Hi,<div><br></div><div>So I have followed Johanna and Stephan's advise to create template_grid and each subject's grid from MNI image, which is now 1cm spacing instead of .5cm. These steps seem to run, and I'm able to create a common spatial filter to run beamformer using DICS. However, I get an error when I apply the commom filter to each condition.</div>

<div><br></div><div>I had to tweak a few things on example on the page <a href="http://fieldtrip.fcdonders.nl/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space?s[]=template&s[]=grid">http://fieldtrip.fcdonders.nl/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space?s[]=template&s[]=grid</a>  , since my data is EEG and electrode locations vary between subjects, such that:</div>

<div><br></div><font color="#000099">cfg = [];<br>cfg.grid.xgrid  = -20:1:20;<br>cfg.grid.ygrid  = -20:1:20;<br>cfg.grid.zgrid  = -20:1:20;<br>cfg.grid.tight  = 'yes';<br>cfg.inwardshift = -1.5;<br>cfg.vol        = template_vol;<br>

<b>cfg.elec = ft_data.elec; % individual sub's electrode locations: had to add this (got error otherwise)</b><br>template_grid  = ft_prepare_sourcemodel(cfg);</font><div><font color="#000099"><br></font></div><div>then</div>

<div>







<font color="#000099">cfg = [];<br>cfg.grid.warpmni   = 'yes';<br>cfg.grid.template  = template_grid;<br>cfg.grid.nonlinear = 'yes'; <br>cfg.mri            = mri_aligned;<br><b>cfg.elec = ft_data.elec; </b></font><b style="color:rgb(0,0,153)">% individual sub's electrode locations: had to add this (got error otherwise)</b><font color="#000099"><br>

grid               = ft_prepare_sourcemodel(cfg);</font></div><div><font color="#000099"><br></font></div><div>These create grids in MNI space, both for template and individual fine. To create a common spatial filter, I run the following command, which runs:</div>

<font color="#000099">cfg = [];<br>cfg.grid.pos        = grid.pos;<br>cfg.grid.dim        = grid.dim;<br>cfg.grid.inside     = grid.inside;<br>cfg.grid.outside  = grid.outside;<br>cfg.inwardshift     = -1.5;<br>cfg.vol             = vol_cm;<br>

cfg.channel         = {'all'};<br>cfg.frequency       = 10.5;<br>cfg.method          = 'dics';<br>cfg.dics.projectnoise    = 'yes';<br>cfg.dics.keepfilter      = 'yes';<br>cfg.dics.feedback        = 'no';<br>

source_common       = ft_sourceanalysis(cfg, freq_common);</font><br><br>however, when I apply this spatial filter to a task condition, I get an error message <br><font color="#000099">cfg = [];<br>cfg.elec            = freq_common.elec;<br>

cfg.grid.pos        = source_common.pos;<br>cfg.grid.filter     = source_common.avg.filter;<br>cfg.inwardshift     = -1.5; <br>cfg.vol             = vol_cm;<br>cfg.channel         = {'all'};<br>cfg.frequency       = 10.5;<br>

cfg.method          = 'dics';<br>cfg.dics.projectnoise    = 'yes';<br>cfg.dics.keepfilter      = 'yes';<br>cfg.dics.feedback        = 'no';<br>source_itemL         = ft_sourceanalysis(cfg, freq_itemL);<br>

source_itemL.unit    = 'cm';</font><br><div><font color="#000099"><br></font></div><div><div><font color="#ff0000">??? Error using ==> mtimes</font></div><div><font color="#ff0000">Inner matrix dimensions must agree.</font></div>

<div><font color="#ff0000"><br></font></div><div><font color="#ff0000">Error in ==> beamformer_dics at 316</font></div><div><font color="#ff0000">      csd = filt * Cf * ctranspose(filt);                         % Gross eqn. 4</font></div>

<div><font color="#ff0000">      and 5</font></div><div><font color="#ff0000"><br></font></div><div><font color="#ff0000">Error in ==> ft_sourceanalysis at 588</font></div><div><font color="#ff0000">      dip(i) = beamformer_dics(grid, sens, vol, [],  squeeze(Cf(i,:,:)),</font></div>

<div><font color="#ff0000">      optarg{:});</font></div></div><div><font color="#000099"><br></font></div><div>The error occurs when dip.pos = 40 (i.e. it runs fine 1-39). I can't spot where exactly the error is originating from. Am I missing some steps when I create template grids that I feed into ft_sourceanalysis?</div>

