<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>whoopsy, saw your code just now - so I take that back ;) <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264;mso-fareast-language:NL'>--<o:p></o:p></span></b></p><p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255A9E;mso-fareast-language:NL'><o:p> </o:p></span></b></p><p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255A9E;mso-fareast-language:NL'>Jörn M. Horschig, PhD</span></b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264;mso-fareast-language:NL'>, Software Engineer</span><b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:black;mso-fareast-language:NL'><o:p></o:p></span></b></p><p class=MsoNormal><span lang=NL style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264;mso-fareast-language:NL'><a href="http://www.artinis.com/"><span lang=EN-US style='color:#626264'>Artinis Medical Systems</span></a></span><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#626264;mso-fareast-language:NL'> | +31 481 350 980 </span><b><span style='font-size:9.0pt;font-family:"Verdana",sans-serif;color:#255A9E;mso-fareast-language:NL'><o:p></o:p></span></b></p></div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> fieldtrip-bounces@science.ru.nl [mailto:fieldtrip-bounces@science.ru.nl] <b>On Behalf Of </b>Stephen Whitmarsh<br><b>Sent:</b> Friday, July 17, 2015 12:04 AM<br><b>To:</b> fieldtrip, donders<br><b>Subject:</b> [FieldTrip] Advice on using LCMV beamformer<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><div><div><div><div><div><p class=MsoNormal style='margin-bottom:12.0pt'>Hi everyone,<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>I hope there is someone out there who has some time to help me with using LCMV beamformer. I have no experience with it yet, although a little with DICS, and understand they are at least conceptually very similar. However, I am running into some questions. Before I go on, my data on sensor level looks good and it works out with dipolefitting as well (attached).<o:p></o:p></p></div><p class=MsoNormal>I would like to beamform an early (unilaterally stimulated) sensory evoked field. There is no conditional difference, I would just like to extract the timecourse of some maximum voxels. In other words:<o:p></o:p></p></div><p class=MsoNormal>1) get a contralateral cluster or a number of voxels with maximum amplitude.<o:p></o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>2) extract the timecourses of those clusters, then average them.<o:p></o:p></p></div><p class=MsoNormal>For step 1, it seem to have several options, either:<o:p></o:p></p></div><p class=MsoNormal>1a) calculate the filter on the whole timecourse (a common filter as would be used in DICS)<o:p></o:p></p><div><div><p class=MsoNormal>1b) use that common filter to calculate the amplitude of the early component<o:p></o:p></p></div><div><p class=MsoNormal>1c) do the same for the baseline period<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>1d) subtract the baseline activation from the active period (or take a ratio)<o:p></o:p></p></div><div><p class=MsoNormal>Alternatively, I could:<o:p></o:p></p></div><div><p class=MsoNormal>2a) beamform the active period<o:p></o:p></p></div><div><p class=MsoNormal>2b) beamform the baseline period<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>2c) subtract the baseline activation from the active period (or take a ratio)<o:p></o:p></p></div><div><p class=MsoNormal>Or it seems, I might even:<o:p></o:p></p></div><div><p class=MsoNormal>3a) beamform the active period<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>3b) divide the active period by the projected noise<o:p></o:p></p></div><div><p class=MsoNormal>Do I get this correctly? Does anyone have an argument for one of these option?<br><br>Anyway, first practical problem is that when I plot either the whole, the baseline or the activation period I get the same results (attached). A difference therefore doesn't work, obviously. So this raises the question how the selection of latency works in ft_sourceanalysis? I trust cfg.latency works, but it doesn't seem to make a difference for me. At the same time, using selectdata to select a time period doesn't make a difference either. I'm obviously doing something wrong, but what?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal style='margin-bottom:12.0pt'>Anyway, when I get this figured out, I still need to extract the timecourses. How would I proceed doing this? I imagine the fastest way would not be to loop ft_sourceanalysis for each timepoint (using a common filter I would think). Should I 'manually' multiply the data with the filter?<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'>It would be great to have some feedback on the general idea, and perhaps someone can identify what I am doing wrong (script below). I would be happy to finish the LCMV beamformer tutorial on the FT website once I get it figured out, as I can imagine more people would have these questions.<o:p></o:p></p></div><div><p class=MsoNormal>All the best and thanks,<o:p></o:p></p></div><div><p class=MsoNormal>Stephen<br><span style='font-size:7.5pt;font-family:"Courier New"'><br><br>% timelock average + covariance<br><br>cfg = [];<br>cfg.covariance = 'yes';<br>cfg.covariancewindow = 'all';<br>cfg.trials = find(clean_data.trialinfo(:,2) == 1);<br>ERF_single{isubject} = ft_timelockanalysis(cfg,clean_data);<br>cfg.trials = find(clean_data.trialinfo(:,2) == 2);<br>ERF_double{isubject} = ft_timelockanalysis(cfg,clean_data);<br><br>% combine gradiometers (single stim)<br>cfg = [];<br>ERF_single_cmb{isubject} = ft_combineplanar(cfg,ERF_single{isubject});<br>ERF_double_cmb{isubject} = ft_combineplanar(cfg,ERF_double{isubject});<br><br>% load headmodel MEG<br>temp = load(['/home/stephen/analysis/metacognition/sourcemodel/pp_' num2str(isubject) '_headmodel_singleshell.mat']);<br>headmodel_meg{isubject} = temp.headmodel_meg;<br><br>% headmodel_meg = ft_convert_units(headmodel_meg, 'cm');<br>gridtemp = load(['/home/stephen/analysis/metacognition/sourcemodel/pp_' num2str(isubject) '_grid.mat']);<br><br>hdr = ft_read_header(flist{1});<br>cfg = [];<br>cfg.grad = hdr.grad;<br>cfg.vol = headmodel_meg{isubject};<br>cfg.grid = gridtemp.grid;<br>cfg.channel = {'MEGGRAD'};<br>cfg.normalize = 'yes';<br>leadfield = ft_prepare_leadfield(cfg);<br><br>% get the filter<br>cfg = [];<br>cfg.method = 'lcmv';<br>cfg.grid = leadfield;<br>cfg.vol = headmodel_meg{isubject};<br>cfg.keepfilter = 'yes';<br>cfg.senstype = 'meg';<br>cfg.channel = 'meggrad';<br>cfg.lcmv.fixedori = 'yes'; % use only right gradiometers<br>cfg.reducerank = 2;<br>source_lcmv_single{isubject} = ft_sourceanalysis(cfg, ERF_single{isubject});<br>source_lcmv_double{isubject} = ft_sourceanalysis(cfg, ERF_double{isubject});<br><br>% project post stim latency with previous common filter<br><br>cfg = [];<br>cfg.latency = latency;<br>ERF_single_latency{isubject} = ft_selectdata(cfg,ERF_single{isubject});<br><br>cfg = [];<br>cfg.method = 'lcmv';<br>cfg.grid = leadfield;<br>cfg.vol = headmodel_meg{isubject};<br>cfg.grid.filter = source_lcmv_single{isubject}.avg.filter;<br>cfg.channel = 'meggrad';<br>cfg.senstype = 'meg';<br>% cfg.latency = latency;<br>cfg.lcmv.fixedori = 'yes'; <br>cfg.reducerank = 2;<br>source_lcmv_single_latency{isubject} = ft_sourceanalysis(cfg, ERF_single_latency{isubject});<br><br>% baseline<br><br>cfg = [];<br>cfg.latency = [-0.2 0];<br>ERF_single_baseline{isubject} = ft_selectdata(cfg,ERF_single{isubject});<br><br>cfg = [];<br>cfg.method = 'lcmv';<br>cfg.grid = leadfield;<br>cfg.vol = headmodel_meg{isubject};<br>cfg.grid.filter = source_lcmv_single{isubject}.avg.filter;<br>cfg.channel = 'meggrad';<br>cfg.senstype = 'meg';<br>% cfg.latency = latency;<br>cfg.lcmv.fixedori = 'yes'; <br>cfg.reducerank = 2;<br>source_lcmv_single_baseline{isubject} = ft_sourceanalysis(cfg, ERF_single_baseline{isubject});<br><br>% get difference between baseline and component<br>source_lcmv_single_diff{isubject} = source_lcmv_single_latency{isubject};<br>source_lcmv_single_diff{isubject}.avg.pow = source_lcmv_single_latency{isubject}.avg.pow - source_lcmv_single_baseline{isubject}.avg.pow;<br><br>template_mri = ft_read_mri(['/opt/fieldtrip/external/spm8/templates/T1.nii']);<br><br>cfg = [];<br>cfg.voxelcoord = 'no';<br>cfg.parameter = 'avg.pow';<br>cfg.interpmethod = 'nearest';<br>source_lcmv_single_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single{isubject}, template_mri);<br>source_lcmv_single_latency_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single_latency{isubject}, template_mri);<br>source_lcmv_single_diff_int{isubject} = ft_sourceinterpolate(cfg, source_lcmv_single_diff{isubject}, template_mri);<br><br>cfg = [];<br>cfg.method = 'slice';<br>cfg.funparameter = 'avg.pow';<br>cfg.maskparameter = cfg.funparameter;<br>cfg.funcolorlim = [3e-22 5e-22];<br>% ft_sourceplot(cfg,source_lcmv_single_latency_int{isubject});<br>% ft_sourceplot(cfg,source_lcmv_single_int{isubject});<br>ft_sourceplot(cfg,source_lcmv_single_latency_int{isubject});<br><br>cfg = [];<br>cfg.method = 'slice';<br>cfg.funparameter = 'pow';<br>cfg.funcolorlim = [-1e-23 1e-23];<br>ft_sourceplot(cfg,source_lcmv_single_diff_int{isubject});</span><span style='font-size:7.5pt'><br> </span><o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p></div><div><div><p class=MsoNormal><o:p> </o:p></p></div></div></div></div></div></body></html>