<div dir="ltr">Hi there,<div><br></div><div>I apologize. I found a small bug in that script regarding the fieldtrip directory. The revised version is attached.</div><div><br></div><div>Best,</div><div><br></div><div>Tommy</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 24, 2017 at 11:36 AM Tommy Wilson <<a href="mailto:tommy.wilson@med.einstein.yu.edu">tommy.wilson@med.einstein.yu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">Hi Julian,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thank you so much for your reply. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 <a href="https://www.dropbox.com/s/8w99ejwrzmwc5pt/Source_fitting_dump.mat?dl=0" class="gmail_msg" target="_blank">here</a> (that file also includes the raw data stored in variables A and U that I am attempting to source-fit).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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 <a href="http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index" class="gmail_msg" target="_blank">Neural Activity Index</a>) and look at a contrast there, we again see no non-zero values.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">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.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Best,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Tommy Wilson</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">--- CODE ---</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">%% Source fitting protocol</div><div class="gmail_msg">% Fieldtrip path (to find template MRI)</div><div class="gmail_msg">ftdir = 'your\path\here\';</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">% Equate covariance matrices for now to rule out any differences in the</div><div class="gmail_msg">% source fit due to differences in covariances</div><div class="gmail_msg">U.cov = A.cov;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">%%% Do the LCMV sourcefitting</div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">cfg                     = [];</div><div class="gmail_msg">cfg.method              = 'lcmv';</div><div class="gmail_msg">cfg.grid                = leadfield;</div><div class="gmail_msg">cfg.vol                 = vol;</div><div class="gmail_msg">cfg.elec                = elec;</div><div class="gmail_msg">cfg.lcmv.lambda         = '15%';</div><div class="gmail_msg">cfg.lcmv.keepfilter     = 'yes';</div><div class="gmail_msg">cfg.lcmv.fixedori       = 'yes';</div><div class="gmail_msg">cfg.lcmv.projectnoise   = 'yes';</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">sourceA = ft_sourceanalysis(cfg,A);</div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">sourceU = ft_sourceanalysis(cfg,U);</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">%%% Attempt a contrast</div><div class="gmail_msg">% Create the contrast</div><div class="gmail_msg">sourceContrast = sourceA;</div><div class="gmail_msg">sourceContrast.avg.pow = sourceA.avg.pow - sourceU.avg.pow;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">% Check to see if any non-zero values exist in the contrast</div><div class="gmail_msg">if all(sourceContrast.avg.pow(sourceContrast.inside(:)) == 0)</div><div class="gmail_msg">    warning('No non-zero contast values exist. ft_sourceplot will give an error. Do not plot.');</div><div class="gmail_msg">end</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">%%% Instead of a contrast, look at the Neural Activity Index (NAI)</div><div class="gmail_msg">% See: <a href="http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index" class="gmail_msg" target="_blank">http://www.fieldtriptoolbox.org/tutorial/beamformer#neural_activity_index</a></div><div class="gmail_msg">sourceA_NAI = sourceA;</div><div class="gmail_msg">sourceA_NAI.avg.pow = sourceA.avg.pow./sourceA.avg.noise;</div><div class="gmail_msg">sourceU_NAI = sourceU;</div><div class="gmail_msg">sourceU_NAI.avg.pow = sourceU.avg.pow./sourceU.avg.noise;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">if all(sourceA_NAI.avg.pow(sourceA_NAI.inside(:)) - sourceU_NAI.avg.pow(sourceU_NAI.inside(:))==0)</div><div class="gmail_msg">    warning('No non-zero contast values exist. ft_sourceplot will give an error. Do not plot.')</div><div class="gmail_msg">end</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">%%% Visualize the output</div><div class="gmail_msg">% Load template MRI</div><div class="gmail_msg">mri = ft_read_mri([ftdir '\fieldtrip-20160309\template\anatomy\single_subj_T1.nii']);</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">% Interpolate source onto MRI</div><div class="gmail_msg">cfg            = [];</div><div class="gmail_msg">cfg.parameter  = 'avg.pow';</div><div class="gmail_msg">sourceA_interp  = ft_sourceinterpolate(cfg, sourceA, mri);</div><div class="gmail_msg">sourceA_NAI_interp  = ft_sourceinterpolate(cfg, sourceA_NAI, mri);</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">% Visualize with ft_sourceplot</div><div class="gmail_msg">cfg = [];</div><div class="gmail_msg">cfg.method        = 'ortho';</div><div class="gmail_msg">cfg.funparameter  = 'avg.pow';</div><div class="gmail_msg">cfg.funcolorlim   = [0 3e3];</div><div class="gmail_msg">cfg.maskparameter = cfg.funparameter; </div><div class="gmail_msg">ft_sourceplot(cfg, sourceA_interp);</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">cfg = [];</div><div class="gmail_msg">cfg.method        = 'ortho';</div><div class="gmail_msg">cfg.funparameter  = 'avg.pow';</div><div class="gmail_msg">cfg.maskparameter = cfg.funparameter; </div><div class="gmail_msg">ft_sourceplot(cfg, sourceA_NAI_interp);</div></div></div><div dir="ltr" class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Tue, Jan 24, 2017 at 3:42 AM Julian Keil <<a href="mailto:julian.keil@gmail.com" class="gmail_msg" target="_blank">julian.keil@gmail.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Tommy,<br class="gmail_msg">
<br class="gmail_msg">
did you do some sort of contrast (e.g. with the noise estimate or a baseline) after your source analysis?<br class="gmail_msg">
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?<br class="gmail_msg">
It might also be the case that the automatic scaling in the source plot throws you off - maybe try setting it by hand.<br class="gmail_msg">
<br class="gmail_msg">
Good luck,<br class="gmail_msg">
<br class="gmail_msg">
Julian<br class="gmail_msg">
<br class="gmail_msg">
Am 23.01.2017 um 22:00 schrieb Tommy Wilson:<br class="gmail_msg">
<br class="gmail_msg">
> Hi all,<br class="gmail_msg">
><br class="gmail_msg">
> 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.<br class="gmail_msg">
><br class="gmail_msg">
> 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:<br class="gmail_msg">
><br class="gmail_msg">
> cfg                     = [];<br class="gmail_msg">
> cfg.method              = 'lcmv';<br class="gmail_msg">
> cfg.grid                = leadfield;<br class="gmail_msg">
> cfg.vol                 = vol;<br class="gmail_msg">
> cfg.elec                = elec;<br class="gmail_msg">
> cfg.lcmv.lambda         = '15%';<br class="gmail_msg">
> cfg.lcmv.keepfilter     = 'yes';<br class="gmail_msg">
> cfg.lcmv.fixedori       = 'yes';<br class="gmail_msg">
> cfg.lcmv.projectnoise   = 'yes';<br class="gmail_msg">
><br class="gmail_msg">
> sourceA = ft_sourceanalysis(cfg,A);<br class="gmail_msg">
><br class="gmail_msg">
> 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).<br class="gmail_msg">
><br class="gmail_msg">
> 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.<br class="gmail_msg">
><br class="gmail_msg">
> Thanks so much,<br class="gmail_msg">
><br class="gmail_msg">
> Tommy<br class="gmail_msg">
><br class="gmail_msg">
> <Grid.PNG><Electrode localization.PNG><Topo.PNG><Source.PNG>_______________________________________________<br class="gmail_msg">
> fieldtrip mailing list<br class="gmail_msg">
> <a href="mailto:fieldtrip@donders.ru.nl" class="gmail_msg" target="_blank">fieldtrip@donders.ru.nl</a><br class="gmail_msg">
> <a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" class="gmail_msg" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
fieldtrip mailing list<br class="gmail_msg">
<a href="mailto:fieldtrip@donders.ru.nl" class="gmail_msg" target="_blank">fieldtrip@donders.ru.nl</a><br class="gmail_msg">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" class="gmail_msg" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote></div></div></blockquote></div></div>