<div dir="ltr"><div><div><div><div><div>Senor Schoffelen,<br><br></div>C'est vrai! But what to do? I've been trying ft_source2full, but that doesn't do the trick. In other words, I'm back to where I started when I cried my first cry for help (to the FT mailinglist, not birth).<br><br></div></div>Should I try to reshape the data to a regular grid? But can't FT do that somewhere brilliantly without my interference?<br><br></div>Merci,<br></div>Stephen<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 26 June 2017 at 14:45, Schoffelen, J.M. (Jan Mathijs) <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word">
Monsieur Stephen!
<div><br>
</div>
<div>I would expect that prod(stat.dim), which is on the order of 5780 is equal to the number of positions. This is clearly not the case. It could be that this confuses ft_sourceinterpolate.</div>
<div>Best,</div>
<div>JM</div><div><div class="h5">
<div><br>
</div>
<div><br>
<div>
<blockquote type="cite">
<div>On 26 Jun 2017, at 13:42, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="m_71185502113561675Apple-interchange-newline">
<div>
<div dir="ltr">
<div>Hi again Mathijs :-)<br>
<br>
</div>
<div>The problem seems to be shifted toward the next step: I now want to visualize the stats on an anatomical image (the same template on which the subject inverse headmodels were based). For this I need to interpolate, but that breals. The following
 datasets go into ft_sourceinterpolate:<br>
<span style="font-family:monospace,monospace"><br>
stat = <br>
<br>
  struct with fields:<br>
<br>
                   prob: [2982×1 double]<br>
            posclusters: [1×3 struct]<br>
    posclusterslabelmat: [2982×1 double]<br>
        posdistribution: [1×1000 double]<br>
            negclusters: [1×4 struct]<br>
    negclusterslabelmat: [2982×1 double]<br>
        negdistribution: [1×1000 double]<br>
                cirange: [2982×1 double]<br>
                   mask: [2982×1 logical]<br>
                   stat: [2982×1 double]<br>
                    ref: [2982×1 double]<br>
                 dimord: 'pos'<br>
                    dim: [17 20 17]<br>
                   freq: 10.5000<br>
                    pos: [2982×3 double]<br>
                    cfg: [1×1 struct]<br>
<br>
</span></div>
<div><span style="font-family:arial,helvetica,sans-serif">and:</span><span style="font-family:monospace,monospace"><br>
<br>
<br>
template_mri = <br>
<br>
  struct with fields:<br>
<br>
          dim: [91 109 91]<br>
      anatomy: [91×109×91 double]<br>
          hdr: [1×1 struct]<br>
    transform: [4×4 double]<br>
         unit: 'mm'<br>
     coordsys: 'spm'<br>
       inside: [91×109×91 logical]<br>
<br>
</span></div>
<div><span style="font-family:arial,helvetica,sans-serif">Now, if I run the following:<br>
<br>
<span style="font-family:monospace,monospace">cfg            = [];<br>
cfg.parameter  = 'stat';<br>
stat_int       = ft_sourceinterpolate(cfg, stat, template_mri);</span><br>
</span></div>
<div><br>
</div>
<div>I get the following error:<br>
<span style="font-family:monospace,monospace"><br>
<span style="color:rgb(255,153,0)">Warning: could not reshape stat to the expected dimensions<br>
> In ft_datatype_volume (line 136)<br>
  In ft_checkdata (line 351)<br>
  In ft_sourceinterpolate (line 170)</span><br>
selecting subvolume of 0.0%<br>
reslicing and interpolating stat<br>
interpolating<br>
<span style="color:rgb(255,0,0)">Error using interpn (line 153)<br>
Wrong number of input arguments.<br>
<br>
Error in ft_sourceinterpolate>my_<wbr>interpn (line 693)<br>
  av(sel) = interpn(fv, ax(sel), ay(sel), az(sel), interpmethod);<br>
<br>
Error in ft_sourceinterpolate (line 595)<br>
          av( sel) = my_interpn(fv, ax(sel), ay(sel), az(sel), cfg.interpmethod, cfg.feedback);<br>
 </span><br>
153         error(message('MATLAB:interpn:<wbr>nargin'));<br>
<br>
</span></div>
<div>Now, I did try to add a .statdimord field, but that didn't make a difference.<br>
</div>
<div>Any idea?<br>
<br>
</div>
<div>Thanks,<br>
</div>
<div>Stephen<br>
<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 26 June 2017 at 13:09, Stephen Whitmarsh <span dir="ltr">
<<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div>
<div>
<div>Hi Jan-Mathijs,<br>
<br>
</div>
Indeed, adding a .dim field did it!<br>
<br>
</div>
Thanks again,<br>
</div>
Stephen<br>
</div>
<div class="m_71185502113561675HOEnZb">
<div class="m_71185502113561675h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 24 June 2017 at 09:30, Schoffelen, J.M. (Jan Mathijs)
<span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi Stephen,
<div><br>
</div>
<div>The error suggests that Fieldtrip does not manage to guess whether the set of dipole positions are defined on a regular grid, or whether it’s on a 2D mesh. Your source structure either needs a ‘dim’ field (if indeed the positions describe a full
 3D grid in an ordered way), or it needs a ‘tri’, defining the edges between the nodes.</div>