<div><br></div><div>Thank you in advance for your help! Akiko   </div><div><div><font color="#000099"><br></font><div><br><div class="gmail_quote">On Thu, Oct 18, 2012 at 4:29 PM, Akiko Ikkai <span dir="ltr"><<a href="mailto:akiko.ikkai@gmail.com" target="_blank">akiko.ikkai@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Everyone,<div><br></div><div>Thank you very much for your advise. I just came back from SfN, and just found your replies, so I will test these options and report back what I find.</div>

<div><br></div><div>Thank you again! Akiko<div><div class="h5"><br>
<br><div class="gmail_quote">On Mon, Oct 8, 2012 at 6:14 AM, 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">


Hi Akiko!<div><br></div><div>Just to chime in - your source grid is very, very large indeed! ALthough I started with a very fine grid, at one point I also had to downside it (going to 5mm), and had to stop using interpolated source data for stats and the like. Johanna's suggestion will certainly do the trick and it will speed up your analysis enormously as well. You then only need to do interpolate for plotting purposes.</div>



<div><br></div><div>all the best,</div><div>Stephen</div><div><div><div><br><br><div class="gmail_quote">On 8 October 2012 12:02, Johanna Zumer <span dir="ltr"><<a href="mailto:johanna.zumer@donders.ru.nl" target="_blank">johanna.zumer@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">Hi Akiko,<div><br></div><div>In addition to Saskia's comment (which is very useful!) remember also that if you create the subject's grid from the warped MNI template grid (explained here <a href="http://fieldtrip.fcdonders.nl/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space?s[]=template&s[]=grid" target="_blank">http://fieldtrip.fcdonders.nl/example/create_single-subject_grids_in_individual_head_space_that_are_all_aligned_in_mni_space?s[]=template&s[]=grid</a>)  then you can keep each subject's source data in a 'source' structure with .pos field and still do group level statistics, without need to convert to 'volume' structure which upsamples the spatial resolution perhaps artificially too high.</div>





<div><br></div><div>Cheers,</div><div>Johanna<div><div><br><br><div class="gmail_quote">2012/10/7 Akiko Ikkai <span dir="ltr"><<a href="mailto:akiko.ikkai@gmail.com" target="_blank">akiko.ikkai@gmail.com</a>></span><br>



<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Saskia,<div><br></div><div>Thank you for the quick advise! Removing cfg definitely works well. Each of the group data is now 1.3G (I also used "single" to convert everything into single precision), which is definitely manageable. Computation time has also been reduced to 3 times less now.</div>







<div><br></div><div>Thanks! Akiko  <div><div><br><br><div class="gmail_quote">On Sun, Oct 7, 2012 at 2:16 PM, Saskia Haegens <span dir="ltr"><<a href="mailto:shaegens@gmail.com" target="_blank">shaegens@gmail.com</a>></span> wrote:<br>







