<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi intersect(everyone, casper)<div><br></div><div><blockquote type="cite"><div dir="ltr"><div><div><div>Everyone,</div><div><br></div>While the whole script is way too convoluted to put up here, but luckily the relevant steps are quite simple<div>Input is simply raw data, read with ft_preprocessing, which is passed through functions as shown in my previous email.</div><div><br></div><div>After passing the data to ft_sourcegrandaverage (only using cfg.outputfile), where the data is fed as a cell array (which seems to work properly), I go over to a source-comparison script. This script works as follows:</div><div><div>First I create a pre-post contrast as shown in the beamformer tutorial.</div><div><br></div><div>Next, I read some MRI-data using ft_read_mri from a standard folder, and reslice this data:</div><div><div><i>mri = ft_read_mri(strcat(h.subject,'Subject01.mri'));  <br></i></div><div><i>mri = ft_volumereslice([], mri);</i></div><div><br></div></div></div></div></div></div></blockquote></div><div><div><blockquote type="cite"><div dir="ltr"><div style=""><div style=""><div style="">Then:</div><div style=""><div><i>[data] = ft_sourceinterpolate(cfg, data, mri);<br>

</i></div><div style="">where cfg contains:</div><div style=""><div><div><i>cfg.parameter: 'avg.pow'</i></div><div><i>cfg.downsample: 4</i></div></div><div><br></div></div><div style="">and I add the anatomy:</div></div><div>

<i>data.anatomy = mri.anatomy; clear mri</i></div></div></div></div></blockquote><div><br></div><div><div>Putting mri.anatomy into data.anatomy is probably not what you want to do: the whole point about ft_sourceinterpolate is to get the functional and anatomical data in the same 'pixel-space'; this is the only way that ft_sourceplot (as of yet) can deal with it. The reason is that now the functional data is sampled once every 4 voxels, relative to the anatomy. I guess that this causes your problem in ft_sourceplot.</div><div><blockquote type="cite"><div dir="ltr"><div><div><div></div></div></div></div></blockquote></div></div><div><br></div><div><br></div><div>Best wishes,</div><div><br></div><div>Jan-Mathijs</div><div><br></div><div><br></div><br><blockquote type="cite"><div dir="ltr"><div style=""><div style=""><div>And finally, I call ft_sourceplot using these options:</div></div></div></div></blockquote><blockquote type="cite"><div dir="ltr"><div style=""><div style=""><div>cfg.<i>parameter: 'avg.pow';</i></div></div></div></div></blockquote><blockquote type="cite"><div dir="ltr"><div style=""><div style=""><div><i>cfg.downsample: 4</i></div></div></div></div></blockquote><div><div><i><br></i></div></div></div><div><blockquote type="cite"><div dir="ltr"><div style=""><div style=""><div style=""><div style="">with one of these three methods:</div><div style="">1) <i>cfg.method = 'surface';</i></div><div><i>    cfg.surffile = 'surface_l4_both.mat';</i></div><div><i>    cfg.surfdownsample = 4;</i></div>

<div><i>    cfg.projmethod = 'nearest';</i></div></div><div>2) <i>cfg.method = 'ortho';</i></div><div>3) <i>cfg.method = 'slice';</i></div><div><i>    cfg.nslices = 20;</i></div><div style="">Which leads to the errors shown earlier. At this point, disp(data) yields:</div>

<div style=""><div><i>K>> disp(data)</i></div><div><i>         avg: [1x1 struct]</i></div><div><i>         pos: [16777216x3 double]</i></div><div><i>         dim: [256 256 256]</i></div><div><i>      inside: [1x16777216 double]</i></div>

<div><i>     outside: [1x0 double]</i></div><div><i>    coordsys: 'ctf'</i></div><div><i>        unit: 'mm'</i></div><div><i>         cfg: [1x1 struct]</i></div><div><i>     anatomy: [256x256x256 double]</i></div>

<div><i><br></i></div><div style="">I'm guessing it has something to do with the 'inside' and 'outside' elements, so my 'standard head model'. I think I made this using the following code:</div><div style="">

<div><i>mri = ft_read_mri(strcat(h.subject,'Subject01.mri')); % load 'standard' anatomical model<br></i></div><div><i><br></i></div><div><i>% segment the template brain and construct a volume conduction model (i.e. head model)</i></div>

