Back to the main page.

Bug 115 - ft_prepare_mesh not robust in dealing with inputfile

Status CLOSED FIXED
Reported 2010-07-19 09:21:00 +0200
Modified 2010-07-21 14:15:51 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P1 enhancement
Assigned to: Joint development user
URL:
Tags:
Depends on:
Blocks:
See also:

Jan-Mathijs Schoffelen - 2010-07-19 09:21:09 +0200

Ali reported a problem when ft_prepare_mesh was called with a segmented mri in the input. For some reason the following part of the code did not work. Apparently, cfg.inputfile was not empty, resulting in an empty mri. Consequently basedonseg was not assigned correctly. I found the problem. The following is a part of ft_prepare_mesh.m file: if ~isempty(cfg.inputfile) % the input data should be read from file if hasdata error('cfg.inputfile should not be used in conjunction with giving input data to this function'); else mri = loadvar(cfg.inputfile, 'data'); end else mri = []; end This should be made more robust. Ali suggested: if ~exist('mri', 'var'), mri = []; end Yet this should be taken care of by the earlier assigned hasdata. I would suggest an explicit conditional check: if hasdata && ~isempty(cfg.inputfile) error('....'); elseif hasdata && isempty(cfg.inputfile) % this is OK elseif ~hasdata && ~isempty(cfg.inputfile) mri = loadvar(...); elseif ~hasdata && isempty(cfg.inputfile) % apparently no input data is needed mri = []; end


Jan-Mathijs Schoffelen - 2010-07-21 10:22:43 +0200

I made some changes to make the handling of the input more robust. Ali, could you do an svn update and report back whether this fixes your issue? Thanks.


Ali Bahramisharif - 2010-07-21 12:56:51 +0200

(In reply to comment #1) > I made some changes to make the handling of the input more robust. > > Ali, could you do an svn update and report back whether this fixes your issue? > > Thanks. There is something wrong in the code! (ft_prepare_mesh.m) Line 73: <<<<<<< .mine Line 80: ====== Line 83: >>>>>>> .r1433 I do not know how they are there! But if I remove these three lines, it would be fine. Thanks. Ali


Jan-Mathijs Schoffelen - 2010-07-21 13:44:01 +0200

Hi Ali, This is because svn did not manage merge the changes in the repository (made and committed by me) with the changes you made to your local copy (but did not commit). To be completely sure, you should physically remove your copy (rm ft_prepare_mesh.m) and then update (svn update ft_prepare_mesh.m). In that case, your file will be clean again, and in sync with the svn-repository


Ali Bahramisharif - 2010-07-21 14:09:32 +0200

Yes. You are right. Now it is fine. Thanks.