Back to the main page.

Bug 1573 - GrandAVG and Stats can't be plottet on anatomy or be interpolated on an MRI

Status CLOSED WORKSFORME
Reported 2012-06-29 14:05:00 +0200
Modified 2013-06-06 15:10:07 +0200
Product: FieldTrip
Component: plotting
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P1 major
Assigned to: Johanna
URL:
Tags:
Depends on:
Blocks: 1554
See also:

Martin - 2012-06-29 14:05:23 +0200

Hello, I got a kind of big problem as follows. I can easly normalize, interpolate and plot my LCMV-Beamformer results on an MRI and plot with that anatomy: template = '/media/sonja1/MatlabAnalysis/Martin/WFU_PickAtlas/spm8/canonical/single_subj_T1.nii'; template_mri = ft_read_mri(template); cfg = []; % cfg.coordsys = 'spm'; cfg.method = 'fiducial'; %'interactive'; cfg.fiducial.nas = [45 106 17]; %position of nasion cfg.fiducial.lpa = [88 49 11]; %position of LPA cfg.fiducial.rpa = [3 49 11]; %position of RPA mri = ft_volumerealign(cfg, template_mri); load(sourcesOutFile); cfg = []; cfg.downsample = 1; cfg.parameter = {'avg.pow', 'avg.logpowDiff'}; sourceDiffInt = ft_sourceinterpolate(cfg, sourceDiff , mri); Works without any problem! And can be plotted afterwords kind of nicely on an anatomy. Now what doesn't work: %Load functional data load(['/media/sonja1/Patienten/Parkinson/grandAVG_SourceDiff_OHNEdysphagie__beta.mat']); %avg.avg.pow to avg.pow powtemp = grandavg.avg.avg.pow; grandavg = rmfield(grandavg, 'avg'); grandavg.avg.pow = powtemp; %Load template MRI template = '/media/sonja1/MatlabAnalysis/Martin/WFU_PickAtlas/spm8/canonical/single_subj_T1.nii'; template_mri = ft_read_mri(template); %Segment and Interpolate MRI cfg = []; cfg.method = 'fiducial'; %'interactive'; cfg.fiducial.nas = [45 106 17]; %position of nasion cfg.fiducial.lpa = [88 49 11]; %position of LPA cfg.fiducial.rpa = [3 49 11]; %position of RPA mri_realign = ft_volumerealign(cfg, template_mri); % match up volumetric source result matrix with anatomical volume cfg = []; cfg.downsample = 1; cfg.parameter = 'avg.pow'; sourceDiff_int = ft_sourceinterpolate(cfg, grandavg , mri_realign); %Plot MRI cfg = []; cfg.method = 'ortho'; cfg.interactive = 'yes'; cfg.funparameter = 'avg.pow'; figure; ft_sourceplot(cfg, grandavg); - it starts to interpolate over hours and hours... and the results are worng at the end. I tried also this way (this worked with another experiment where we got individual MRI's for each subject): %load GAVG-Results load(['/media/sonja1/Patienten/Parkinson/grandAVG_SourceDiff_OHNEdysphagie__beta.mat']); %Remove the avg.avg field powtemp = grandavg.avg.avg.pow; grandavg = rmfield(grandavg, 'avg'); grandavg.avg.pow = powtemp; %Load an anatomy from the normalized subjects which have been interpolated load(['/media/sonja1/Patienten/Parkinson/P0390/P0390-vol-f.ds/sourceDiffNormalized.mat']); %Plot with anatomy from normalized subject cfg = []; cfg.method = 'ortho'; cfg.interactive = 'yes'; cfg.funparameter = 'avg.pow'; grandavg.anatomy = sourceDiffIntNorm_beta.anatomy; figure; ft_sourceplot(cfg, grandavg); That prints the following error: ??? Attempted to access dim(3); index out of bounds because numel(dim)=2. Error in ==> ft_plot_slice at 207 if all(ori==[0 1 0]), xplane = 1:dim(1); yplane = loc(2); zplane = 1:dim(3); end Error in ==> ft_plot_ortho at 119 hx = ft_plot_slice(dat, varargin{:}); Error in ==> ft_sourceplot at 781 ft_plot_ortho(ana, 'transform', eye(4), 'location', ijk, 'style', 'subplot', 'parents', [h1 h2 h3].*update, 'doscale', false); Error in ==> mw_ft_plot_GrandAVGa at 19 figure; ft_sourceplot(cfg, grandavg); I also upladed the data here: http://www.sendspace.com/file/zkbgqz (GrandAVG result and a normalized LCMV-Beamformer-Result) Does anybody have any suggestions?


