<div dir="ltr"><div><div><div>Dear Andreas,<br><br></div>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.<br><br>atlas                                 = ft_read_atlas(paths_to_AAL_atlas); % read aal atlas<br>atlas.coordsys                   = 'spm';<br>interpolated_data.coordsys = 'spm';<br>cfg_plot                             = [];<br>cfg_plot.method                 = 'ortho';<br>cfg_plot.funparameter         = 'pow';<br>cfg_plot.atlas                     = atlas;<br>ft_sourceplot(cfg_plot,interpolated_data);<br><br></div>Hope it helps<br></div>Marc<br><div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 8:22 PM, Andreas Sauer <span dir="ltr"><<a href="mailto:sauer.mpih@googlemail.com" target="_blank">sauer.mpih@googlemail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Jan-Mathijs,<div><br></div><div>sorry that I bring up that post again, but I am still having problems with the different coordinate systems in my data. </div><div><br></div><div>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...". </div><div><br></div><div>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.</div><div><br></div><div>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...</div><div><br></div><div>Thanks a lot and best wishes,</div><div><br></div><div>Andreas</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-06-15 15:06 GMT+02:00 Schoffelen, J.M. (Jan Mathijs) <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="word-wrap:break-word">
Are you sure that you use the pos-field from the template, i.e. from the standard_sourcemodel3d5mm?<br>
<div>
<div>
<div style="word-wrap:break-word">
<div><br>
</div>
<div>Best,</div>
<div>Jan-Mathijs</div>
<div><br>
<div>
<blockquote type="cite"><div><div>
<div>On 15 Jun 2016, at 14:31, Andreas Sauer <<a href="mailto:sauer.mpih@googlemail.com" target="_blank">sauer.mpih@googlemail.com</a>> wrote:</div>
<br>
</div></div><div><div><div>
<div dir="ltr">Dear Jan,
<div><br>
</div>
<div>thank you for your email and the example code!</div>
<div><br>
</div>
<div>I tried both ways to convert the coord systems, but unfortunately it still doesn't work. </div>
<div><br>
</div>
<div>Since I used the tutorial procedure to create my sourcemodel (<a href="http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space" style="font-size:13px" target="_blank">http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space</a>)
 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? </div>
<blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px">
<div><i><br>
</i></div>
<div><i>% Step1: Load mri file</i></div>
<div>
<div><i>mri = ft_read_mri('/data/home1/asauer/Projects/RPScZ/Analysis/Beamforming/MRI/HSM12_V2.mri');</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>% Step 2: Segment the template brain and construct a volume conduction</i></div>
</div>
<div>
<div><i>% model (i.e. head model): this is needed for the inside/outside detection of voxels</i></div>
</div>
<div>
<div><i>cfg = [];</i></div>
</div>
<div>
<div><i>cfg.output = 'brain';</i></div>
</div>
<div>
<div><i>segmentedmri = ft_volumesegment(cfg,anatomy);</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>cfg = [];</i></div>
</div>
<div>
<div><i>cfg.method = 'singleshell';</i></div>
</div>
<div>
<div><i>vol = ft_prepare_headmodel(cfg,segmentedmri);</i></div>
</div>
<div>
<div><i>vol = ft_convert_units(vol,'m');</i></div>
</div>
<div>
<div><i>figure; ft_plot_sens(sens,'style','*b'); hold on; ft_plot_vol(vol)</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>% Step 3: Load sourcemodel </i></div>
</div>
<div>
<div><i>load(fullfile(ft_path,'template/sourcemodel/standard_sourcemodel3d5mm'));</i></div>
</div>
<div>
<div><i>template_grid = sourcemodel;</i></div>
</div>
<div>
<div><i>clear sourcemodel</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>% Step 4: Make sourcemodel</i></div>
</div>
<div>
<div><i>cfg = [];</i></div>
</div>
<div>
<div><i>cfg.grid.warpmni = 'yes';</i></div>
</div>
<div>
<div><i>cfg.grid.template = template_grid;</i></div>
</div>
<div>
<div><i>cfg.grid.nonlinear = 'yes';</i></div>
</div>
<div>
<div><i>cfg.mri = mri;</i></div>
</div>
<div>
<div><i>cfg.grid.unit = 'm';</i></div>
</div>
<div>
<div><i>grid = ft_prepare_sourcemodel(cfg);</i></div>
</div>
<div>
<div><i>figure; hold on;</i></div>
</div>
<div>
<div><i>ft_plot_vol(vol,'facecolor','cortex','edgecolor','none'); alpha 0.5; camlight;</i></div>
</div>
<div>
<div><i>ft_plot_mesh(grid.pos(grid.inside,:));</i></div>
</div>
</blockquote>
<div><br>
</div>
<div>The only thing that is different from the tutorial is the unit conversion... <br>
</div>
<div><br>
</div>
<div>After that I tried the transformation. All worked well until the source interpolation. ft_sourceinterpolation throws this error:</div>
<div><br>
</div>
<blockquote style="margin:0px 0px 0px 40px;border:medium none;padding:0px">
<div>
<div><i>Attempted to access sel(1); index out of bounds because numel(sel)=0.</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>Error in ft_sourceinterpolate>my_interpn (line 508)</i></div>
</div>
<div>
<div><i>  ft_progress(sel(1)/num, 'interpolating %.1f%%\n', 100*sel(1)/num);</i></div>
</div>
<div>
<div><i><br>
</i></div>
</div>
<div>
<div><i>Error in ft_sourceinterpolate (line 393)</i></div>
</div>
<div>
<div><i>    interp.inside( sel) = my_interpn(double(functional.inside), ax(sel), ay(sel), az(sel), 'nearest', cfg.feedback);</i></div>
</div>
</blockquote>
<div><br>
</div>
<div>which, to be honest, I don't really understand. Sorry...</div>
<div><br>
</div>
<div>Best wishes,</div>
<div><br>
</div>
<div>Andreas</div>
<div><br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2016-06-14 9:41 GMT+02:00 Schoffelen, J.M. (Jan Mathijs)
<span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="word-wrap:break-word">Dear Andreas,
<div>
<div><span><br>
<blockquote type="cite">
<div>
<div dir="ltr">
<div style="font-family:Helvetica;font-size:12px">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. </div>
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div style="font-family:Helvetica;font-size:12px">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… </div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div>
<div dir="ltr">
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div style="font-family:Helvetica;font-size:12px">Is there any way that I can transform the functional data to RAS orientation or the anatomical data to ALS orientation, respectively?</div>
</div>
</div>
</blockquote>
<blockquote type="cite">
<div>
<div dir="ltr">
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div style="font-family:Helvetica;font-size:12px">I tried with ft_volumerealign. However, since the template file has no fiducials, it is hard to really precisely do this. </div>
</div>
</div>
</blockquote>
<div><br>
</div>
</span>
<div>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: <a href="http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space" target="_blank">
http://www.fieldtriptoolbox.org/tutorial/sourcemodel#subject-specific_grids_that_are_equivalent_across_subjects_in_normalized_space</a>, you could directly replace the source.pos of your functional data with the template.pos and then do the interpolation.</div>
<div><br>
</div>
<div>To summarize: </div>
<div><br>
</div>
<div>either:</div>
<div><br>
</div>
<div>mri = ft_read_mri(‘V2.mri’);</div>
<div>mri.coordsys = ‘bti’;</div>
<div><br>
</div>
<div>cfg = [];</div>
<div>cfg.nonlinear=’no’;</div>
<div>mrin = ft_volumenormalise(cfg, mri);</div>
<div><br>
</div>
<div>transform_vox2bti = mri.transform;</div>
<div>transform_vox2spm = mrin.transform;</div>
<div>transform_bti2spm = transform_vox2spm/transform_vox2bti</div>
<div>source = ft_transform_geometry(transform_bti2spm, source);</div>
<div><br>
</div>
<div>source_int = ft_sourceinterpolate(somecfg, source, niceanatomical);</div>
<div><br>
</div>
<div>or:</div>
<div><br>
</div>
<div>source.pos = templat.pos;</div>
<div>source_int = ft_sourceinterpolate(somecfg, source, niceanatomical);</div>
<div><br>
</div>
<div>Best,</div>
<div>JM</div>
<div><br>
</div>
<div><br>
</div>
<br>
<blockquote type="cite">
<div><span>
<div dir="ltr">
<div style="font-family:Helvetica;font-size:12px">Any input on how to plot the sources on one of these nice anatomical files is highly appreciated!</div>
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div style="font-family:Helvetica;font-size:12px">Thanks and best regards,</div>
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div style="font-family:Helvetica;font-size:12px">Andreas</div>
<div style="font-family:Helvetica;font-size:12px"><br>
</div>
<div><br>
</div>
-- <br>
<div data-smartmail="gmail_signature">
<div></div>
<div>Dipl.-Psych. Andreas Sauer</div>
<div>Max Planck Institute for Brain Research</div>
<div>Deutschordenstraße 46</div>
<div>60528 Frankfurt am Main</div>
<div>Germany</div>
<div><br>
</div>
<div>T: <a href="tel:%2B49%2069%2096769%20278" value="+496996769278" target="_blank">
+49 69 96769 278</a></div>
<div>F: <a href="tel:%2B49%2069%2096769%20327" value="+496996769327" target="_blank">
+49 69 96769 327</a></div>
<div>Email: <a href="mailto:sauer.mpih@gmail.com" target="_blank">
sauer.mpih@gmail.com</a></div>
<div><a href="http://www.brain.mpg.de/" target="_blank">www.brain.mpg.de</a></div>
</div>
</div>
</span><span><Rotated_Source.png></span>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div>
<br>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
<div data-smartmail="gmail_signature">
<div></div>
<div>Dipl.-Psych. Andreas Sauer</div>
<div>Max Planck Institute for Brain Research</div>
<div>Deutschordenstraße 46</div>
<div>60528 Frankfurt am Main</div>
<div>Germany</div>
<div><br>
</div>
<div>T: <a href="tel:%2B49%2069%2096769%20278" value="+496996769278" target="_blank">+49 69 96769 278</a></div>
<div>F: <a href="tel:%2B49%2069%2096769%20327" value="+496996769327" target="_blank">+49 69 96769 327</a></div>
<div>Email: <a href="mailto:sauer.mpih@gmail.com" target="_blank">
sauer.mpih@gmail.com</a></div>
<div><a href="http://www.brain.mpg.de/" target="_blank">www.brain.mpg.de</a></div>
</div>
</div>
</div>
</div></div><span><pos_fields.png></span>_______________________________________________<span><br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
</div>

<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div></div><div>Dipl.-Psych. Andreas Sauer</div><div>Max Planck Institute for Brain Research</div><div>Deutschordenstraße 46</div><div>60528 Frankfurt am Main</div><div>Germany</div><div><br></div><div>T: <a href="tel:%2B49%2069%2096769%20278" value="+496996769278" target="_blank">+49 69 96769 278</a></div><div>F: <a href="tel:%2B49%2069%2096769%20327" value="+496996769327" target="_blank">+49 69 96769 327</a></div><div>Email: <a href="mailto:sauer.mpih@gmail.com" target="_blank">sauer.mpih@gmail.com</a></div><div><a href="http://www.brain.mpg.de" target="_blank">www.brain.mpg.de</a></div></div>
</div>
</div></div><br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br><br clear="all"><br>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div>Marc Recasens<br><span><span><br>Tel.: <a href="tel:%2B44%207845810006" value="+447845810006" target="_blank">+44 7845810006</a></span></span><br>Tel.: <a href="tel:%2B34%20639241598" value="+34639241598" target="_blank">+34 639241598</a><br></div></div></div>
</div></div></div></div>