<div><br>
</div>
<div>Best,</div>
<div>JM</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap:break-word">J.M.Schoffelen, MD PhD<br>
Senior Researcher, VIDI-fellow - PI, language in interaction<br>
Telephone: <a href="tel:+31%2024%20361%204793" value="+31243614793" target="_blank">
+31-24-3614793</a></div>
<div style="word-wrap:break-word">Physical location: room 00.028</div>
<div style="word-wrap:break-word">Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands<br>
<br>
</div>
<div>
<div class="m_71185502113561675m_-1595869056777638227h5">
<div>
<blockquote type="cite">
<div>On 23 Jun 2017, at 16:28, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="m_71185502113561675m_-1595869056777638227m_-4725666021363548075Apple-interchange-newline">
<div>
<div dir="ltr">
<div>
<div>Dear Jan-Mathijs,<br>
<br>
</div>
Thanks, I've been away but back on it now. <br>
I've been going over it again, and while plotting works fine (after sourceinterpolate), sourcestatistics still throws the same error. Just to be clear - i am using/creating current source-level datastructures and without complicating things, I end up with the
 following data structures that go into sourceanalysis.<br>
<br>
<span style="font-family:monospace,monospace">         pos: [2982×3 double]<br>
        freq: 10.5000<br>
         cfg: [1×1 struct]<br>
          MI: [2982×1 double]<br>
      inside: [2982×1 logical]<br>
    MIdimord: 'pos'<br>
</span><br>
</div>
The error I keep getting is:<br>
<div><span style="font-family:monospace,monospace"><br>
Error using spm_bwlabel<br>
spm_bwlabel: CONN must be 6, 18 or 26<br>
<br>
Error in clusterstat (line 222)<br>
      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);<br>
<br>
Error in ft_statistics_montecarlo (line 347)<br>
  [stat, cfg] = clusterstat(cfg, statrand, statobs);<br>
<br>
Error in ft_sourcestatistics (line 205)<br>
  [stat, cfg] = statmethod(cfg, dat, design);</span><br>
<br>
</div>
<div>It's a mystery what might be wrong. Would you have any further leads?<br>
<br>
</div>
<div>Thanks again,<br>
</div>
<div>Stephen<br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 18 May 2017 at 21:35, Schoffelen, J.M. (Jan Mathijs) <span dir="ltr">
<<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hi Stephen,
<div><br>
</div>
<div>source2full and source2sparse are probably quite outdated, and do not seem to work well anymore with the latest type of source-level data structures. Most relevantly, the inside field these days is by default a boolean vector of size nposx1, whereas
 once upon a time the inside and outside fields together contained the indices of the dipole positions, indicating which positions are on the in-/outside.</div>
<div><br>
</div>
<div>Do you need the source2sparse step to begin with?</div>
<div><br>
</div>
<div>Best,</div>
<div>JM</div>
<div><br>
</div>
<div>
<div>
<div><br>
</div>
<div><br>
<blockquote type="cite">
<div>
<div class="m_71185502113561675m_-1595869056777638227m_-4725666021363548075h5">
<div>On 17 May 2017, at 16:46, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="m_71185502113561675m_-1595869056777638227m_-4725666021363548075m_-2370281886775714604Apple-interchange-newline">
</div>
</div>
<div>
<div>
<div class="m_71185502113561675m_-1595869056777638227m_-4725666021363548075h5">
<div dir="ltr">
<div>Hi there,<br>
<br>
<br>
</div>
After beamformer sourceanalysis I end up with datastructures looking like:<br>
<span style="font-family:monospace,monospace"><br>
</span>
<div><span style="font-family:monospace,monospace">  struct with fields:<br>
<br>
         freq: 10.5000<br>
          cfg: [1×1 struct]<br>
          pos: [2982×3 double]<br>
          pow: [2982×1 double]<br>
       inside: [2982×1 logical]<br>
    powdimord: 'pos'<br>
</span><br>
</div>
<div>The .inside field is created by ft_selectdata used to average across frequencies, and contains all 1s. Running sourceanalysis with this data trows the following error:<br>
<br>
</div>
<div><span style="color:rgb(255,0,0)"><br>
</span><span style="font-family:monospace,monospace"><span style="color:rgb(255,0,0)">Error using spm_bwlabel<br>
spm_bwlabel: CONN must be 6, 18 or 26</span><br>
<br>
<span style="color:rgb(255,0,0)">Error in clusterstat (line 222)<br>
      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);<br>
<br>
Error in ft_statistics_montecarlo (line 347)<br>
  [stat, cfg] = clusterstat(cfg, statrand, statobs);<br>
<br>
Error in ft_sourcestatistics (line 205)<br>
  [stat, cfg] = statmethod(cfg, dat, design);</span><br>
 <br>
<span style="color:rgb(0,0,255)"><u>222 </u></span>      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);</span><br>
<br>
<br>
</div>
<div>I think this results because of a wrong estimate of the dimensionality, resulting from the fact that the data is represented in an array rather than a 3-dimensional matrix, which it seems to expect.
<br>
<br>
I think therefor that I might need to convert my data back into a 3-d representation, i..e not a sparse but full representation. I have tried using ft_source2full, but that is not straightforward as I only have inside voxels/positions. In other words, I would
 need to do exactly the same as ft_source_statistics seems to want to do with spm_bwlabel.<br>
<br>
</div>
<div>So I guess I might just have put FieldTrip on the wrong leg, to use a Dutch expression.<br>
<br>
</div>
<div>Any suggestions?<br>
<br>
</div>
<div>Best,<br>
</div>
<div>Stephen<br>
</div>
<div><br>
<br>
</div>
</div>
</div>
</div>
______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
</div>
______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
<br>
<br>
<div>
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<br>
</div>
</div>
</div>
</div>
<br>
</div>
<br>
______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br>
</div>
</div></div></div>

<br>______________________________<wbr>_________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank">https://mailman.science.ru.nl/<wbr>mailman/listinfo/fieldtrip</a><br></blockquote></div><br></div>