Hi Johanna,<div><br></div><div>you are right! specifying cfg.grid = grid; was the key; ft_sourceanalysis for each condition runs to the completion :) </div><div><br></div><div>However, since my data is EEG and the electrode locations vary (hence the grid coordinates vary) between subjects, running stats across subjects without normalizing might be causing a problem. For example, the first 3 points in subject1's .pos are (after creating template grid etc.., and run ft_sourceanalysis using MNI grid):</div>
<div><br></div><div>d1group{1}.pos(1:3,:)</div><div>ans =</div><div> -8.7000 -7.5000 -7.6000</div><div> -7.7000 -7.5000 -7.6000</div><div> -6.7000 -7.5000 -7.6000</div><div><br></div><div>and the same points for the subject2's are:</div>
<div><br></div><div>d1group{2}.pos(1:3,:)</div><div>ans =</div><div> -8.3000 -7.6000 -8.2000</div><div> -7.3000 -7.6000 -8.2000</div><div> -6.3000 -7.6000 -8.2000 </div><div> </div><div>So when I try to run ft_sourcestatistics. I get an error message:</div>
<div><div><font color="#ff0000">??? Error using ==> statistics_wrapper at 109</font></div><div><font color="#ff0000">grid locations of the source reconstructions do not match, use NORMALISEVOLUME</font></div><div><font color="#ff0000">first</font></div>
<div><font color="#ff0000"><br></font></div><div><font color="#ff0000">Error in ==> ft_sourcestatistics at 100</font></div><div><font color="#ff0000"> [stat, cfg] = statistics_wrapper(cfg, varargin{:});</font></div>
</div><div><font color="#ff0000"><br></font></div><div>Perhaps I should interpolate and normalize each subject, and run group stats afterall?</div><div><br></div><div>Thanks! Akiko </div><div><div><br><div class="gmail_quote">
On Sun, Oct 21, 2012 at 11:32 AM, 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,<br>
<br>
Can you type 'dbstop if error' before running the last step, so that<br>
it goes to debug mode when it crashes there? What are the sizes of<br>
'filt' and 'Cf' for the 40th position?<br>
<br>
Another thing to try is, during your last call to ft_sourceanalysis,<br>
cfg = [];<br>
cfg.grid = grid;<br>
cfg.grid.filter = source_common.avg.filter;<br>
<br>
so that all the .inside and .outside information is transfered as well.<br>
<br>
A note to all users: you can skip the first step by loading the<br>
precomuted template grids in */fieldtrip/template/sourcemodel.<br>
<br>
Cheers,<br>
Johanna<br>
<br>
<br>
2012/10/20 Akiko Ikkai <<a href="mailto:akiko.ikkai@gmail.com">akiko.ikkai@gmail.com</a>>:<br>
<div class="HOEnZb"><div class="h5">> Hi,<br>
><br>
> So I have followed Johanna and Stephan's advise to create template_grid and<br>
> each subject's grid from MNI image, which is now 1cm spacing instead of<br>
> .5cm. These steps seem to run, and I'm able to create a common spatial<br>
> filter to run beamformer using DICS. However, I get an error when I apply<br>
> the commom filter to each condition.<br>
><br>
> I had to tweak a few things on example on the page<br>
> <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><br>
> , since my data is EEG and electrode locations vary between subjects, such<br>
> that:<br>
><br>
> 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>
> cfg.elec = ft_data.elec; % individual sub's electrode locations: had to add<br>
> this (got error otherwise)<br>
> template_grid = ft_prepare_sourcemodel(cfg);<br>
><br>
> then<br>
> cfg = [];<br>
> cfg.grid.warpmni = 'yes';<br>
> cfg.grid.template = template_grid;<br>
> cfg.grid.nonlinear = 'yes';<br>
> cfg.mri = mri_aligned;<br>
> cfg.elec = ft_data.elec; % individual sub's electrode locations: had to add<br>
> this (got error otherwise)<br>
> grid = ft_prepare_sourcemodel(cfg);<br>
><br>
> These create grids in MNI space, both for template and individual fine. To<br>
> create a common spatial filter, I run the following command, which runs:<br>
> 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);<br>
><br>
> however, when I apply this spatial filter to a task condition, I get an<br>
> error message<br>
> 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';<br>
><br>
> ??? Error using ==> mtimes<br>
> Inner matrix dimensions must agree.<br>
><br>
> Error in ==> beamformer_dics at 316<br>
> csd = filt * Cf * ctranspose(filt); % Gross<br>
> eqn. 4<br>
> and 5<br>
><br>
> Error in ==> ft_sourceanalysis at 588<br>
> dip(i) = beamformer_dics(grid, sens, vol, [], squeeze(Cf(i,:,:)),<br>
> optarg{:});<br>
><br>
> The error occurs when dip.pos = 40 (i.e. it runs fine 1-39). I can't spot<br>
> where exactly the error is originating from. Am I missing some steps when I<br>
> create template grids that I feed into ft_sourceanalysis?<br>
><br>
> Thank you in advance for your help! Akiko<br>
><br>
><br>
> On Thu, Oct 18, 2012 at 4:29 PM, Akiko Ikkai <<a href="mailto:akiko.ikkai@gmail.com">akiko.ikkai@gmail.com</a>> wrote:<br>
>><br>
>> Hi Everyone,<br>
>><br>
>> Thank you very much for your advise. I just came back from SfN, and just<br>
>> found your replies, so I will test these options and report back what I<br>
>> find.<br>
>><br>
>> Thank you again! Akiko<br>
>><br>
>><br>
>> On Mon, Oct 8, 2012 at 6:14 AM, Stephen Whitmarsh<br>
>> <<a href="mailto:stephen.whitmarsh@gmail.com">stephen.whitmarsh@gmail.com</a>> wrote:<br>
>>><br>
>>> Hi Akiko!<br>
>>><br>
>>> Just to chime in - your source grid is very, very large indeed! ALthough<br>
>>> I started with a very fine grid, at one point I also had to downside it<br>
>>> (going to 5mm), and had to stop using interpolated source data for stats and<br>
>>> the like. Johanna's suggestion will certainly do the trick and it will speed<br>
>>> up your analysis enormously as well. You then only need to do interpolate<br>
>>> for plotting purposes.<br>
>>><br>
>>> all the best,<br>
>>> Stephen<br>
>>><br>
>>><br>
>>> On 8 October 2012 12:02, Johanna Zumer <<a href="mailto:johanna.zumer@donders.ru.nl">johanna.zumer@donders.ru.nl</a>><br>
>>> wrote:<br>
>>>><br>
>>>> Hi Akiko,<br>
>>>><br>
>>>> In addition to Saskia's comment (which is very useful!) remember also<br>
>>>> that if you create the subject's grid from the warped MNI template grid<br>
>>>> (explained here<br>
>>>> <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>)<br>
>>>> then you can keep each subject's source data in a 'source' structure with<br>
>>>> .pos field and still do group level statistics, without need to convert to<br>
>>>> 'volume' structure which upsamples the spatial resolution perhaps<br>
>>>> artificially too high.<br>
>>>><br>
>>>> Cheers,<br>
>>>> Johanna<br>
>>>><br>
>>>><br>
>>>> 2012/10/7 Akiko Ikkai <<a href="mailto:akiko.ikkai@gmail.com">akiko.ikkai@gmail.com</a>><br>
>>>>><br>
>>>>> Hi Saskia,<br>
>>>>><br>
>>>>> Thank you for the quick advise! Removing cfg definitely works well.<br>
>>>>> Each of the group data is now 1.3G (I also used "single" to convert<br>
>>>>> everything into single precision), which is definitely manageable.<br>
>>>>> Computation time has also been reduced to 3 times less now.<br>
>>>>><br>
>>>>> Thanks! Akiko<br>
>>>>><br>
>>>>><br>
>>>>> On Sun, Oct 7, 2012 at 2:16 PM, Saskia Haegens <<a href="mailto:shaegens@gmail.com">shaegens@gmail.com</a>><br>
>>>>> wrote:<br>
>>>>>><br>
>>>>>> 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>
>>>>>><br>
>>>>>> On Sun, Oct 7, 2012 at 11:36 AM, Akiko Ikkai <<a href="mailto:akiko.ikkai@gmail.com">akiko.ikkai@gmail.com</a>><br>
>>>>>> wrote:<br>
>>>>>> > Dear Fieldtrip users,<br>
>>>>>> ><br>
>>>>>> > I've been trying to run group stats on my EEG source data, which<br>
>>>>>> > contains 14<br>
>>>>>> > subjects' normalized beamformer data, and having serious swap memory<br>
>>>>>> > issue<br>
>>>>>> > (not Matlab memory issue, but OS swap memory).<br>
>>>>>> ><br>
>>>>>> > I'm trying to contrast 2 conditions (within subject design). Each<br>
>>>>>> > 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<br>
>>>>>> > Attributes<br>
>>>>>> ><br>
>>>>>> > source_lTMI_intNorm 1x1 520114791 struct<br>
>>>>>> ><br>
>>>>>> ><br>
>>>>>> > therefore, when I open all subjects' data ("data1group" and<br>
>>>>>> > "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).<br>
>>>>>> > 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<br>
>>>>>> > 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>
>>>>>> > _______________________________________________<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>
>>>>>> _______________________________________________<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>
>>>>><br>
>>>>><br>
>>>>><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>
>>>>> _______________________________________________<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>
>>>><br>
>>>><br>
>>>><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>
>>><br>
>>><br>
>>><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>
>><br>
>><br>
>><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>
><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>
> _______________________________________________<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>
_______________________________________________<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>
</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>