[FieldTrip] Source localization

Casper van Heck caspervanheck at gmail.com
Sat Jan 26 17:05:28 CET 2013


Dear Hanneke,

But data.anatomy doesn't exist; I added it through the line *data.anatomy =
mri.anatomy; clear mri*, but originally it does not have any.

I'm going to take a look at earlier steps to find out why this field isn't
there in the first place (assuming it should be).

Sincerely,

Casper



On Wed, Jan 23, 2013 at 12:19 PM, Hanneke van Dijk <
Hanneke.vanDijk at med.uni-duesseldorf.de> wrote:

> Hi Casper,
>
> The cfg.anaparameter should then be 'anatomy'.  It refers to the field (in
> data) in which the anatomy can be found, in your case: data.anatomy.
>
> Hope this helps,
>
> Hanneke
> Op 23 jan. 2013 10:57 schreef "Casper van Heck" <caspervanheck at gmail.com>
> het volgende:
>
>  Dear Jan-Mathijs,
>>
>> Since ft_sourceplot complained about not having anatomy (or functional)
>> parameter, and it seems to default to a field named '*data.anatomy'*, I
>> assumed adding *mri.anatomy* in *data.anatomy* would suffice.
>>
>> But, without this, ft_sourceplot would again require an anatomy
>> parameter, so that would mean that I need to ut '*cfg.anaparameter = mri*'
>> in the cfg I feed to ft_sourceplot, where 'mri' is the result from
>> ft_volumereslice.
>> However, ft_sourceplot then says "*do not understand cfg.anaparameter*",
>> and thus it is not plotting "*anatomy*". After looking back to the
>> plotting tutorial where I read "The anatomy can be read with ft_read_mri",
>> I'm not quite sure what's going wrong.
>>
>> Sincerely,
>>
>> Casper
>>
>>
>>
>> On Tue, Jan 22, 2013 at 9:49 AM, jan-mathijs schoffelen <
>> jan.schoffelen at donders.ru.nl> wrote:
>>
>>> Hi intersect(everyone, casper)
>>>
>>> Everyone,
>>>
>>> While the whole script is way too convoluted to put up here, but luckily
>>> the relevant steps are quite simple
>>> Input is simply raw data, read with ft_preprocessing, which is passed
>>> through functions as shown in my previous email.
>>>
>>> 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:
>>> First I create a pre-post contrast as shown in the beamformer tutorial.
>>>
>>> Next, I read some MRI-data using ft_read_mri from a standard folder, and
>>> reslice this data:
>>> *mri = ft_read_mri(strcat(h.subject,'Subject01.mri'));
>>> *
>>> *mri = ft_volumereslice([], mri);*
>>>
>>> Then:
>>> *[data] = ft_sourceinterpolate(cfg, data, mri);
>>> *
>>> where cfg contains:
>>> *cfg.parameter: 'avg.pow'*
>>> *cfg.downsample: 4*
>>>
>>> and I add the anatomy:
>>> *data.anatomy = mri.anatomy; clear mri*
>>>
>>>
>>> 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.
>>>
>>>
>>>
>>> Best wishes,
>>>
>>> Jan-Mathijs
>>>
>>>
>>>
>>> And finally, I call ft_sourceplot using these options:
>>>
>>> cfg.*parameter: 'avg.pow';*
>>>
>>> *cfg.downsample: 4*
>>>
>>> *
>>> *
>>>
>>> with one of these three methods:
>>> 1) *cfg.method = 'surface';*
>>> *    cfg.surffile = 'surface_l4_both.mat';*
>>> *    cfg.surfdownsample = 4;*
>>> *    cfg.projmethod = 'nearest';*
>>> 2) *cfg.method = 'ortho';*
>>> 3) *cfg.method = 'slice';*
>>> *    cfg.nslices = 20;*
>>> Which leads to the errors shown earlier. At this point, disp(data)
>>> yields:
>>> *K>> disp(data)*
>>> *         avg: [1x1 struct]*
>>> *         pos: [16777216x3 double]*
>>> *         dim: [256 256 256]*
>>> *      inside: [1x16777216 double]*
>>> *     outside: [1x0 double]*
>>> *    coordsys: 'ctf'*
>>> *        unit: 'mm'*
>>> *         cfg: [1x1 struct]*
>>> *     anatomy: [256x256x256 double]*
>>> *
>>> *
>>> 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:
>>> *mri = ft_read_mri(strcat(h.subject,'Subject01.mri')); % load
>>> 'standard' anatomical model
>>> *
>>> *
>>> *
>>> *% segment the template brain and construct a volume conduction model
>>> (i.e. head model)*
>>> *cfg             = [];*
>>> *cfg.output      = {'brain' 'scalp' 'skull'};*
>>> *cfg.downsample  = 2;*
>>> *t_seg    = ft_volumesegment(cfg, mri);*
>>> * *
>>> *% create head model*
>>> *cfg          = [];*
>>> *cfg.method   = 'singlesphere';*
>>> *cfg.hdmfile  = strcat(h.subject,'Subject01.hdm');*
>>> *cfg.elec     = ft_read_sens('standard_1020.elc');*
>>> *t_vol = ft_prepare_headmodel(cfg, t_seg);*
>>> *clear template_seg*
>>> *
>>> *
>>> *% construct the dipole grid in the template brain coordinates*
>>> *cfg = [];*
>>> *cfg.normalize = 'no'; % no normalization, since we're comparing two
>>> conditions THAT'S RIGHT I DID PAY ATTENTION*
>>> *cfg.vol        = t_vol;*
>>> *t_grid  = ft_prepare_sourcemodel(cfg);*
>>> *
>>> *
>>> 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):
>>> *source{subj}.(datasets{d}) = sourceanalysis(data, t_vol, t_grid);*
>>> *
>>> *
>>> Anyone seeing anything obviously stupid?
>>>
>>> Sincerely,
>>>
>>> Casper
>>>
>>>
>>> On Fri, Jan 18, 2013 at 4:43 PM, <Lilla.Magyari at mpi.nl> wrote:
>>>
>>>> Hi Casper,
>>>>
>>>> I think it is really difficult to figure only from the error message
>>>> what
>>>> the problem is. I think it would be also useful to see the inputs (cfg,
>>>> and your data) of ft_sourceplot. Could you just send me how your cfg and
>>>> your data-structure looks like? (I mean that you do not need to send the
>>>> actual data, just the screen output of disp(data) and disp(cfg)).
>>>>
>>>> Best,
>>>> Lilla
>>>>
>>>>
>>>> > Dear Fieldtrippers,
>>>> >
>>>> > I've asked this question earlier, but either it got lost due to
>>>> technical
>>>> > reasons, or the people who actually understand what's happening here
>>>> were
>>>> > on vacation, so here it is again:
>>>> >
>>>> > I've been trying to do a source analysis on a dataset with two
>>>> conditions,
>>>> > mostly following the tutorials and examples from the Fieldtrip site,
>>>> and
>>>> > come upon a problem; it won't plot. While the source analysis is not
>>>> an
>>>> > essential component of the analysis of this dataset (it's more along
>>>> the
>>>> > lines of "let's see if I can do this"), and I don't expect any result
>>>> > other
>>>> > than something like "there might be a source in the left hemisphere",
>>>> I'd
>>>> > still would like to found out why it's not working.
>>>> >
>>>> > Essentially, I create a standard headmodel cause I don't have
>>>> individual
>>>> > MRI's from the "Subject1.mri"-example, using ft_volumesegment,
>>>> > ft_prepare_headmodel and ft_prepare_sourcemodel, and try to get
>>>> Fieldtrip
>>>> > to find sources based on individual EEG-datasets using ft_freqanalysis
>>>> > (with cfg.method = 'mtmfft') and ft_sourceanalysis.
>>>> > After that, I use ft_sourcegrandaverage to produce, well, a grand
>>>> average
>>>> > source, and feed this via ft_sourceinterpolate to ft_sourceplot.
>>>> >
>>>> > Now, ft_sourceplot has three plotting possibilities: slice, ortho, and
>>>> > surface. Initially I tried to get the ortho-option to work, but this
>>>> gave
>>>> > the following error:
>>>> > *Attempted to access dim(3); index out of bounds because
>>>> numel(dim)=2.*
>>>> > *Error in ==> cornerpoints at 11
>>>> > *
>>>> > *Error in ==> ft_plot_slice at 157
>>>> > *
>>>> >
>>>> > So, I tried the surf-option, which gave me this:
>>>> > *Undefined function or variable "val".*
>>>> > *Error in ==> ft_sourceplot at 1174
>>>> > *
>>>> >
>>>> > And finally, I tried the slice-option, which gave one of two errors
>>>> (which
>>>> > seems to be based on how many slices I requested):
>>>> > *Out of memory*
>>>> > Which is pretty damn impressive since I've got 8GB of RAM and a
>>>> pagefile
>>>> > topping of at 40GB
>>>> > Or, the mildly disconcerting:
>>>> > *Matlab has encountered an internal error and has to close*
>>>> > Which seems to have been caused by a so-called *"Segmentation
>>>> violation"
>>>> > *
>>>> >
>>>> > Can anyone offer any insight in these errors? I think I'm doing
>>>> something
>>>> > wrong pretty early on, but have no idea what it is.
>>>> >
>>>> > Sincerely,
>>>> >
>>>> > Casper van Heck
>>>> >
>>>> >
>>>> > On Fri, Dec 21, 2012 at 1:43 PM, Casper van Heck
>>>> > <caspervanheck at gmail.com>wrote:
>>>> >
>>>> >> Dear Fieldtrippers,
>>>> >>
>>>> >> I've been trying to do a source analysis on a dataset with two
>>>> >> conditions,
>>>> >> mostly following the tutorials and examples from the Fieldtrip site,
>>>> and
>>>> >> come upon a problem; it won't plot. While the source analysis is not
>>>> an
>>>> >> essential component of the analysis of this dataset (it's more along
>>>> the
>>>> >> lines of "let's see if I can do this"), and I don't expect any result
>>>> >> other
>>>> >> than something like "there might be a source in the left hemisphere",
>>>> >> I'd
>>>> >> still would like to found out why it's not working.
>>>> >>
>>>> >> Essentially, I create a standard headmodel cause I don't have
>>>> individual
>>>> >> MRI's from the "Subject1.mri"-example, using ft_volumesegment,
>>>> >> ft_prepare_headmodel and ft_prepare_sourcemodel, and try to get
>>>> >> Fieldtrip
>>>> >> to find sources based on individual EEG-datasets using
>>>> ft_freqanalysis
>>>> >> (with cfg.method = 'mtmfft') and ft_sourceanalysis.
>>>> >> After that, I use ft_sourcegrandaverage to produce, well, a grand
>>>> >> average
>>>> >> source, and feed this via ft_sourceinterpolate to ft_sourceplot.
>>>> >>
>>>> >> Now, ft_sourceplot has three plotting possibilities: slice, ortho,
>>>> and
>>>> >> surface. Initially I tried to get the ortho-option to work, but this
>>>> >> gave
>>>> >> the following error:
>>>> >> *Attempted to access dim(3); index out of bounds because
>>>> numel(dim)=2.*
>>>> >> *Error in ==> cornerpoints at 11
>>>> >> *
>>>> >> *Error in ==> ft_plot_slice at 157
>>>> >> *
>>>> >>
>>>> >> So, I tried the surf-option, which gave me this:
>>>> >> *Undefined function or variable "val".*
>>>> >> *Error in ==> ft_sourceplot at 1174
>>>> >> *
>>>> >>
>>>> >> And finally, I tried the slice-option, which gave one of two errors
>>>> >> (which
>>>> >> seems to be based on how many slices I requested):
>>>> >> *Out of memory*
>>>> >> Which is pretty damn impressive since I've got 8GB of RAM and a
>>>> pagefile
>>>> >> topping of at 40GB
>>>> >> Or, the mildly disconcerting:
>>>> >> *Matlab has encountered an internal error and has to close*
>>>> >> Which seems to have been caused by a so-called *"Segmentation
>>>> violation"
>>>> >> *
>>>> >>
>>>> >> Can anyone offer any insight in these errors? I think I'm doing
>>>> >> something
>>>> >> wrong pretty early on, but have no idea what it is.
>>>> >>
>>>> >> Sincerely,
>>>> >>
>>>> >> Casper van Heck
>>>> >>
>>>> > _______________________________________________
>>>> > fieldtrip mailing list
>>>> > fieldtrip at donders.ru.nl
>>>> > http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>
>>>>
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> fieldtrip at donders.ru.nl
>>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>>
>>>    Jan-Mathijs Schoffelen, MD PhD
>>>
>>> Donders Institute for Brain, Cognition and Behaviour,
>>> Centre for Cognitive Neuroimaging,
>>> Radboud University Nijmegen, The Netherlands
>>>
>>> Max Planck Institute for Psycholinguistics,
>>> Nijmegen, The Netherlands
>>>
>>> J.Schoffelen at donders.ru.nl
>>> Telephone: +31-24-3614793
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> fieldtrip at donders.ru.nl
>>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>
>>
>>
>> _______________________________________________
>> fieldtrip mailing list
>> fieldtrip at donders.ru.nl
>> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130126/ba2ced01/attachment-0001.html>


More information about the fieldtrip mailing list