Back to the main page.

Bug 1665 - align_ctf2spm.m fails on regular donders MRI data

Status CLOSED FIXED
Reported 2012-08-21 19:36:00 +0200
Modified 2012-08-23 10:47:18 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

Robert Oostenveld - 2012-08-21 19:36:20 +0200

On 21 Aug 2012, at 17:25, Irina Simanova wrote: Hi Robert, I came back from a long weekend , and now I have problems with fieldtrip/utilities/privat/align_ctf2spm.m All operations with anatomical scans that require this function fail with an SPM error: “There is not enough overlap in the images to obtain a solution”. I am pretty sure I didn’t see this error last week with the very same scripts. I see that align_ctf2spm.m was modified last Friday (aug 17). Is it a bug? Or should I now align individual structural image with the template in order it to work? Best, Irina Here is the full text of the error: * - SPM8: spm_affreg ---------------------------------------------- There is not enough overlap in the images to obtain a solution. Please check that your header information is OK. The Check Reg utility will show you the initial alignment between the images, which must be within about 4cm and about 15 degrees in order for SPM to find the optimal solution. ----------------------------------------- 17:11:17 - 21/08/2012 ??? Error using ==> spm_affreg>error_message at 474 insufficient image overlap Error in ==> spm_affreg at 177 if length(msk)<32, error_message; end; Error in ==> align_ctf2spm at 61 [M, scale] = spm_affreg(V1,V2,flags); Error in ==> ft_convert_coordsys at 63 obj = align_ctf2spm(obj); Error in ==> ft_volumesegment at 263 mri = ft_convert_coordsys(mri, 'spm'); Error in ==> MEG_process_structural at 66 struct_segment = ft_volumesegment(cfg, struct_reslice);


Robert Oostenveld - 2012-08-21 19:37:31 +0200

@Irina could you attach (or better send through home/common because of privacy) the input MRI and cfg on which it fails? That will help in debugging and ensuring that the problem (when fixed) does not re-surface in the future.


Irina - 2012-08-22 08:50:29 +0200

(In reply to comment #1) I put a mat-file with an MRI image in Fieldtrip format into common/temporary/4Bugzilla Here is the code: load segmentedS2 struct_reslice cfg = []; cfg.coordsys = 'ctf'; struct_segment = ft_volumesegment(cfg, struct_reslice);


Robert Oostenveld - 2012-08-22 09:01:18 +0200

(In reply to comment #2) thanks. I have copied the test data to roboos@mentat001> pwd /home/common/matlab/fieldtrip/data/test/bug1665 roboos@mentat001> ls segmentedS2.mat


Jan-Mathijs Schoffelen - 2012-08-22 09:27:54 +0200

error reproduced. it could be caused by the fact that the bounding box around the anatomical does not fully encapsulate the whole head. If I take a resliced MRI, in which this is the case, i.e. the head is more centered in the image, the affine registration works just fine. It could have another cause though, but this would be my first guess.


Jan-Mathijs Schoffelen - 2012-08-22 09:38:59 +0200

Hi Irinia, Could you also upload the original MRI so that I can see why the reslicing does not work appropriately?


Jan-Mathijs Schoffelen - 2012-08-22 10:01:58 +0200

Found it. After reslicing the anatomical volume contains NaNs. This is something SPM cannot handle. I suggest to fix this in ft_volumereslice, and to build in a check in align_ctf2spm to convert the NaNs to 0. Also, I will build a try catch around the spm based coregistration, so that the function will not crash, but just provides the initial (and sometimes inaccurate) coregistration matrix. @Robert: agreed?


Robert Oostenveld - 2012-08-22 10:23:26 +0200

(In reply to comment #6) I agree with the 0s instead of NaNs (at both locations, i.e. when creating and also when using it). Is it an idea to implement this through ft_checkdata (and code+documentation it in ft_datatype_volume), i.e. there we can state that the anatomy is not allowed to contain NaNs? I am not sure what the value is of getting the initial coregistration matrix in case SPM fails. If that is of little value, then it is better to throw the SPM error.


Jan-Mathijs Schoffelen - 2012-08-22 10:51:37 +0200

well, the initial coregistration matrix is the one which was outputted prior to my changes last week. these have been of good enough value to the DCCN anatomicals so far. I am not sure whether I could imagine scenarios where the approximate coregistration (if not accurate enough to begin with) is sufficient. I would be happy to then stick to the SPM error. Do we have an accord?


Jan-Mathijs Schoffelen - 2012-08-22 11:13:58 +0200

svn commit ../ft_volumereslice.m private/align_itab2spm.m private/align_ctf2spm.m ft_datatype_volume.m Sending ft_volumereslice.m Sending utilities/ft_datatype_volume.m Sending utilities/private/align_ctf2spm.m Sending utilities/private/align_itab2spm.m Transmitting file data .... Committed revision 6393. and svn commit test_bug1665.m Sending test_bug1665.m Transmitting file data . Committed revision 6394.