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