AW: [FIELDTRIP] Neuromag-fif-mri from mne to fieldtrip.

Gustavo Sudre gsudre at POBOX.COM
Wed Jul 8 14:17:09 CEST 2009


Hi,

I've been following this discussion closely because I've been having  
the same problem. The new read_mri worked fine for me (thanks for  
that!). Now, the mri I import is already in head coordinates (Neuromag  
standard: mri.hdr.trans.from=4), and it has been realigned to the data  
using a separate program, so I would prefer to not re-define the  
fiducials using volumerealign. In this case, is it enough to just  
switch the X and Y axes manually (mri.anatomy = permute(mri.anatomy,[2  
1 3])) to conform to CTF standards, and use the identity matrix for  
mri.transform?

If I understand it correctly, mri.transform is used to take the mri  
(or any volume) to head coordinates, right? So, I was wondering what  
steps the mri.transform matrix is required. Do other common future  
steps (e.g. plotting, preparing headmodel, leadfield, etc) assume the  
volume is already in head coordinates, or do they always use  
vol.transform for that?

Also, when I tried removing mri,transform, volumerealign didn't like  
it because the mri structure wasn't a volume structure anymore (and I  
imagine other functions will complain about it too, that's why I used  
the identity).

Thanks,

Gus

On Jul 8, 2009, at 4:22 AM, jan-mathijs schoffelen wrote:

> Hi Hanneke,
>
> Please note that the X and Y axis in the neuromag head-coordinate  
> system are swapped with respect to the CTF and 4D convention; i.e. X  
> axis through the ears, and Y-axis to the nose.
> What usually works for me is discarding the mri.transform (mri =  
> rmfield(mri, 'transform'), and call volumerealign in the interactive  
> mode. You can then specify the location of the fiducials yourself
> and the output mri of the function will contain a transformation  
> matrix according to ctf convention. This at least ensures that  
> volumesegment etc kind of work properly. Yet, it is important to  
> know that of course the gradiometer positions in the data are  
> defined in neuromag convention, so after preparing your volume  
> conduction model you probably have to swap the x and y coordinates  
> of the vol.bnd.pnt (assuming you use a singleshell as volume  
> conductor model), before proceeding to visualization (headmodelplot;  
> just to check whether the head fits in the helmet), leadfield  
> computation (only makes sense if the head fits in the helmet), and  
> sourceanalysis (idem).
>
> Yours,
>
> JM
>
>
>
>
> On Jul 8, 2009, at 9:09 AM, Robert Oostenveld wrote:
>
>> Hi Hanneke,
>>
>> I have tried importing another MRI fif file which I still had on  
>> disk using the following modification of the fieldtrip/fileio/ 
>> read_mri.m code
>>
>>  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
>> %%%%%%%%%%%%%
>> elseif filetype(filename, 'neuromag_fif') && hastoolbox('mne')
>>  % use the mne functions to read the Neuromag MRI
>>  hdr = fiff_read_mri(filename);
>>  img = cat(3, hdr.slices.data);
>>  hdr.slices = rmfield(hdr.slices, 'data'); % remove the image data  
>> to save memory
>>  transform = hdr.trans.trans;
>>
>> and then slightly further down in the code
>>
>> % set up the axes of the volume in voxel coordinates
>> nx = size(img,1);
>> ny = size(img,2);
>> nz = size(img,3);
>> mri.dim = [nx ny nz];
>> % store the anatomical data
>> mri.anatomy = img;
>> % store the header with all fileformat specific details
>> mri.hdr = hdr;
>> try
>>  % if present, store the homogenous transformation matrix
>>  mri.transform = transform;
>> end
>>
>> This results in a warning of the MNE fiff_read_mri function
>>
>> >> mri = read_mri('lp_mri_headcoords.fif')
>> 	Reading slice information and pixel data..50..100..126..[done]
>> 	The slices are not equally spaced. Voxel transformation will not  
>> be included
>>
>> mri =
>>          dim: [256 256 126]
>>      anatomy: [256x256x126 int16]
>>          hdr: [1x1 struct]
>>    transform: [4x4 double]
>>
>> and the resulting coordinate transformation matrix is not fully  
>> correct. You can check the coordinates by plotting it intreactively  
>> in sourceplot (after converting the image data from int16 into  
>> double).
>>
>> Perhaps one of the Neuromag experts on the list can help you further.
>>
>> best regards,
>> Robert
>>
>> PS atatched is the latest read_mri function, which includes the  
>> call to fiff_read_mri.
>>
>>
>> On 8 Jul 2009, at 9:49, Robert Oostenveld wrote:
>>
>>> Hi Hanneke,
>>>
>>> The mri.fif file that you sent only contains the header  
>>> information, but not the slice/image information.
>>>
>>> >> fiff_read_mri('mri.fif')
>>> 	Reading slice information and pixel data.??? Error using ==>  
>>> fiff_read_mri at 116
>>> Could not locate pixel file /neuro/mri/k/kahlbrock_nina/slices/ 
>>> MR1.3.12.2.1107.5.2.32.35204.2008010817494654069656329
>>>
>>> Please also send the corresponding slice data.
>>>
>>> Robert
>>>
>>>
>>> On 8 Jul 2009, at 9:01, Hanneke Van Dijk wrote:
>>>
>>>> Hi Robert,
>>>>
>>>> Thanks for your reply. I have tried the meg_pd function loadmri  
>>>> (via read_mri in fieldtrip) but I got the feedback: 'error  
>>>> loading mri-file'. So I have no idea what is going wrong. I will  
>>>> send you the example mri-file right now. It is probably not to  
>>>> difficult to work something out but I want to be sure that the  
>>>> mri head coordinates end up in the right way as device coordinates.
>>>>
>>>> Thanks in advance!
>>>> Viele Gruße aus Düsseldorf ;-)
>>>>
>>>> Hanneke
>>>
>>> ----------------------------------
>>> The aim of this list is to facilitate the discussion between users  
>>> of the FieldTrip  toolbox, to share experiences and to discuss new  
>>> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html 
>>>  and http://www.ru.nl/neuroimaging/fieldtrip.
>>>
>>
>> ----------------------------------
>> The aim of this list is to facilitate the discussion between users  
>> of the FieldTrip  toolbox, to share experiences and to discuss new  
>> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html 
>>  and http://www.ru.nl/neuroimaging/fieldtrip.<read_mri.m>
>
> ----------------------------------
> The aim of this list is to facilitate the discussion between users  
> of the FieldTrip  toolbox, to share experiences and to discuss new  
> ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html 
>  and http://www.ru.nl/neuroimaging/fieldtrip.

----------------------------------
The aim of this list is to facilitate the discussion between users of the FieldTrip  toolbox, to share experiences and to discuss new ideas for MEG and EEG analysis. See also http://listserv.surfnet.nl/archives/fieldtrip.html and http://www.ru.nl/neuroimaging/fieldtrip.



More information about the fieldtrip mailing list