<div dir="ltr">Hi Laura,<div><br></div><div>If I understand your problem correctly, what I think you need to do is create a template grid using ft_source_model, then use ft_source_model to create a grid using each subjects' mri with the template grid, and finally change the .dim and .pos parameters of the source analysis output to unwarp from the subject grid to the template grid. The following code might help, although I think there is also a tutorial that talks about this:</div><div><br></div><div><div>    template                   = ft_read_mri(templatefile);</div><div>    template.coordsys    = 'spm';</div><div>    </div><div>    % segment the template brain and construct a volume conduction model (i.e. head model)</div><div><br></div><div>    cfg                            = [];</div><div>    template_seg           = ft_volumesegment(cfg, template);</div><div> </div><div>    cfg                            = [];</div><div>    cfg.method               = 'singleshell';</div><div>    template_vol             = ft_prepare_headmodel(cfg, template_seg);</div><div> </div><div>    % construct the dipole grid in the template brain coordinates</div><div><br></div><div>    cfg                           = [];</div><div>    cfg.grid.xgrid           = -20:1:20;</div><div>    cfg.grid.ygrid           = -20:1:20;</div><div>    cfg.grid.zgrid           = -20:1:20;</div><div>    cfg.grid.unit             = 'cm';</div><div>    cfg.grid.tight            = 'yes';</div><div>    cfg.inwardshift        = -1.5;</div><div>    cfg.vol                     = template_vol;</div><div>    template_grid         = ft_prepare_sourcemodel(cfg);</div></div><div><br></div><div>   % Subject mri</div><div><br></div><div><div>    mri                          = ft_read_mri(mrifile);</div><div>    mri                          = ft_volumereslice([], mri);</div></div><div><br></div><div><div>    cfg                          = [];</div><div>    cfg.write                  = 'no';</div><div>    cfg.coordsys           = 'ctf';</div><div>    segmented             = ft_volumesegment(cfg, mri);</div><div>    </div><div>    cfg                          = [];</div><div>    cfg.method             = 'singleshell';</div><div>    vol                          = ft_prepare_headmodel(cfg, segmented);</div><div><br></div><div>    % Prepare Source Model using template grid and subject mri</div><div><br></div><div>    cfg                          = [];</div><div>    cfg.grid.warpmni     = 'yes';</div><div>    cfg.grid.template     = template_grid;</div><div>    cfg.grid.nonlinear    = 'yes';</div><div>    cfg.mri                     = mri;</div><div>    grid                          = ft_prepare_sourcemodel(cfg);</div></div><div><br></div><div><div>   % Unwarp Grid (For group analysis)</div></div><div><br></div><div>    src.dim                   = template_grid.dim;<br></div><div><div>    src.pos                   = template_grid.pos;</div></div><div><br></div><div>I hope this helps.</div><div>best,</div><div><br></div><div>Max</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 20, 2014 at 12:17 PM, Laura Rueda Delgado <span dir="ltr"><<a href="mailto:Laura.Rueda@faber.kuleuven.be" target="_blank">Laura.Rueda@faber.kuleuven.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="NL-BE" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Dear all,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="EN-US">I’m working with EEG data and the individual MRIs. I have a doubt about a step for defining ROIs. I have EEG data during a task with 3 conditions (C1, C2, C3) and during rest. I would like to know what is the main effect
 of the conditions in my source data. I was recommended to use the contrast of Task (C1, C2 and C3 together) vs Rest to obtain meaningful sources, which then are used to restrict the source and statistical analysis between the conditions. This is what I do:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p><u></u><span lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span lang="EN-US">Estimate sources with the common filter for Task and Rest separately.<u></u><u></u></span></p>
<p><u></u><span lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span lang="EN-US">Find sources that are significantly different between these two conditions (ft_sourcestatistics with dependent T).<u></u><u></u></span></p>
<p><u></u><span lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span lang="EN-US">Use the position of these sources as ROIs in ft_sourceanalysis for C1, C2 and C3 separately (but using a common filter of these conditions).<u></u><u></u></span></p>
<p><u></u><span lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span lang="EN-US">Find sources that account for the main effect between conditions (ft_sourcestatistics with dependent F).
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Now the problem is that if I use the position of the sources in ft_sourceanalysis, I don’t have a regular grid anymore, and this becomes a problem when using ft_sourcestatistics as cfg.dim needs to be specified and if
 I do not specify it (because I don’t have a regular grid with 3 dimensions as expected), I get the following error:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">Error using reshape<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">To RESHAPE the number of elements must not change.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">Error in clusterstat (line 185)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">      posclusobs = findcluster(reshape(postailobs, [cfg.dim,1]),channeighbstructmat,cfg.minnbchan);<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">Error in ft_statistics_montecarlo (line 361)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">  [stat, cfg] = clusterstat(cfg, statrand, statobs);<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">Error in statistics_wrapper (line 308)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">    [stat, cfg] = statmethod(cfg, dat, design);<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">Error in ft_sourcestatistics (line 107)<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:red">    [stat, cfg] = statistics_wrapper(cfg, varargin{:});<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">So does anybody know a way to work around this?
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">And what do you think of the logic of these steps?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you in advance for any help!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Cheers,<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></span></p><span class="HOEnZb"><font color="#888888">
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Laura Rueda Delgado<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</font></span></div>
</div>

<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Max Cantor<div>Lab Manager</div><div>Computational Neurolinguistics Lab</div><div>University of Michigan</div></div>
</div>