<div><i>cfg             = [];</i></div><div><i>cfg.output      = {'brain' 'scalp' 'skull'};</i></div><div><i>cfg.downsample  = 2;</i></div><div><i>t_seg    = ft_volumesegment(cfg, mri);</i></div><div>

<i> </i></div><div><i>% create head model</i></div><div><i>cfg          = [];</i></div><div><i>cfg.method   = 'singlesphere';</i></div><div><i>cfg.hdmfile  = strcat(h.subject,'Subject01.hdm');</i></div><div>

<i>cfg.elec     = ft_read_sens('standard_1020.elc');</i></div><div><i>t_vol = ft_prepare_headmodel(cfg, t_seg);</i></div><div><i>clear template_seg</i></div><div><i><br></i></div><div><i>% construct the dipole grid in the template brain coordinates</i></div>

<div><i>cfg = [];</i></div><div><i>cfg.normalize = 'no'; % no normalization, since we're comparing two conditions THAT'S RIGHT I DID PAY ATTENTION</i></div><div><i>cfg.vol        = t_vol;</i></div><div><i>t_grid  = ft_prepare_sourcemodel(cfg);</i></div>

<div><i><br></i></div><div style="">After which I use this on all subjects, using this (note that I store all data in a single massive structure, to make saving to disk and selecting data etc. easier):</div><div><i>source{subj}.(datasets{d}) = sourceanalysis(data, t_vol, t_grid);</i></div>

