<div dir="ltr">Hello,<div><br></div><div>I am new to FieldTrip (and MEG) and I have been working through the walkthroughs and tutorials in an attempt to use beamforming to source localize my MEG data. In this experiment, there are 3 conditions and 2 groups. I have been following the Example: Source Statistics (<a href="http://www.fieldtriptoolbox.org/example/source_statistics">http://www.fieldtriptoolbox.org/example/source_statistics</a>) tutorial but I have encountered a couple of difficulties. </div><div><br></div><div>1) The first issue is in the choice of design matrix for the analyses I would like to run. The tutorial offers a very clear example of how to assess differences between conditions within a single group, but it is less straightforward (to me at least) how to run an analysis of the differences between two groups on a single condition. In my case, I have 17 participants from group 1 and 14 participants from group 2. I have created 17x1 and 14x1 cell array containing the output from each subject's beamform (at the individual subject level, I contrasted a period of interest from condition 1 with an equivalent length of time from the prestim baseline). My call to ft_sourcestatistics is below. Is this the proper way to set up the design matrix to run this analysis? I know that participants are not true 'independent variables' but it seems to me that treating them as such will randomise group assignment to produce the monte carlo distribution that I am looking for.</div><div><br></div><div><div>cfg=[];</div><div>cfg.dim=cond1_h{1}.dim;</div><div>cfg.method      = 'montecarlo';</div><div>cfg.statistic   = 'ft_statfun_indepsamplesT';</div><div>cfg.parameter   = 'pow';</div><div>cfg.correctm    = 'cluster';</div><div>cfg.numrandomization = 1000;</div><div>cfg.alpha       = 0.05; % note that this only implies single-sided testing</div><div>cfg.tail        = 0;</div><div><br></div><div>nsubj=17;</div><div>cfg2.design(1,:) = [ones(1,nsubj) ones(1,nsubj)*2];  %create over-large desmtx </div><div>cfg.design=cfg.design(:,1:31); %trim desmtx to correct specs</div><div>cfg.ivar        = 1; % row of design matrix that contains independent variable (the participants)</div><div><br></div><div>stat = ft_sourcestatistics(cfg, cond1_h{:}, cond1_s{:});</div></div><div><br></div><div>2) The second issue is that it appears I have been inefficient in my memory use as matlab crashes when I attempt to run this analysis ( FYI I have 16GB of RAM and 16GB of swap space). I have employed the -nojvm flag when starting matlab, and I have used struct2single to try and reduce the memory load but matlab still crashes out (without message) when I attempt to run this analysis. This code will run on my computer with a maximum of 4 subjects from each group and 50 randomizations, which is obviously not ideal for me. Please find the contents of a single cell from one of the groups below. Is there something that is obviously problematic in what I have so far? </div><div><br></div><div><div>       inside: [256x256x256 logical]</div><div>          pow: [256x256x256 single]</div><div>          dim: [256 256 256]</div><div>    transform: [4x4 single]</div><div>      anatomy: [256x256x256 single]</div><div>     coordsys: 'ctf'</div><div>         unit: 'mm'</div><div>          cfg: [1x1 struct]</div></div><div><br></div><div><br></div><div>Thank you very much for any help you can offer me with this! If any further information or clarifications would be useful to help diagnose or overcome this issue, please let me know.</div><div><br></div><div>Paul</div><div><br></div><div><br></div><div><br></div></div>