<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Monsieur Stephen!
<div class=""><br class="">
</div>
<div class="">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 class="">Best,</div>
<div class="">JM</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 26 Jun 2017, at 13:42, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" class="">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">Hi again Mathijs :-)<br class="">
<br class="">
</div>
<div class="">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 class="">
<span style="font-family:monospace,monospace" class=""><br class="">
stat = <br class="">
<br class="">
  struct with fields:<br class="">
<br class="">
                   prob: [2982×1 double]<br class="">
            posclusters: [1×3 struct]<br class="">
    posclusterslabelmat: [2982×1 double]<br class="">
        posdistribution: [1×1000 double]<br class="">
            negclusters: [1×4 struct]<br class="">
    negclusterslabelmat: [2982×1 double]<br class="">
        negdistribution: [1×1000 double]<br class="">
                cirange: [2982×1 double]<br class="">
                   mask: [2982×1 logical]<br class="">
                   stat: [2982×1 double]<br class="">
                    ref: [2982×1 double]<br class="">
                 dimord: 'pos'<br class="">
                    dim: [17 20 17]<br class="">
                   freq: 10.5000<br class="">
                    pos: [2982×3 double]<br class="">
                    cfg: [1×1 struct]<br class="">
<br class="">
</span></div>
<div class=""><span style="font-family:arial,helvetica,sans-serif" class="">and:</span><span style="font-family:monospace,monospace" class=""><br class="">
<br class="">
<br class="">
template_mri = <br class="">
<br class="">
  struct with fields:<br class="">
<br class="">
          dim: [91 109 91]<br class="">
      anatomy: [91×109×91 double]<br class="">
          hdr: [1×1 struct]<br class="">
    transform: [4×4 double]<br class="">
         unit: 'mm'<br class="">
     coordsys: 'spm'<br class="">
       inside: [91×109×91 logical]<br class="">
<br class="">
</span></div>
<div class=""><span style="font-family:arial,helvetica,sans-serif" class="">Now, if I run the following:<br class="">
<br class="">
<span style="font-family:monospace,monospace" class="">cfg            = [];<br class="">
cfg.parameter  = 'stat';<br class="">
stat_int       = ft_sourceinterpolate(cfg, stat, template_mri);</span><br class="">
</span></div>
<div class=""><br class="">
</div>
<div class="">I get the following error:<br class="">
<span style="font-family:monospace,monospace" class=""><br class="">
<span style="color:rgb(255,153,0)" class="">Warning: could not reshape stat to the expected dimensions<br class="">
> In ft_datatype_volume (line 136)<br class="">
  In ft_checkdata (line 351)<br class="">
  In ft_sourceinterpolate (line 170)</span><br class="">
selecting subvolume of 0.0%<br class="">
reslicing and interpolating stat<br class="">
interpolating<br class="">
<span style="color:rgb(255,0,0)" class="">Error using interpn (line 153)<br class="">
Wrong number of input arguments.<br class="">
<br class="">
Error in ft_sourceinterpolate>my_interpn (line 693)<br class="">
  av(sel) = interpn(fv, ax(sel), ay(sel), az(sel), interpmethod);<br class="">
<br class="">
Error in ft_sourceinterpolate (line 595)<br class="">
          av( sel) = my_interpn(fv, ax(sel), ay(sel), az(sel), cfg.interpmethod, cfg.feedback);<br class="">
 </span><br class="">
153         error(message('MATLAB:interpn:nargin'));<br class="">
<br class="">
</span></div>
<div class="">Now, I did try to add a .statdimord field, but that didn't make a difference.<br class="">
</div>
<div class="">Any idea?<br class="">
<br class="">
</div>
<div class="">Thanks,<br class="">
</div>
<div class="">Stephen<br class="">
<br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On 26 June 2017 at 13:09, Stephen Whitmarsh <span dir="ltr" class="">
<<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank" class="">stephen.whitmarsh@gmail.com</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class="">Hi Jan-Mathijs,<br class="">
<br class="">
</div>
Indeed, adding a .dim field did it!<br class="">
<br class="">
</div>
Thanks again,<br class="">
</div>
Stephen<br class="">
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On 24 June 2017 at 09:30, Schoffelen, J.M. (Jan Mathijs)
<span dir="ltr" class=""><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank" class="">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word" class="">Hi Stephen,
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">JM</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="word-wrap:break-word" class="">J.M.Schoffelen, MD PhD<br class="">
Senior Researcher, VIDI-fellow - PI, language in interaction<br class="">
Telephone: <a href="tel:+31%2024%20361%204793" value="+31243614793" target="_blank" class="">
+31-24-3614793</a></div>
<div style="word-wrap:break-word" class="">Physical location: room 00.028</div>
<div style="word-wrap:break-word" class="">Donders Centre for Cognitive Neuroimaging, Nijmegen, The Netherlands<br class="">
<br class="">
</div>
<div class="">
<div class="m_-1595869056777638227h5">
<div class="">
<blockquote type="cite" class="">
<div class="">On 23 Jun 2017, at 16:28, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank" class="">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="m_-1595869056777638227m_-4725666021363548075Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">Dear Jan-Mathijs,<br class="">
<br class="">
</div>
Thanks, I've been away but back on it now. <br class="">
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 class="">
<br class="">
<span style="font-family:monospace,monospace" class="">         pos: [2982×3 double]<br class="">
        freq: 10.5000<br class="">
         cfg: [1×1 struct]<br class="">
          MI: [2982×1 double]<br class="">
      inside: [2982×1 logical]<br class="">
    MIdimord: 'pos'<br class="">
