Back to the main page.

Bug 2531 - surfaceplot made by ft_sourceplot sparing thefrontal lobes

Status CLOSED FIXED
Reported 2014-04-10 16:02:00 +0200
Modified 2014-06-18 12:31:14 +0200
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Windows
Importance: P5 normal
Assigned to: Jan-Mathijs Schoffelen
URL:
Tags:
Depends on:
Blocks:
See also:

- 2014-04-10 16:02:55 +0200

Created attachment 604 surfaceplot with cfg.funparameter avg.pow and maskparameter anatomy Hello, The plot I generated by ft_sourceplot using cfg.method = 'surface' with either projectionemthod 'nearest' or 'project' looks funny. The frontal lobes don't show any activation, they are just left grey. And also specific activations on the cortex are shifted towards the back (y-axis). I compared the same 3-D- sourceactivation data (interpolated on the standard T1 output of ft_interpolate with ft_interpolate) in an orthoplot and there the sourceactivation is neatly arranged in the whole brain volume, including the frontal lobes. So that the mistake must origin in the ft_sourceplot function. I use the version of the 18th of December 2013. Also the latest version of yesterday is still having this problem. A version I used from first of january 2013 was not showing this problem, but I need other functionalities of the later versions... Do you know this problem and can help me with it? If not, do you have an idea to solve it or cirumvent it? Thanks in advance, Marlene


Arjen Stolk - 2014-04-10 16:15:00 +0200

Hi Marlene, Thanks for reporting this issue. Could you add your processing steps to the description, e.g. lines of code? Right now, all we know is that you used cfg.method = 'surface', which obviously is not much. Also, it would be helpful to have an overview of the source structure, i.e. dimensions of source.pos etc. best, Arjen


- 2014-04-10 16:20:48 +0200

Created attachment 605 sourcedata with the field trial emptied to reduce size mri = ft_read_mri(fullfile(basedir, 'source' ,'single_subj_T1.nii')); mri = ft_volumereslice([], mri); cfg_i = []; cfg_i.parameter = {'avg.pow'}; %prob: proportion of draws with a clusterstatistic larger than clusterstat. the less the more significant cfg_i.downsample = 2; plot_rel_young1 = ft_sourceinterpolate(cfg_i, source_rel_young1,mri); % source_rel_young1 is the output of ft_sourcegrandaverage, which i did on % ft_sourceanalysis data using DICS cfg.maskparameter='anatomy'; cfg.funparameter = 'avg.pow'; cfg.method = 'surface' cfg.projmethod= 'project' cfg.funcolorlim=[-0.2 0.2] cfg.location = [-35.5 -25.5 60.5] figure ft_sourceplot(cfg, plot_rel_young1);


- 2014-04-10 16:29:47 +0200

(In reply to Arjen Stolk from comment #1) HI Arjen, I just uploaded the sourcedata I plot and the code including the interpolation. the sourcedata has a dim of dim: [35 44 39] and the interpolation I do with downsampling by two, resulting in a source volume to be plotted of dim: [128 128 128] I uploaded the struct to be interpolated again without the .trial field, the interpolation doesnt work if it is still in there but emptied. Best, Marlene


- 2014-04-10 16:31:07 +0200

Created attachment 606 sourcedata with the field trial removed to reduce size


Arjen Stolk - 2014-04-10 17:07:50 +0200

Dear Marlene, I have been able to replicate your 'bug' using cfg.funparameter = 'avg.pow' cfg.method = 'surface' cfg.projemethod = 'nearest' cfg.surffile = 'surface_pial_both.mat' ft_sourceplot(cfg, source_rel_young1) Whereas cfg.method = 'ortho' ft_sourceplot(cfg, source_rel_young1) does show values at those locations, that are not NaNs. However, closer inspection reveals that the values at those locations are the smallest across the whole brain, suggesting it could be related to thresholding (opacitylimits perhaps - obscuring the smallest values in source.avg.pow). Yours, Arjen


Jan-Mathijs Schoffelen - 2014-04-10 17:26:17 +0200

Note to Arjen: As you know, the interpolation onto the surface mesh is done on the fly in ft_sourceplot, but it is not guaranteed that the cortical sheet that is used for the visualisation is nicely registered with the anatomical image that is used for the explicit interpolation step using ft_sourceinterpolate. I think the first thing you should check is whether the mesh in cfg.surffile is in register with the anatomical 3D image. ft_plot_montage supports the option of plotting a mesh along with an anatomical image, to be used as: options = {'transform', mri.transform,'nslice',16,'intersectmesh',{surfacemesh},... 'intersectlinewidth',1,'slicesize',[300 300]}; figure; ft_plot_montage(mri.anatomy, 'location', [0 0 0], 'orientation', [0 0 1], 'slicerange', [-20 120], options{:}); mri is the anatomical volume, surfacemesh is the mesh loaded from the surffile. Extra note to Arjen: irrespective of the thing being an interpolation issue or not, this is a good example of why certain functionality should be represented at a single location, i.e. ft_sourceinterpolate. It keeps the code easier to manage. If it's a registration issue, we should ensure that the anatomical template that can be used for source-interpolation (defined in standard space) is the one from which the template meshes have been derived (ensuring at least that these are defined in the same standard space).


- 2014-04-10 18:48:44 +0200

Created attachment 607 surfaceplot "wrong"


- 2014-04-10 18:49:51 +0200

(In reply to Arjen Stolk from comment #5) Hi Arjen, I plotted the same data in one version of the 01.01.2013 (activity spread over the whole cortex) and one version of the 18.12.2013 (activity missing the frontal lobes). You can see one blop of decreased activity which is actually shifted towards lower y values in the plot done with the later version. IN the ortho plot of both versions the blop also appears rather more frontal, corresponding to the location of the plot of the version of the 01.01.2013. So I am pretty sure, that the activity is not correctly illustrated. Thanks to both of you for taking care of that issue. As a workaround I could do the plotting with the earlier version and the rest with the later version, but it makes everything a bit messy. Best, Marlene


- 2014-04-10 18:50:30 +0200

Created attachment 608 surfaceplot "good"


Jan-Mathijs Schoffelen - 2014-04-10 20:06:35 +0200

Created attachment 609 cortical sheet is out of register with T1 template brain


Jan-Mathijs Schoffelen - 2014-04-10 20:06:56 +0200

As the latest attachment shows, the cortical sheet is out of register with the template brain.


Jan-Mathijs Schoffelen - 2014-04-10 20:24:28 +0200

Created attachment 610 cortical sheet is back in register after JM's magical transformation


Jan-Mathijs Schoffelen - 2014-04-10 20:29:57 +0200

OK guys, the problem was that the freesurfer surfaces are expressed in another coordinate system, which was not taken into account when I uploaded the template surfaces. I applied the transformation matrix from the surfrend toolbox to the surfaces and the result seems to make sense. The shitty thing is that the mis-registered surfaces have been introduced in the version of 13/12/2013, i.e. 5 days before the version that Marlene used, so it has been in FT for a while. Funny that nobody had noticed before. Well spotted, Marlene! Course of action: -Fix the affected surfaces. -Document the fix, and document the time period in which the surfaces were wrong. -Write an e-mail to the discussion list.


Arjen Stolk - 2014-04-10 20:44:15 +0200

Nice work, JM. "Funny that nobody had noticed before. Well spotted, Marlene!" I guess we all were impressed by the beauty of the new surface renderings.


Arjen Stolk - 2014-04-10 20:53:37 +0200

"Extra note to Arjen: irrespective of the thing being an interpolation issue or not, this is a good example of why certain functionality should be represented at a single location, i.e. ft_sourceinterpolate. It keeps the code easier to manage." I fully agree with that logic of course. However, 1) that functionality (i.e. reducepatch) was already there in ft_sourceplot, and 2) it has to be there, or at least, when the functionality is moved over to ft_sourceinterpolate, ft_sourceplot has to call ft_sourceinterpolate for adjusting the cortical mesh. Would the latter be preferred behavior?


