<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=us-ascii"><meta name=Generator content="Microsoft Word 12 (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:Tahoma;
        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:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@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=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Russ,<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><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I ran into a similar error which was avoided by following the steps in the <u>extended</u> beamformer tutorial (<a href="http://fieldtrip.fcdonders.nl/tutorial/beamformingextended">http://fieldtrip.fcdonders.nl/tutorial/beamformingextended</a>). The problem seems to rather be that ft_sourceinterpolate wrongly detects your functional data as being 2 dimensional (if I remember correctly) because a .dim field is not present. I did not have the time yet to find-out if it is a problem with the other beamformer tutorial or an actual bug.<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><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>In any case, if I compare the steps in the extended beamformer tutorial with the steps you took I noticed that in the extended beamformer tutorial a sourcemodel (ft_prepare_sourcemodel) is calculated after calculating the headmodel, which is then used to calculate the leadfield (ft_prepare_leadfield), followed by using this leadfield in ft_sourceanalysis. Could you try and see if that works? <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><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Best,<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><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Jim<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 style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> fieldtrip-bounces@science.ru.nl [mailto:fieldtrip-bounces@science.ru.nl] <b>On Behalf Of </b>Russell G Port<br><b>Sent:</b> vrijdag 15 maart 2013 0:18<br><b>To:</b> FieldTrip discussion list<br><b>Subject:</b> [FieldTrip] Inner matrix mismatch in source interpolate<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi Fieldtrippers,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>When running ft source interpolate on my CTF MEG data, I get an error where it reaches line 237; tmp    = interpmat*tmp. The error is an inner matrix dimension mismatch. Here interpmat is  a 16777216(256x256x256) x642 matrix, (mri voxels X leaderfield interpolation matrix). tmp is a 1 * 642 matrix of power at the leaderfield coordinates. If this is just matrix math, then I assume the problem is just that the matrix have to be mxn and nxp. Is there any reason I cannot just use tmp=tmp' to make the inner dimensions match?<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Cheers Russ<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><o:p> </o:p></p><div><p class=MsoNormal style='margin-bottom:12.0pt'>---------- Forwarded message ----------<br>From: <b>Russell G Port</b> <<a href="mailto:russgport@gmail.com">russgport@gmail.com</a>><br>Date: Sat, Mar 9, 2013 at 8:38 PM<br>Subject: source interpolate - tmp = interpmat*tmp; inner matrix must agree<br>To: FieldTrip discussion list <<a href="mailto:fieldtrip@science.ru.nl">fieldtrip@science.ru.nl</a>><br><br><br>Hi Fieldtrippers,<br><br>I have a slight issue that I was hoping someone can help with. I have some CTF data, that I was trying to perform DICS beamforming and then source interpolation on. I am trying to beamform to the source of gamma frequency in the right hemisphere, comparing pre and post stimuli.  Heres the basic script:<br><br><b>People can skip the first part of code, I included it as possibly useful information for this plead <br></b><br>%%%%% Data has already been preprocessed and timelocked%%%%%%<br><br>     load('processed_data_500Hz.mat')<br>     load('timelock_data_500Hz.mat')<br><br>%%%% following the beamforming tutorial %%%%%%%<br><br>%%%%%%%%%%%%%split and combine%%%%%%%%%%%%%  <br>     <br>    cfg        = [];                                           <br>    cfg.toilim = baseline;  <br>    cfg.channel=channel<br>    total_bsl   = ft_redefinetrial(cfg, data);<br>      <br>    <br>    cfg        = [];                                           <br>    cfg.toilim = interest;                       <br>    cfg.channel=channel<br>    total_interest   = ft_redefinetrial(cfg, data);<br>    <br>    cfg      = [];<br>    total_cmb = ft_appenddata(cfg, total_bsl, total_interest);<br>     <br>    total_cmb.trialinfo = [zeros(length(total_bsl.trial), 1); ones(length(total_interest.trial), 1)];<br><br><br>    %%%%%%%%%%%%%cross spectrial density for dics and tf for common filter%%%%%%%%%%%%%%<br>    <br>cfg = [];<br>cfg.method    = 'mtmfft';<br>cfg.output    = 'powandcsd';<br>cfg.tapsmofrq = 25;<br>cfg.foilim    = 55;<br>freqPre_total = ft_freqanalysis(cfg, total_bsl);<br><br>cfg = [];<br>cfg.method    = 'mtmfft';<br>cfg.output    = 'powandcsd';<br>cfg.tapsmofrq = 25;<br>cfg.foilim    = 55;<br>freqPost_total = ft_freqanalysis(cfg, total_interest);<br><br>cfg = [];<br>cfg.method    = 'mtmfft';<br>cfg.output    = 'powandcsd';<br>cfg.tapsmofrq = 25;<br>cfg.foilim    = 55;<br>freqALL_total = ft_freqanalysis(cfg, total_cmb);<br><br><br>%%%%%%%%%%%%%%%%%%%%%%%% calc leadfield %%%%%%%%%%%%%%%%%%%%%%%%%%%<br><br>% <br>T=ft_read_mri('R128_V2.mri')<br><br>       cfg.fiducial.nas  = T.hdr.fiducial.mri.nas<br>    cfg.fiducial.lpa  = T.hdr.fiducial.mri.lpa<br>    cfg.fiducial.rpa  = T.hdr.fiducial.mri.rpa<br>    cfg.method         = 'fiducial'<br>    cfg.coordsys       = 'ctf' <br>   <br>    [mri] = ft_volumerealign(cfg, T)<br> <br>cfg          = [];<br>cfg.coordsys = 'ctf'; % the MRI is expressed in the CTF coordinate system, see below<br>segmentedmri = ft_volumesegment(cfg, mri);<br><br>cfg        = [];<br>cfg.method = 'singleshell';<br>hdm        = ft_prepare_headmodel(cfg, segmentedmri);<br><br> vol = ft_convert_units(hdm, 'cm');<br><br>%%%%%%%%%%%%%%%<br><br><br>cfg                 = [];<br>cfg.grad            = freqPost_total.grad;<br>cfg.vol          = vol;<br>cfg.reducerank      = 2;<br>cfg.channel         = 'MR'<br>[grid] = ft_prepare_leadfield(cfg);<br><br><br><br><b>Upto this point everything works. My volume conduction model, grads, and grid looks good when verified visually...<br><br>I then compute the common filter and apply it to the beamforming of each condition</b><br><br><br>%%%%%%%%%%%%%%%%%%%%% computer common filter%%%%%%%%%%%<br><br>cfg              = [];<br>cfg.method       = 'dics';<br>cfg.grad              = freqALL_total.grad;<br>cfg.keeptrials        = 'yes';<br>cfg.frequency    = freqALL_total.freq;<br>cfg.grid         = grid;<br>cfg.vol          = vol;<br>cfg.dics.projectnoise = 'yes';<br>cfg.dics.lambda       = '5%';<br>cfg.dics.keepfilter   = 'yes';<br>cfg.dics.realfilter   = 'yes';<br>cfg.channel         = 'MR'<br>sourceAll = ft_sourceanalysis(cfg, freqALL_total);<br><br>%%%%%%%%%%%%%%%%%% source for bsl + interest %%%%%%%%%%%%%<br><br>cfg.grid.filter = sourceAll.avg.filter;<br>cfg.grid         = grid;<br>sourcePre_con  = ft_sourceanalysis(cfg, freqPre_total );<br>sourcePost_con = ft_sourceanalysis(cfg, freqPost_total);<br><br><br>%%%%%%%%%% Calc difference %%%%%%%%%%%%%%%%%<br><br>sourceDiff = sourcePost_con;<br>sourceDiff.avg.pow = (sourcePost_con.avg.pow - sourcePre_con.avg.pow) ./ sourcePre_con.avg.pow;<br><br><br><br><b>Heres where it falls apart, because I try to source interpolate</b><br><br><br>%%%%%%%%%%%%%%%%%%%%% graph time %%%%%%%%%%%%%%%%%%<br><br>% slicemri = ft_volumereslice([], mri);<br>% % mri = ft_volumereslice([],segmentedmri) %%<b> didnt appear to help with the current problem<br></b><br>cfg            = [];<br>cfg.downsample = 2;<br>cfg.parameter  = 'avg.pow';<br>cfg.coordsys     = 'ctf';<br>cfg.channel         = 'MR'<br>source_diffInt  = ft_sourceinterpolate(cfg, sourceDiff , mri); &&& I also tried segmentedmri, but no difference<br><br>It works until it reachs line 237; tmp    = interpmat*tmp; where there is the matrixs are mismatch (interpmat is  a 16777216(256x256x256) x642 matrix, and tmp is a 1 * 642 matrix. From my basic skills I gather that tmp is sourceDiff.avg.pow (the power difference for each leadfield point). interpmat is the interpolation matrix return by<br><br>interpmat = interp_ungridded(functional.pos <b>(position of the leadfield locations)</b>, pos (mri voxels), 'projmethod', cfg.interpmethod (<b>nearest</b>), 'sphereradius', cfg.sphereradius) (0.<b>05</b>);<br><br>what I get out of this is a 16777216(<b>256x256x256</b> voxels) x642 <b>(leadfield position)</b> matrix<b>. </b>it then undergoes  interpmat(~anatomical.inside(:), :) = 0. My <b>anatomical.inside is all voxels (all of the 256 x 256 x 256 matrix= 1), as a result of the defaults in ft_checkdata</b>.<br><br>When I try to find the minimum value in this matrix I get (via min(interpmat) =  All zero sparse: 1-by-642<br><br>I think what is supposed to happen is that the interpmat is a matrix that relates meg to mri space, and as such then mutlipling with a vector that represents the power in meg space, I can see how that would get points of power in mri space. Though this must be wrong since the math is not allowed.... I cannot see where I went off the beaten track. It seems as if other people have not had this problem. <br><br>Sorry for the bother,<br><br>Russ Port<br><br>Graduate Student @ Upenn<br><br><br>P.S. thanks to anyone who tries to help in advance...<br><br><br><br><br><br><br><br><o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>