</span><br class="">
</div>
The error I keep getting is:<br class="">
<div class=""><span style="font-family:monospace,monospace" class=""><br class="">
Error using spm_bwlabel<br class="">
spm_bwlabel: CONN must be 6, 18 or 26<br class="">
<br class="">
Error in clusterstat (line 222)<br class="">
      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);<br class="">
<br class="">
Error in ft_statistics_montecarlo (line 347)<br class="">
  [stat, cfg] = clusterstat(cfg, statrand, statobs);<br class="">
<br class="">
Error in ft_sourcestatistics (line 205)<br class="">
  [stat, cfg] = statmethod(cfg, dat, design);</span><br class="">
<br class="">
</div>
<div class="">It's a mystery what might be wrong. Would you have any further leads?<br class="">
<br class="">
</div>
<div class="">Thanks again,<br class="">
</div>
<div class="">Stephen<br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On 18 May 2017 at 21:35, Schoffelen, J.M. (Jan Mathijs) <span dir="ltr" class="">
<<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank" class="">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word" class="">Hi Stephen,
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">Do you need the source2sparse step to begin with?</div>
<div class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">JM</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">
<div class="m_-1595869056777638227m_-4725666021363548075h5">
<div class="">On 17 May 2017, at 16:46, Stephen Whitmarsh <<a href="mailto:stephen.whitmarsh@gmail.com" target="_blank" class="">stephen.whitmarsh@gmail.com</a>> wrote:</div>
<br class="m_-1595869056777638227m_-4725666021363548075m_-2370281886775714604Apple-interchange-newline">
</div>
</div>
<div class="">
<div class="">
<div class="m_-1595869056777638227m_-4725666021363548075h5">
<div dir="ltr" class="">
<div class="">Hi there,<br class="">
<br class="">
<br class="">
</div>
After beamformer sourceanalysis I end up with datastructures looking like:<br class="">
<span style="font-family:monospace,monospace" class=""><br class="">
</span>
<div class=""><span style="font-family:monospace,monospace" class="">  struct with fields:<br class="">
<br class="">
         freq: 10.5000<br class="">
          cfg: [1×1 struct]<br class="">
          pos: [2982×3 double]<br class="">
          pow: [2982×1 double]<br class="">
       inside: [2982×1 logical]<br class="">
    powdimord: 'pos'<br class="">
</span><br class="">
</div>
<div class="">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 class="">
<br class="">
</div>
<div class=""><span style="color:rgb(255,0,0)" class=""><br class="">
</span><span style="font-family:monospace,monospace" class=""><span style="color:rgb(255,0,0)" class="">Error using spm_bwlabel<br class="">
spm_bwlabel: CONN must be 6, 18 or 26</span><br class="">
<br class="">
<span style="color:rgb(255,0,0)" class="">Error in clusterstat (line 222)<br class="">
      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);<br class="">
<br class="">
Error in ft_statistics_montecarlo (line 347)<br class="">
  [stat, cfg] = clusterstat(cfg, statrand, statobs);<br class="">
<br class="">
Error in ft_sourcestatistics (line 205)<br class="">
  [stat, cfg] = statmethod(cfg, dat, design);</span><br class="">
 <br class="">
<span style="color:rgb(0,0,255)" class=""><u class="">222 </u></span>      [negclusobs, negnum] = spm_bwlabel(tmp, 2*numdims);</span><br class="">
<br class="">
<br class="">
</div>
<div class="">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 class="">
<br class="">
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 class="">
<br class="">
</div>
<div class="">So I guess I might just have put FieldTrip on the wrong leg, to use a Dutch expression.<br class="">
<br class="">
</div>
<div class="">Any suggestions?<br class="">
<br class="">
</div>
<div class="">Best,<br class="">
</div>
<div class="">Stephen<br class="">
</div>
<div class=""><br class="">
<br class="">
</div>
</div>
</div>
</div>
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a><br class="">
</blockquote>
</div>
<br class="">
</div>
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
<br class="">
<br class="">
<div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; word-wrap: break-word;" class="">
<br class="">
</div>
</div>
</div>
</div>
<br class="">
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank" class="">fieldtrip@donders.ru.nl</a><br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/<wbr class="">mailman/listinfo/fieldtrip</a><br class="">
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="mailto:fieldtrip@donders.ru.nl" class="">fieldtrip@donders.ru.nl</a><br class="">
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>