- 2014-04-10 22:36:03 +0200

I expected something like that singe the cfg.surffile was different between those two versions... but I wouldn't have been able to manage that myself. You fieldtrippers are ingenious! Thanks again for such a quick and effectual help to JM and Arjen. So I will read in the discussion list, when the new version is prepared, I guess. Many greetings, Marlene


- 2014-04-11 14:26:49 +0200

(In reply to Jan-Mathijs Schoffelen from comment #13) HI Jan-Mathijs, I would like to do some plotting over the weekend. So just in case the fieldtrip version of ft_sourfaceplot is not rehabilitated until then, could you send me the surface_white_both.mat with your magical transformation done to them which I would just incorporate into my existing fieldtrip version to make it work properly? Many greetings, Marlene


Jan-Mathijs Schoffelen - 2014-04-12 20:36:39 +0200

bash-4.1$ svn commit -m "bugfix - updated coordinates of the surfaces to match the MNI coordinate system in the corresponding anatomical image" *.mat Sending surface_inflated_both.mat Sending surface_inflated_left.mat Sending surface_inflated_right.mat Sending surface_pial_both.mat Sending surface_pial_left.mat Sending surface_pial_right.mat Sending surface_white_both.mat Sending surface_white_left.mat Sending surface_white_right.mat Transmitting file data ......... Committed revision 9401. Check for further documentation http://fieldtrip.fcdonders.nl/template/anatomy


Arjen Stolk - 2014-04-13 10:09:13 +0200

Thanks for fixing, JM. I've added your mail below for bookkeeping. [FieldTrip] ft_sourceplot: issue with cfg.method = 'surface' 12 april 2014 21:03 Dear fieldtrippers, Despite our best efforts, there has been an inconvenient bug in ft_sourceplot, which has been present in r9031-r9400 (Dec 13, 2013-April 12,2014). In particular, the images constructed when using cfg.method = 'surface' were incorrect. The issue pertains to the on-the-fly interpolation onto a cortical sheet of volumetrically (i.e. on a 3D grid) source-reconstructed data. I updated the cortical sheets last December, and replaced the handcrafted exemplars by the ones from the SPM surfrend toolbox. The motivation for all this would be to have a better reference to the actual data used. The bottom line of all this is that I made a mistake, and directly used the surfaces loaded from the Freesurfer file format, without taking into account the fact that in the Freesurfer convention the coordinate system in these files is slightly different than standard space. As a consequence these surfaces were misregistered to the 3D anatomical image in standard space, and thus to incorrect interpolations of the functional data onto these surfaces. This issue has been identified thanks to Marlene Bönstrup and has been fixed today. Any sourceplots with cfg.method = 'surface' that have been made with FieldTrip versions originating from between the dates mentioned above will incorrectly represent the source reconstructed data, and may need to be re-done. More info can be found on http://fieldtrip.fcdonders.nl/template/anatomy. I am very sorry for any inconvenience this may have caused. Best wishes, Jan-Mathijs Schoffelen, MD PhD