[FieldTrip] Fwd: Coordsys issue ft_sourceplot

Marc Recasens recasensmarc at gmail.com
Tue Jun 21 10:32:31 CEST 2016


Dear Andreas,

I managed to get the AAL atlas labels on ortho-plots by adding the same
"coordsys" subfield in both atlas and data files (plus cfg.atlas). I use
coordsys = 'spm' even though everything is "mni", I reckon doesn't matter
as long as both files share the same "coordsys". Maybe there's a more
elegant way to do it but that worked fine for me.

atlas                                 = ft_read_atlas(paths_to_AAL_atlas);
% read aal atlas
atlas.coordsys                   = 'spm';
interpolated_data.coordsys = 'spm';
cfg_plot                             = [];
cfg_plot.method                 = 'ortho';
cfg_plot.funparameter         = 'pow';
cfg_plot.atlas                     = atlas;
ft_sourceplot(cfg_plot,interpolated_data);

Hope it helps
Marc


On Mon, Jun 20, 2016 at 8:22 PM, Andreas Sauer <sauer.mpih at googlemail.com>
wrote:

> Dear Jan-Mathijs,
>
> sorry that I bring up that post again, but I am still having problems with
> the different coordinate systems in my data.
>
> After replacing the .pos field in the source files with the one from the
> "standard_sourcemodel3d5mm" ft_sourceplot works fine, i.e. the functional
> data is not rotated anymore. However, the option cfg.atlas doesn't work
> since I always get the error message "mismatch between the coord sys in the
> atlas and the coord sys in the data...".
>
> I checked the atlas, the functional data (stat) and the anatomy I use for
> interpolation with ft_determine_coordsys. All three files have RAS
> orientation. If I change the anatomical label of the axes of the functional
> data, ft says "neuromag". Unfortunately, the function atlas_lookup works
> only with "mni", "tal" or "spm". So I see where the error messages comes
> from... The difference between MNI and neuromas is the unit (mm resp. m),
> so I thought to use ft_convert_units, but that doesn't work for functional
> data.
>
> Is there any way that I can change the functional data to "MNI" (I thought
> I did this already)? Sorry if this is a straight forward thing, but I don't
> see where I make the mistake...
>
> Thanks a lot and best wishes,
>
> Andreas
>
> 2016-06-15 15:06 GMT+02:00 Schoffelen, J.M. (Jan Mathijs) <
> jan.schoffelen at donders.ru.nl>:
>
>> Are you sure that you use the pos-field from the template, i.e. from the
>> standard_sourcemodel3d5mm?
>>
>> Best,
>> Jan-Mathijs
>>
>> On 15 Jun 2016, at 14:31, Andreas Sauer <sauer.mpih at googlemail.com>
>> wrote:
>>
>> Dear Jan,
>>
>> thank you for your email and the example code!
>>
>> I tried both ways to convert the coord systems, but unfortunately it
>> still doesn't work.
>>
>> Since I used the tutorial procedure to create my sourcemodel (
>> http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space)
>> I tried first with the easy way of only replacing the .pos field. But the
>> plots don't change, the sources are still rotated by 90 degrees. Actually,
>> the .pos fields are already the same before replacing it (see pic). Is
>> there some error in my code?
>>
>>
>> *% Step1: Load mri file*
>> *mri =
>> ft_read_mri('/data/home1/asauer/Projects/RPScZ/Analysis/Beamforming/MRI/HSM12_V2.mri');*
>>
>> *% Step 2: Segment the template brain and construct a volume conduction*
>> *% model (i.e. head model): this is needed for the inside/outside
>> detection of voxels*
>> *cfg = [];*
>> *cfg.output = 'brain';*
>> *segmentedmri = ft_volumesegment(cfg,anatomy);*
>>
>> *cfg = [];*
>> *cfg.method = 'singleshell';*
>> *vol = ft_prepare_headmodel(cfg,segmentedmri);*
>> *vol = ft_convert_units(vol,'m');*
>> *figure; ft_plot_sens(sens,'style','*b'); hold on; ft_plot_vol(vol)*
>>
>> *% Step 3: Load sourcemodel *
>>
>> *load(fullfile(ft_path,'template/sourcemodel/standard_sourcemodel3d5mm'));*
>> *template_grid = sourcemodel;*
>> *clear sourcemodel*
>>
>> *% Step 4: Make sourcemodel*
>> *cfg = [];*
>> *cfg.grid.warpmni = 'yes';*
>> *cfg.grid.template = template_grid;*
>> *cfg.grid.nonlinear = 'yes';*
>> *cfg.mri = mri;*
>> *cfg.grid.unit = 'm';*
>> *grid = ft_prepare_sourcemodel(cfg);*
>> *figure; hold on;*
>> *ft_plot_vol(vol,'facecolor','cortex','edgecolor','none'); alpha 0.5;
>> camlight;*
>> *ft_plot_mesh(grid.pos(grid.inside,:));*
>>
>>
>> The only thing that is different from the tutorial is the unit
>> conversion...
>>
>> After that I tried the transformation. All worked well until the source
>> interpolation. ft_sourceinterpolation throws this error:
>>
>> *Attempted to access sel(1); index out of bounds because numel(sel)=0.*
>>
>> *Error in ft_sourceinterpolate>my_interpn (line 508)*
>> *  ft_progress(sel(1)/num, 'interpolating %.1f%%\n', 100*sel(1)/num);*
>>
>> *Error in ft_sourceinterpolate (line 393)*
>> *    interp.inside( sel) = my_interpn(double(functional.inside), ax(sel),
>> ay(sel), az(sel), 'nearest', cfg.feedback);*
>>
>>
>> which, to be honest, I don't really understand. Sorry...
>>
>> Best wishes,
>>
>> Andreas
>>
>>
>> 2016-06-14 9:41 GMT+02:00 Schoffelen, J.M. (Jan Mathijs) <
>> jan.schoffelen at donders.ru.nl>:
>>
>>> Dear Andreas,
>>>
>>> after having calculated the sources of a MMN paradigm (4D-system), I’d
>>> like to plot the results on one of the anatomy template files in the
>>> fieldtrip directory (single_subj_T1_1mm.nii) or alternatively on a MNI T1
>>> template file (mni_icbm152_t1_tal_nlin_sym_09a.nii). Unfortunately, this is
>>> not working well… As you can see on the attached picture, the functional
>>> data is rotated by 90 degrees.
>>>
>>> I guess that something gets mixed because of the different coordsystems
>>> of functional and anatomical data. The functional data is 4D, which means
>>> ALS orientation. The anatomical is MNI, so RAS orientation. The plotting
>>> works fine, if I use a mri file which was converted in field trip (V2.mri)
>>> and therefore is also in ALS orientation. However, the anatomy doesn’t look
>>> very pretty…
>>>
>>>
>>> Is there any way that I can transform the functional data to RAS
>>> orientation or the anatomical data to ALS orientation, respectively?
>>>
>>>
>>> I tried with ft_volumerealign. However, since the template file has no
>>> fiducials, it is hard to really precisely do this.
>>>
>>>
>>> Fair point. I would however do it the other way around, using the V2 to
>>> get the transformation from voxel space to MNI-RAS, and then use the
>>> inverse of the transformation on the functional data: in this case you
>>> could use ft_volumenormalise, with cfg.nonlinear = ‘no’. Alternatively, if
>>> you are using this procedure:
>>> http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space,
>>> you could directly replace the source.pos of your functional data with the
>>> template.pos and then do the interpolation.
>>>
>>> To summarize:
>>>
>>> either:
>>>
>>> mri = ft_read_mri(‘V2.mri’);
>>> mri.coordsys = ‘bti’;
>>>
>>> cfg = [];
>>> cfg.nonlinear=’no’;
>>> mrin = ft_volumenormalise(cfg, mri);
>>>
>>> transform_vox2bti = mri.transform;
>>> transform_vox2spm = mrin.transform;
>>> transform_bti2spm = transform_vox2spm/transform_vox2bti
>>> source = ft_transform_geometry(transform_bti2spm, source);
>>>
>>> source_int = ft_sourceinterpolate(somecfg, source, niceanatomical);
>>>
>>> or:
>>>
>>> source.pos = templat.pos;
>>> source_int = ft_sourceinterpolate(somecfg, source, niceanatomical);
>>>
>>> Best,
>>> JM
>>>
>>>
>>>
>>> Any input on how to plot the sources on one of these nice anatomical
>>> files is highly appreciated!
>>>
>>> Thanks and best regards,
>>>
>>> Andreas
>>>
>>>
>>> --
>>> Dipl.-Psych. Andreas Sauer
>>> Max Planck Institute for Brain Research
>>> Deutschordenstraße 46
>>> 60528 Frankfurt am Main
>>> Germany
>>>
>>> T: +49 69 96769 278
>>> F: +49 69 96769 327
>>> Email: sauer.mpih at gmail.com
>>> www.brain.mpg.de
>>> <Rotated_Source.png>_______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>
>>
>>
>> --
>> Dipl.-Psych. Andreas Sauer
>> Max Planck Institute for Brain Research
>> Deutschordenstraße 46
>> 60528 Frankfurt am Main
>> Germany
>>
>> T: +49 69 96769 278
>> F: +49 69 96769 327
>> Email: sauer.mpih at gmail.com
>> www.brain.mpg.de
>> <pos_fields.png>_______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>>
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>
>
>
> --
> Dipl.-Psych. Andreas Sauer
> Max Planck Institute for Brain Research
> Deutschordenstraße 46
> 60528 Frankfurt am Main
> Germany
>
> T: +49 69 96769 278
> F: +49 69 96769 327
> Email: sauer.mpih at gmail.com
> www.brain.mpg.de
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>



-- 
Marc Recasens

Tel.: +44 7845810006
Tel.: +34 639241598
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20160621/e414b94c/attachment-0002.html>


More information about the fieldtrip mailing list