[FieldTrip] errors replicating Salzburg Fieldtrip tutorial
Irene Varela Leniz
irene.varela at alumni.mondragon.edu
Fri May 24 08:50:25 CEST 2019
Dear all,
I am still working on computing the leadfield using MNI templates to create
ROIs. My recent work has been focused on translating the MEG tutorial to
EEG. Anyway, I am really confused with the results I am obtaining, I have
some concerns and I would be grateful if somebody could help me on this
topic.
1. I started preparing the sourcemodel with a EEG headmodel, using the code
below:
*vol = *
* struct with fields:*
* bnd: [1×3 struct]*
* cond: [0.3300 0.0041 0.3300]*
* mat: [3000×3000 double]*
* type: 'dipoli'*
* unit: 'mm'*
* cfg = []; cfg.grid.xgrid
= [-90 : 5 : 90]; cfg.grid.ygrid =
[-115: 5 : 85]; cfg.grid.zgrid = [-70 : 5 :
100]; cfg.tight = 'yes';
cfg.headmodel = vol; template_grid =
ft_prepare_sourcemodel(cfg); template_grid =
ft_convert_units(template_grid,'mm');*
*template_grid = *
* struct with fields:*
* dim: [29 37 30]*
* pos: [32190×3 double]*
* unit: 'mm'*
* inside: [32190×1 logical]*
* cfg: [1×1 struct]*
And I obtained quite good results:
[image: image.png]
2. Then I use a typical MNI template from Fieldtrip, called ROI_MNI_v4.nii
to create the mask for selecting the ROIs:
atlas =
struct with fields:
dim: [91 109 91]
hdr: [1×1 struct]
transform: [4×4 double]
unit: 'mm'
tissue: [91×109×91 double]
tissuelabel: {1×116 cell}
coordsys: 'mni'
* atlas = ft_read_atlas('ROI_MNI_v4.nii');*
* atlas = ft_convert_units(atlas,'mm');*
* cfg = [];*
* cfg.atlas = atlas;*
* cfg.roi = atlas.tissuelabel; *
* cfg.inputcoord = 'mni';*
* mask = ft_volumelookup(cfg,
template_grid);*
* % create temporary mask according to
the atlas entries*
* tmp = repmat(template_grid.inside,1,1);*
* tmp(tmp==1) = 0;
tmp(mask) = 1; % define inside locations
according to the atlas based mask
template_grid.inside = tmp;*
[image: image.png]
3. After, I computed the sourcemodel using previous templete grid and
standard_mri.mat file.
mri =
struct with fields:
dim: [181 217 181]
xgrid: [1×181 double]
ygrid: [1×217 double]
zgrid: [1×181 double]
anatomy: [181×217×181 uint8]
transform: [4×4 double]
hdr: [1×1 struct]
unit: 'mm'
* mri = ft_read_mri('standard_mri.mat');*
* cfg = [];
cfg.template = template_grid;
cfg.mri = mri; sourcemodel =
ft_prepare_sourcemodel(cfg);*
4. Also used a headmodel:
hdm = ft_read_mri('headmodel_eeg.mat'); %read the
headmodel
hdm = ft_convert_units(hdm, 'mm');
sourcemodel = ft_convert_units(sourcemodel,
'mm');
*hdm = *
* struct with fields:*
* bnd: [1×3 struct]*
* cond: [0.3333 0.0167 0.3333]*
* skin_surface: 3*
* source: 1*
* mat: [1000×6000 double]*
* type: 'bemcp'*
* unit: 'mm'*
* cfg: [1×1 struc*t]
[image: image.png]
But as you can see, I do not match a perfect alineation, I try to apply
volume align using fidutials but that was not the solution. On the other
hand, I am not transforming the electrodes to ROIs I still have electrode
data. What can I do to solve this error?.
5. Finally I compute the leadfield as follows:
*sourcemodel = *
* struct with fields:*
* pos: [7942×3 double]*
* dim: [19 22 19]*
* inside: [7942×1 logical]*
* unit: 'mm'*
* cfg: [1×1 struct]*
* cfg = []; cfg.vol = hdm;
cfg.reducerank = 3; % I am
working with EEG data cfg.sourcemodel =
sourcemodel; leadfield = ft_prepare_leadfield(cfg,
data);*
*leadfield = *
* struct with fields:*
* pos: [7942×3 double]*
* dim: [19 22 19]*
* inside: [7942×1 logical]*
* unit: 'mm'*
* cfg: [1×1 struct]*
* leadfield: {1×7942 cell}*
* label: {128×1 cell}*
* leadfielddimord: '{pos}_chan_ori'*
Thank you very much in advance,
Irene
El jue., 23 may. 2019 a las 11:37, Irene Varela Leniz (<
irene.varela at alumni.mondragon.edu>) escribió:
> Dear Tzvetan,
>
>
> El jue., 23 may. 2019 a las 9:22, Tzvetan Popov (<
> tzvetan.popov at uni-konstanz.de>) escribió:
>
>> Dear Irene,
>> This is not going to work.
>> 1. The headmodel is expressed in units of ‘m’ and aligned to the 4D/bti
>> MEG coordinates. This has nothing to do with your EEG electrode positions.
>> 2. As you already anticipated the type of headmodel is not appropriate
>> for EEG source analysis.
>>
>> I recommend the following:
>> 1. Work out the tutorial with the provided data.
>> 2. Go thru it again and try to internalize the order of the analysis
>> steps.
>> 3. Switch to an EEG source analysis tutorial. Use the provided data there
>> and try to understand the key differences. For example here:
>> http://www.fieldtriptoolbox.org/workshop/natmeg/dipolefitting/
>> Or also here
>> http://www.fieldtriptoolbox.org/workshop/aarhus/beamformingerf/
>> 4. Go back and try to merge the two tutorials to reflect your needs.
>>
>> Good luck
>> Tzvetan
>>
>> Am 23.05.2019 um 08:55 schrieb Irene Varela Leniz <
>> irene.varela at alumni.mondragon.edu>:
>>
>> Dear both,
>>
>> You are right. I thought I was working with the latest version but I did
>> not know that another more recent one had been released on April 19th.
>> Anyway, what I could see investigating inside the function is that they
>> have changed the way to configure the cfg in the function, right?
>>
>> The function is not able to understand the cfg that I am configuring. I
>> must mention that in my case, I am working with EEG, so for example the
>> configuration of lcmv.reducerank I had to change it to 3. Anyway I get the
>> following error related to the cfg:
>>
>> * cfg = [];*
>>
>>
>>
>>
>>
>>
>>
>> * cfg.label = data.label;
>> cfg.elec = data.elec; cfg.vol
>> = hdm; cfg.lcmv.reducerank = 3; % I am working with
>> EEG data cfg.normalize = 'yes'
>> cfg.grid = sourcemodel; [grid] =
>> ft_prepare_leadfield(cfg);*
>>
>>
>> *Error using ft_prepare_leadfield (line 110)*
>>
>> *It seems as if the first input argument is a FieldTrip data structure,
>> while a cfg is expected*
>>
>>
>> I also add information about how the data (EEG), the headmodel and the
>> sourcemodel are:
>>
>> *hdm = *
>>
>> * struct with fields:*
>>
>> * bnd: [1×1 struct]*
>>
>> * type: 'singleshell'*
>>
>> * unit: 'm'*
>>
>> * cfg: [1×1 struct]*
>>
>>
>> *sourcemodel = *
>>
>> * struct with fields:*
>>
>> * pos: [6426×3 double]*
>>
>> * dim: [17 21 18]*
>>
>> * unit: 'm'*
>>
>> * inside: [17×21×18 logical]*
>>
>> * cfg: [1×1 struct]*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *data = struct with fields: hdr: [1×1 struct] trial:
>> {1×69 cell} time: {1×69 cell} elec: [1×1 struct]
>> fsample: 256 label: {128×1 cell} sampleinfo: [69×2 double]
>> cfg: [1×1 struct]*
>>
>> On the other hand, if I'm working with EEG, do you think it makes sense
>> to use files *standard_singleshell.mat*, *atlas ROI_MNI_V4.nii*, *mri.mat
>> *and *hdm.mat* to create the leadfield? Do I need others for EEG?
>>
>> Thank you for your attention.
>>
>> Best wishes,
>>
>> Irene
>>
>>
>> El mié., 22 may. 2019 a las 9:51, Schoffelen, J.M. (Jan Mathijs) (<
>> jan.schoffelen at donders.ru.nl>) escribió:
>>
>>> You are not using the most recent fieldtrip code. See attached
>>> screenshot for a section of ft_checkconfig (which I took from
>>> https://github.com/fieldtrip/fieldtrip (utilities/ft_checkconfig.m)
>>>
>>> The error message in your earlier e-mail pointed to line 529.
>>>
>>> Jan-Mathijs
>>>
>>>
>>>
>>> <Screen Shot 2019-05-22 at 09.48.49.png>
>>>
>>> On 22 May 2019, at 09:42, Irene Varela Leniz <
>>> irene.varela at alumni.mondragon.edu> wrote:
>>>
>>> Dear Shoffelen,
>>>
>>> I am working with last Fieldtrip and MATLAB version so I'm afraid that's
>>> not the problem.
>>>
>>> Best wishes,
>>>
>>> Irene
>>>
>>> El mié., 22 may. 2019 a las 9:38, Schoffelen, J.M. (Jan Mathijs) (<
>>> jan.schoffelen at donders.ru.nl>) escribió:
>>>
>>>> Hi Irene,
>>>>
>>>> Please check which version of the code you are using, and update to a
>>>> more recent version to FieldTrip, and try again. The line + error you
>>>> report does not match the ones in the current version of Fieldtrip.
>>>>
>>>> Best wishes,
>>>> Jan-Mathijs
>>>>
>>>>
>>>>
>>>> On 22 May 2019, at 09:21, Irene Varela Leniz <
>>>> irene.varela at alumni.mondragon.edu> wrote:
>>>>
>>>> Dear Fieldtripers,
>>>>
>>>> I am trying to replicate the well-known *tutorial:salzburg [FielTrip]
>>>> (*http://old.fieldtriptoolbox.org/tutorial/salzburg). Anyway, I am
>>>> getting some errors that I could not manage to solve. I would be really
>>>> grateful if someone could lend me a hand.
>>>>
>>>> I am working on section called "Localizing auditory evoked fields
>>>> using beamforming techniques in parceled brain space". I managed to
>>>> compute the *sourcemode*l as explained in the tutorial without any
>>>> problem. But now, when "Computing the leadfield" I get an error message
>>>> related with *sourcemodel.inside *field, which makes it impossible for
>>>> me to create the leadfield. The structure is the following:
>>>>
>>>> *sourcemodel = *
>>>>
>>>> * struct with fields:*
>>>>
>>>> * pos: [6426×3 double]*
>>>>
>>>> * dim: [17 21 18]*
>>>>
>>>> * unit: 'm'*
>>>>
>>>> * inside: [17×21×18 logical]*
>>>>
>>>> * cfg: [1×1 struct]*
>>>>
>>>>
>>>> The structure for computing the leadfield:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> * cfg = []; cfg.label
>>>> = data.label; cfg.elec = data.elec;
>>>> cfg.vol = hdm;
>>>> cfg.lcmv.reducerank = 2; % I am working with EEG data
>>>> cfg.grid = sourcemodel; [grid] =
>>>> ft_prepare_leadfield(cfg)*
>>>>
>>>>
>>>> An the error I get:
>>>>
>>>>
>>>> Operands to the || and && operators must be convertible to logical
>>>> scalar values.
>>>>
>>>>
>>>> Error in ft_checkconfig (line 529)
>>>>
>>>> elseif isfield(cfg, 'grid') && isfield(cfg.grid, 'inside') &&
>>>> any(cfg.grid.inside>1)
>>>>
>>>>
>>>> Error in ft_prepare_leadfield (line 156)
>>>>
>>>> cfg = ft_checkconfig(cfg, 'inside2logical', 'yes');
>>>>
>>>> I think the error comes from the fact that *sourcemodel.inside* is a
>>>> 3-dimensional logical array. The operation - any(cfg.grid.inside>1) does
>>>> not output a logical scalar value because* sourcemodel.inside* is in 3
>>>> dimensions.
>>>> So far I have always worked with models whose inside parameter was of
>>>> one dimension. Anyway, I'm not sure if this is the problem, please correct
>>>> me if I'm wrong.
>>>>
>>>> Has anyone encountered this same problem, and does anyone know how to
>>>> fix it?
>>>>
>>>> Thank you very much for your attention,
>>>>
>>>>
>>>> Irene
>>>>
>>>>
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>> https://doi.org/10.1371/journal.pcbi.1002202
>>>>
>>>>
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>>> https://doi.org/10.1371/journal.pcbi.1002202
>>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>> https://doi.org/10.1371/journal.pcbi.1002202
>>>
>>>
>>> _______________________________________________
>>> fieldtrip mailing list
>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>>> https://doi.org/10.1371/journal.pcbi.1002202
>>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>> https://doi.org/10.1371/journal.pcbi.1002202
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190524/2606f872/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 33206 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190524/2606f872/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 160290 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190524/2606f872/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 76377 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190524/2606f872/attachment-0008.png>
-------------- next part --------------
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202
More information about the fieldtrip
mailing list