<div><i><br></i></div><div style="">Anyone seeing anything obviously stupid?</div><div style=""><br></div><div style="">Sincerely,</div><div style=""><br></div><div style="">Casper</div></div></div><div></div></div></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">On Fri, Jan 18, 2013 at 4:43 PM,  <span dir="ltr"><<a href="mailto:Lilla.Magyari@mpi.nl" target="_blank">Lilla.Magyari@mpi.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Casper,<br>
<br>
I think it is really difficult to figure only from the error message what<br>
the problem is. I think it would be also useful to see the inputs (cfg,<br>
and your data) of ft_sourceplot. Could you just send me how your cfg and<br>
your data-structure looks like? (I mean that you do not need to send the<br>
actual data, just the screen output of disp(data) and disp(cfg)).<br>
<br>
Best,<br>
Lilla<br>
<div class="im"><br>
<br>
> Dear Fieldtrippers,<br>
><br>
> I've asked this question earlier, but either it got lost due to technical<br>
> reasons, or the people who actually understand what's happening here were<br>
> on vacation, so here it is again:<br>
><br>
> I've been trying to do a source analysis on a dataset with two conditions,<br>
> mostly following the tutorials and examples from the Fieldtrip site, and<br>
> come upon a problem; it won't plot. While the source analysis is not an<br>
> essential component of the analysis of this dataset (it's more along the<br>
> lines of "let's see if I can do this"), and I don't expect any result<br>
> other<br>
> than something like "there might be a source in the left hemisphere", I'd<br>
> still would like to found out why it's not working.<br>
><br>
> Essentially, I create a standard headmodel cause I don't have individual<br>
> MRI's from the "Subject1.mri"-example, using ft_volumesegment,<br>
> ft_prepare_headmodel and ft_prepare_sourcemodel, and try to get Fieldtrip<br>
> to find sources based on individual EEG-datasets using ft_freqanalysis<br>
> (with cfg.method = 'mtmfft') and ft_sourceanalysis.<br>
> After that, I use ft_sourcegrandaverage to produce, well, a grand average<br>
> source, and feed this via ft_sourceinterpolate to ft_sourceplot.<br>
><br>
> Now, ft_sourceplot has three plotting possibilities: slice, ortho, and<br>
> surface. Initially I tried to get the ortho-option to work, but this gave<br>
> the following error:<br>
</div>> *Attempted to access dim(3); index out of bounds because numel(dim)=2.*<br>
> *Error in ==> cornerpoints at 11<br>
> *<br>
> *Error in ==> ft_plot_slice at 157<br>
<div class="im">> *<br>
><br>
> So, I tried the surf-option, which gave me this:<br>
</div>> *Undefined function or variable "val".*<br>
> *Error in ==> ft_sourceplot at 1174<br>
<div class="im">> *<br>
><br>
> And finally, I tried the slice-option, which gave one of two errors (which<br>
> seems to be based on how many slices I requested):<br>
</div>> *Out of memory*<br>
<div class="im">> Which is pretty damn impressive since I've got 8GB of RAM and a pagefile<br>
> topping of at 40GB<br>
> Or, the mildly disconcerting:<br>
</div>> *Matlab has encountered an internal error and has to close*<br>
> Which seems to have been caused by a so-called *"Segmentation violation"<br>
> *<br>
<div><div class="h5">><br>
> Can anyone offer any insight in these errors? I think I'm doing something<br>
> wrong pretty early on, but have no idea what it is.<br>
><br>
> Sincerely,<br>
><br>
> Casper van Heck<br>
><br>
><br>
> On Fri, Dec 21, 2012 at 1:43 PM, Casper van Heck<br>
> <<a href="mailto:caspervanheck@gmail.com">caspervanheck@gmail.com</a>>wrote:<br>
><br>
>> Dear Fieldtrippers,<br>
>><br>
>> I've been trying to do a source analysis on a dataset with two<br>
>> conditions,<br>
>> mostly following the tutorials and examples from the Fieldtrip site, and<br>
>> come upon a problem; it won't plot. While the source analysis is not an<br>
>> essential component of the analysis of this dataset (it's more along the<br>
>> lines of "let's see if I can do this"), and I don't expect any result<br>
>> other<br>
>> than something like "there might be a source in the left hemisphere",<br>
>> I'd<br>
>> still would like to found out why it's not working.<br>
>><br>
>> Essentially, I create a standard headmodel cause I don't have individual<br>
>> MRI's from the "Subject1.mri"-example, using ft_volumesegment,<br>
>> ft_prepare_headmodel and ft_prepare_sourcemodel, and try to get<br>
>> Fieldtrip<br>
>> to find sources based on individual EEG-datasets using ft_freqanalysis<br>
>> (with cfg.method = 'mtmfft') and ft_sourceanalysis.<br>
>> After that, I use ft_sourcegrandaverage to produce, well, a grand<br>
>> average<br>
>> source, and feed this via ft_sourceinterpolate to ft_sourceplot.<br>
>><br>
>> Now, ft_sourceplot has three plotting possibilities: slice, ortho, and<br>
>> surface. Initially I tried to get the ortho-option to work, but this<br>
>> gave<br>
>> the following error:<br>
</div></div>>> *Attempted to access dim(3); index out of bounds because numel(dim)=2.*<br>
>> *Error in ==> cornerpoints at 11<br>
>> *<br>
>> *Error in ==> ft_plot_slice at 157<br>
<div class="im">>> *<br>
>><br>
>> So, I tried the surf-option, which gave me this:<br>
</div>>> *Undefined function or variable "val".*<br>
>> *Error in ==> ft_sourceplot at 1174<br>
<div class="im">>> *<br>
>><br>
>> And finally, I tried the slice-option, which gave one of two errors<br>
>> (which<br>
>> seems to be based on how many slices I requested):<br>
</div>>> *Out of memory*<br>
<div class="im">>> Which is pretty damn impressive since I've got 8GB of RAM and a pagefile<br>
>> topping of at 40GB<br>
>> Or, the mildly disconcerting:<br>
</div>>> *Matlab has encountered an internal error and has to close*<br>
>> Which seems to have been caused by a so-called *"Segmentation violation"<br>
>> *<br>
<div class="im HOEnZb">>><br>
>> Can anyone offer any insight in these errors? I think I'm doing<br>
>> something<br>
>> wrong pretty early on, but have no idea what it is.<br>
>><br>
>> Sincerely,<br>
>><br>
>> Casper van Heck<br>
>><br>
</div><div class="HOEnZb"><div class="h5">> _______________________________________________<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>
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></div>
_______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Jan-Mathijs Schoffelen, MD PhD </div><div><br></div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><br></div><div>Max Planck Institute for Psycholinguistics,</div><div>Nijmegen, The Netherlands</div><div><br></div><div><a href="mailto:J.Schoffelen@donders.ru.nl">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: +31-24-3614793</div></div></span></div></span></div></span></div></span></div></span></span>
</div>
<br></div></body></html>