[FieldTrip] Source fitting with template MRI/Headmodel
Tommy Wilson
tommy.wilson at med.einstein.yu.edu
Tue Jan 24 17:55:56 CET 2017
Hi there,
I apologize. I found a small bug in that script regarding the
fieldtrip directory. The revised version is attached.
Best,
Tommy
On Tue, Jan 24, 2017 at 11:36 AM Tommy Wilson <
tommy.wilson at med.einstein.yu.edu> wrote:
> Hi Julian,
>
> Thank you so much for your reply.
>
> I've pasted the commented code below (I apologize for the code dump). I've
> also attached an m-file to this email if you'd prefer to download it that
> way. If relevant, you can download the leadfield, headmodel and electrode
> locations here
> <https://www.dropbox.com/s/8w99ejwrzmwc5pt/Source_fitting_dump.mat?dl=0>
> (that file also includes the raw data stored in variables A and U that I am
> attempting to source-fit).
>
> As per your questions: I do indeed have a contrast between attended (A)
> and unattended (U) conditions. I've written the code below to source-fit
> both conditions and create the contrast. However, despite that the raw
> topographies (see attached images) are different, the source-fits are the
> same (...?). As a consequence, the contrast has no non-zero values. If
> instead, I normalize to noise (i.e. generate the Neural Activity Index
> <http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index>)
> and look at a contrast there, we again see no non-zero values.
>
> Outside of the contrast, I've implemented your other suggestions. I've
> rescaled the original ft_sourceplot such that you can see the extent of it
> (see attached image). To my mind, it shouldn't look like this, but having
> never done this before, I'm not quite sure what to expect. I've also
> included an image of the ft_sourceplot for the Neural Activity Index of
> sourceA which also appears to me to be artefactual. More to the point, I'd
> expect that since the topographies for A and U are different, the NAIs
> should be different, which is not the case.
>
> I'm sort of at a loss about how to proceed here. So, thank you very much
> for taking the time to look into this. If I can supply anything else to
> help, please don't hesitate to let me know.
>
> Best,
>
> Tommy Wilson
>
> --- CODE ---
>
> %% Source fitting protocol
> % Fieldtrip path (to find template MRI)
> ftdir = 'your\path\here\';
>
> % Equate covariance matrices for now to rule out any differences in the
> % source fit due to differences in covariances
> U.cov = A.cov;
>
> %%% Do the LCMV sourcefitting
> cfg = [];
> cfg.method = 'lcmv';
> cfg.grid = leadfield;
> cfg.vol = vol;
> cfg.elec = elec;
> cfg.lcmv.lambda = '15%';
> cfg.lcmv.keepfilter = 'yes';
> cfg.lcmv.fixedori = 'yes';
> cfg.lcmv.projectnoise = 'yes';
>
> sourceA = ft_sourceanalysis(cfg,A);
> sourceU = ft_sourceanalysis(cfg,U);
>
>
> %%% Attempt a contrast
> % Create the contrast
> sourceContrast = sourceA;
> sourceContrast.avg.pow = sourceA.avg.pow - sourceU.avg.pow;
>
> % Check to see if any non-zero values exist in the contrast
> if all(sourceContrast.avg.pow(sourceContrast.inside(:)) == 0)
> warning('No non-zero contast values exist. ft_sourceplot will give an
> error. Do not plot.');
> end
>
>
> %%% Instead of a contrast, look at the Neural Activity Index (NAI)
> % See:
> http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index
> sourceA_NAI = sourceA;
> sourceA_NAI.avg.pow = sourceA.avg.pow./sourceA.avg.noise;
> sourceU_NAI = sourceU;
> sourceU_NAI.avg.pow = sourceU.avg.pow./sourceU.avg.noise;
>
> if all(sourceA_NAI.avg.pow(sourceA_NAI.inside(:)) -
> sourceU_NAI.avg.pow(sourceU_NAI.inside(:))==0)
> warning('No non-zero contast values exist. ft_sourceplot will give an
> error. Do not plot.')
> end
>
>
> %%% Visualize the output
> % Load template MRI
> mri = ft_read_mri([ftdir
> '\fieldtrip-20160309\template\anatomy\single_subj_T1.nii']);
>
> % Interpolate source onto MRI
> cfg = [];
> cfg.parameter = 'avg.pow';
> sourceA_interp = ft_sourceinterpolate(cfg, sourceA, mri);
> sourceA_NAI_interp = ft_sourceinterpolate(cfg, sourceA_NAI, mri);
>
> % Visualize with ft_sourceplot
> cfg = [];
> cfg.method = 'ortho';
> cfg.funparameter = 'avg.pow';
> cfg.funcolorlim = [0 3e3];
> cfg.maskparameter = cfg.funparameter;
> ft_sourceplot(cfg, sourceA_interp);
>
> cfg = [];
> cfg.method = 'ortho';
> cfg.funparameter = 'avg.pow';
> cfg.maskparameter = cfg.funparameter;
> ft_sourceplot(cfg, sourceA_NAI_interp);
>
> On Tue, Jan 24, 2017 at 3:42 AM Julian Keil <julian.keil at gmail.com> wrote:
>
> Hi Tommy,
>
> did you do some sort of contrast (e.g. with the noise estimate or a
> baseline) after your source analysis?
> Right now, it's not clear what you are looking at. Could you paste your
> code not only of the sourceanalysis, but the rest after which got you to
> the plot?
> It might also be the case that the automatic scaling in the source plot
> throws you off - maybe try setting it by hand.
>
> Good luck,
>
> Julian
>
> Am 23.01.2017 um 22:00 schrieb Tommy Wilson:
>
> > Hi all,
> >
> > I'm working with EEG data and I'm trying to get some basic source
> fitting up and running. Unfortunately, I don't have individual subject
> MRIs, so I'm using the templates provided by fieldtrip. I've co-registered
> my 160 Biosemi electrodes to the standard_bem template (see attached
> picture). For the sourcemodel, I'm using the standard_sourcemodel3d5mm grid
> (picture attached, overlaid on standard_bem). I can prepare the leadfield
> from there with ft_prepare_leadfield (cfg.normalize = 'yes'), as per the
> LCMV tutorial.
> >
> > To test this configuration, I've selected a time window in my data and
> averaged across it (the covariance matrix was also calculated); the
> topography of this averaged data is attached. I then attempted a source fit
> with the LCMV beamformer:
> >
> > cfg = [];
> > cfg.method = 'lcmv';
> > cfg.grid = leadfield;
> > cfg.vol = vol;
> > cfg.elec = elec;
> > cfg.lcmv.lambda = '15%';
> > cfg.lcmv.keepfilter = 'yes';
> > cfg.lcmv.fixedori = 'yes';
> > cfg.lcmv.projectnoise = 'yes';
> >
> > sourceA = ft_sourceanalysis(cfg,A);
> >
> > After interpolating to the single_subj_T1.nii provided with
> ft_sourceinterpolate and plotting with ft_sourceplot, I am given a
> sourceplot that is highly focal in nature (see attached picture).
> >
> > I'd find it very surprising if this topography were generated primarily
> by a source that isn't even inside the brain (as the sourceplot indicates).
> So, I'm not sure exactly where/how I'm going wrong with this one, nor am I
> sure how to trouble shoot it. Any guidance you might provide would be
> greatly appreciated.
> >
> > Thanks so much,
> >
> > Tommy
> >
> > <Grid.PNG><Electrode
> localization.PNG><Topo.PNG><Source.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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20170124/0e54d65c/attachment-0002.html>
-------------- next part --------------
%% Source fitting protocol
% Fieldtrip path (to find template MRI)
ftdir = 'your\path\here\fieldtrip-20160309';
% Equate covariance matrices for now to rule out any differences in the
% source fit due to differences in covariances
U.cov = A.cov;
%%% Do the LCMV sourcefitting
cfg = [];
cfg.method = 'lcmv';
cfg.grid = leadfield;
cfg.vol = vol;
cfg.elec = elec;
cfg.lcmv.lambda = '15%';
cfg.lcmv.keepfilter = 'yes';
cfg.lcmv.fixedori = 'yes';
cfg.lcmv.projectnoise = 'yes';
sourceA = ft_sourceanalysis(cfg,A);
sourceU = ft_sourceanalysis(cfg,U);
%%% Attempt a contrast
% Create the contrast
sourceContrast = sourceA;
sourceContrast.avg.pow = sourceA.avg.pow - sourceU.avg.pow;
% Check to see if any non-zero values exist in the contrast
if all(sourceContrast.avg.pow(sourceContrast.inside(:)) == 0)
warning('No non-zero contast values exist. ft_sourceplot will give an error. Do not plot.');
end
%%% Instead of a contrast, look at the Neural Activity Index (NAI)
% See: http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index
sourceA_NAI = sourceA;
sourceA_NAI.avg.pow = sourceA.avg.pow./sourceA.avg.noise;
sourceU_NAI = sourceU;
sourceU_NAI.avg.pow = sourceU.avg.pow./sourceU.avg.noise;
if all(sourceA_NAI.avg.pow(sourceA_NAI.inside(:)) - sourceU_NAI.avg.pow(sourceU_NAI.inside(:))==0)
warning('No non-zero contast values exist. ft_sourceplot will give an error. Do not plot.')
end
%%% Visualize the output
% Load template MRI
mri = ft_read_mri([ftdir '\template\anatomy\single_subj_T1.nii']);
% Interpolate source onto MRI
cfg = [];
cfg.parameter = 'avg.pow';
sourceA_interp = ft_sourceinterpolate(cfg, sourceA, mri);
sourceA_NAI_interp = ft_sourceinterpolate(cfg, sourceA_NAI, mri);
% Visualize with ft_sourceplot
cfg = [];
cfg.method = 'ortho';
cfg.funparameter = 'avg.pow';
cfg.funcolorlim = [0 3e3];
cfg.maskparameter = cfg.funparameter;
ft_sourceplot(cfg, sourceA_interp);
cfg = [];
cfg.method = 'ortho';
cfg.funparameter = 'avg.pow';
cfg.maskparameter = cfg.funparameter;
ft_sourceplot(cfg, sourceA_NAI_interp);
More information about the fieldtrip
mailing list