<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Akiko,<br>
<br>
In my experience with grandavg source structs, sometimes the cfg<br>
(that's attached to the data struct) becomes very large and can<br>
consume a considerable amount of memory. I'm not sure if that's the<br>
case/problem here, but might be worth checking and removing the cfg.<br>
You could even use checkconfig to cleanup your cfg with:<br>
data.cfg = ft_checkconfig(data.cfg, 'checksize', 'yes')<br>
Hope this helps!<br>
<br>
Best,<br>
Saskia<br>
<div><div><br>
On Sun, Oct 7, 2012 at 11:36 AM, Akiko Ikkai <<a href="mailto:akiko.ikkai@gmail.com" target="_blank">akiko.ikkai@gmail.com</a>> wrote:<br>
> Dear Fieldtrip users,<br>
><br>
> I've been trying to run group stats on my EEG source data, which contains 14<br>
> subjects' normalized beamformer data, and having serious swap memory issue<br>
> (not Matlab memory issue, but OS swap memory).<br>
><br>
> I'm trying to contrast 2 conditions (within subject design). Each subject's<br>
> normalized beamformer data (1 condition) is<br>
><br>
> source_lTMI_intNorm =<br>
><br>
>       anatomy: [181x217x181 double]<br>
><br>
>        inside: [181x217x181 logical]<br>
><br>
>           avg: [1x1 struct]<br>
><br>
>     transform: [4x4 double]<br>
><br>
>           dim: [181 217 181]<br>
><br>
>           cfg: [1x1 struct]<br>
><br>
><br>
>>whos<br>
><br>
><br>
><br>
> Name                     Size                Bytes  Class     Attributes<br>
><br>
>   source_lTMI_intNorm      1x1             520114791  struct<br>
><br>
><br>
> therefore, when I open all subjects' data ("data1group" and "data2group"),<br>
> it's huge...<br>
><br>
> Name            Size                 Bytes  Class     Attributes<br>
><br>
>   data1group      1x14            5909429438  cell<br>
><br>
>   data2group      1x14            6705652782  cell<br>
><br>
><br>
> data1group & data2group are both 1x14 struct (1 cell/subject). Therefore,<br>
><br>
>>data1group{1}<br>
><br>
> anatomy: [181x217x181 double]<br>
><br>
>        inside: [181x217x181 logical]<br>
><br>
>           avg: [1x1 struct]<br>
><br>
>     transform: [4x4 double]<br>
><br>
>           dim: [181 217 181]<br>
><br>
>           cfg: [1x1 struct]<br>
><br>
> So, when I try to run<br>
><br>
> cfg=[];<br>
><br>
>  cfg.dim         = data1group{1}.dim;<br>
><br>
>  cfg.method      = 'montecarlo';<br>
><br>
>  cfg.statistic   = 'depsamplesT';<br>
><br>
>  cfg.parameter   = 'avg.pow';<br>
><br>
>  cfg.correctm    = 'cluster';<br>
><br>
>  cfg.numrandomization = 100;<br>
><br>
>  cfg.alpha       = 0.05;<br>
><br>
>  cfg.tail        = 0;<br>
><br>
>  nsubj=length(data1group);<br>
><br>
>  cfg.design(1,:) = [1:nsubj 1:nsubj];<br>
><br>
>  cfg.design(2,:) = [ones(1,nsubj) ones(1,nsubj)*2];<br>
><br>
>  cfg.uvar        = 1;<br>
><br>
>  cfg.ivar        = 2;<br>
><br>
>  stat = ft_sourcestatistics(cfg, data1group{:}, data2group{:});<br>
><br>
>  stat.anatomy = data1group{1}.anatomy;<br>
><br>
><br>
> my computer (os 10.6.8, 6G memory) runs out of swap memory (startup<br>
> memory?), which forces me to quit Matlab. I'm running above processes in a<br>
> function, so I'm not running into Matlab memory error.<br>
><br>
> Could someone help me how it could run more efficiently? I guess<br>
> cfg.inputfile is not available for ft_sourcestatistics, so I have to<br>
> eventually load 2 group data in Matlab workspace...?<br>
><br>
> Thank you in advance! Akiko<br>
><br>
> --<br>
> Akiko Ikkai, Ph.D.<br>
> Postdoctoral Fellow<br>
> Department of Psychological and Brain Sciences<br>
> Johns Hopkins University<br>
> Ames Hall, 3400 N. Charles St.<br>
> Baltimore, MD 21218<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> fieldtrip mailing list<br>
> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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>
_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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><font><span style="font-family:arial,helvetica,sans-serif">Akiko Ikkai, Ph.D. <br>Postdoctoral Fellow<br style="font-family:arial,helvetica,sans-serif"></span></font><font style="font-family:arial,helvetica,sans-serif" face="'PrimaSans BT,Verdana,sans-serif'">Department of 
Psychological and Brain Sciences<br>Johns Hopkins University<br>Ames 
Hall, 3400 N. Charles St.<br>Baltimore, MD 21218</font><br style="font-family:arial,helvetica,sans-serif"><br><br>
</div></div></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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></div></div></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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></div>
</div></div><br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl" target="_blank">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><font><span style="font-family:arial,helvetica,sans-serif">Akiko Ikkai, Ph.D. <br>


Postdoctoral Fellow<br style="font-family:arial,helvetica,sans-serif"></span></font><font style="font-family:arial,helvetica,sans-serif" face="'PrimaSans BT,Verdana,sans-serif'">Department of 
Psychological and Brain Sciences<br>Johns Hopkins University<br>Ames 
Hall, 3400 N. Charles St.<br>Baltimore, MD 21218</font><br style="font-family:arial,helvetica,sans-serif"><br><br>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><font><span style="font-family:arial,helvetica,sans-serif">Akiko Ikkai, Ph.D. <br>Postdoctoral Fellow<br style="font-family:arial,helvetica,sans-serif"></span></font><font style="font-family:arial,helvetica,sans-serif" face="'PrimaSans BT,Verdana,sans-serif'">Department of 
Psychological and Brain Sciences<br>Johns Hopkins University<br>Ames 
Hall, 3400 N. Charles St.<br>Baltimore, MD 21218</font><br style="font-family:arial,helvetica,sans-serif"><br><br>
</div></div></div>