Johanna - 2012-07-04 16:11:33 +0200

Hi Martin, I'll take a look at this tomorrow, as I found a similar problem in my own data recently. I will discuss with Jan-Mathijs as needed, as he knows more about this than I do. Johanna


Johanna - 2012-07-06 13:27:35 +0200

Hi Martin and JM, I'm not sure if this is the root of the problem, or just a part...But at least in my data, when I call ft_sourcegrandaverage, I'm giving as input, the source structure from each subject after call to ft_sourceinterpolate and then ft_volumenormalise, so that all subjects are in MNI space. The first thing that ft_sourcegrandaverage does is to convert this 'volume' structure of the data (where it is contained in .avg.pow in a 181x217x181 grid) back to the 'source' structure with .pos and .avg fields indicating locations of the source powers but in a Nx3 and Nx1 array instead. These are very large (i.e. 7million .pos total, of which about 1.5 million are .inside the brain). This large-nish is, I think, then the cause of it running for hours and hours (or in my case out of Memory crash). If you try the call to ft_sourceinterpolate of the grand_avg with a cfg.downsample of something like 10 (rather than 1) you might succeed, but then both the .anatomy and .avg.pow are very spatially blurred. This is all the info I have so far. Alternatively, if the original subjects source output was comptued using the MNI template grid, then the .pos should already be in MNI space and you should be able to call ft_sourcegrandaverage on the subjects 'source' structure (before ft_sourceinterpolate). Jan-Mathijs, any further thoughts at this stage?


Jan-Mathijs Schoffelen - 2012-07-06 15:54:48 +0200

Hi both, My initial question would be: why would you want to call ft_sourceinterpolate for a second time? As far as I understand (at least in Johanna's case) you have already interpolated to a high spatial resolution in the same volumetric representation as the anatomy. So I'd say no need anymore for a second round. As a side remark, I now also think I understand why the avg field becomes nested, i.e. avg.avg.pow, and that's because actually the interpolated volumes are used as input to ft_sourcegrandaverage, a thing which I have actually never considered. @Cornelius (CC) this is related to the problem you recently reported, correct? I would recommend using MNI-space aligned grid, which allow for the averaging and statistics across subjects at a much lower spatial resolution, and only do the interpolation (which in this case becomes only necessary for visualization purposes) at the latest stage.


Johanna - 2012-07-06 16:53:51 +0200

In my case, I was calling ft_sourceinterpolate on the grandavg because it was *too* high spatial resolution, so I was using it with cfg.downsample=10 to get back resolution of 1cm rather than 0.1cm. (to reduce the .inside from around 1 million true values, to something sensible like 10000.). Another option I just realised is, after the call to ft_sourceinterpolate per subject, then when calling ft_volumenormalise, set cfg.downsample=5 (or 10) to get back a spatial resolution of 0.5 (or 1.0) cm, assuming the MRI used for sourceinterpolate was a resolution of 1mm cubic. Then these MNI normalised volumes per subject should be easier to grandaverage....? I agree with JM though, that all this interpolation back and forth is non-ideal.


Johanna - 2012-08-22 15:51:50 +0200

Hi Martin, Sorry for the delay in following up, but have the comments from Jan-Mathijs and myself been helpful enough, that this problem is now solved for you (i.e. by using MNI spaced aligned grid to begin, and only calling ft_volumeinterpolate and ft_volumenormalize for the purpose of visualisation), or do you still want us to look into some aspect further? The data you posted on sendspace.com is no longer available. Best regards, Johanna


Johanna - 2013-01-15 14:11:18 +0100

Closing this, as I feel the issue is resolved, but please re-open if still remaining questions/problems.