From nea26 at cam.ac.uk  Thu Apr  2 13:48:15 2020
From: nea26 at cam.ac.uk (Dr N.E. Adams)
Date: Thu, 02 Apr 2020 12:48:15 +0100
Subject: [FieldTrip] MEG source-model warp query
In-Reply-To: <3177cc177833f08496b47c6455f49284@cam.ac.uk>
References: <3177cc177833f08496b47c6455f49284@cam.ac.uk>
Message-ID: <43205a26ae41a9ad8a2a75cf1d84f3ab@cam.ac.uk>

Dear community experts

I hope you're all doing well! I am new to fieldtrip and I'm struggling 
to see how to get a sourcemodel that I can match directly to an atlas. 
I'm working with MEG data. In short, currently:

a) I generate a template grid
b) I constrain that grid by vertices found within an AAL atlas
c) I use this constrained template grid to create a sourcemodel for each 
individual's MEG-coregistered MRI using 'warpmni' in the config.

However, no warp process appears to affect the result - only a standard 
geometric transformation using an affine (translation and rotation), so 
I believe I'm either doing something wrong or missing a vital step. 
Debugging through ft_prepare_sourcemodel I find, from this line:...

sourcemodel.pos = ft_warp_apply(inv(normalise.initial), 
ft_warp_apply(normalise.params, mnigrid.pos, 'sn2individual'));

... that it first normalises (which I assume actually *is* a warp) the 
individual's mri (variable = normalise), transforms the template grid 
(variable = mnigrid) by the normed mri affine (note: doesn't use this to 
warp the grid, just transforms it), and then transforms that result by 
the non-normed mri.

1) I'm curious, why does it do this in two stages? i.e. why not just 
transform the template grid straight to the mri affine? What is the use 
of the normalised mri affine in the intermediary step, as it doesn't use 
the warp itself, just the affine?

2) The sourcemodel needs to be in the individual's native shape in order 
to do the source-reconstruction correctly. By changing my template 
construction method, I can create a grid that has complete coverage of 
the individual's brain (and is unrelated to the atlas). However, the 
atlas is in a standard shape so I can't match such source vertices to it 
unless I can either:
     - warp the standard shape atlas to the individual's brain or
     - make a version of the sourcemodel where it's vertices have been 
warped to the atlas shape, so that when I have used the original 
sourcemodel to source-reconstruct my data, I can use the warped 
sourcemodel to know where each vertex is in the atlas.

I have considered that this might be what ft_source_interpolate is for, 
but I've not managed to understand what it's doing, or even understand 
if I'm giving it the right information. For instance, using:...

interp = ft_sourceinterpolate(cfg, atlas, sourcemodel);

... produces a structure that looks a lot like the atlas, and contains 
what appears to be nonsense! :) When what I'd like to see from it is the 
sourcemodel grid warped to the shape of the atlas. - How would I get 
this?

I have attached some of my relevant code in the .txt file for you to 
peruse.

Thanks
Tallie
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sourcemodel to atlas - fieldtrip query.txt
Type: text/x-c++
Size: 6069 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200402/56d50e67/attachment.bin>

From ecaspar at ulb.ac.be  Thu Apr  2 17:33:00 2020
From: ecaspar at ulb.ac.be (Emilie Caspar)
Date: Thu, 2 Apr 2020 17:33:00 +0200
Subject: [FieldTrip] ft_sourcemovie - producing 'contemporary art'
 instead of a brain
In-Reply-To: <CABPNLUooq6DXdvBZabmWGcG0T0wDrF65+YGykG0qY=Vchaa+hw@mail.gmail.com>
References: <B7A355FC-6AFF-496E-94EE-485D44429D28@ulb.ac.be>
 <C3B27185-3A5B-4CCB-A846-7DA76498A063@donders.ru.nl>
 <CABPNLUooq6DXdvBZabmWGcG0T0wDrF65+YGykG0qY=Vchaa+hw@mail.gmail.com>
Message-ID: <252CC2F3-58A2-4B50-9FB9-72D48D3816C4@ulb.ac.be>

Dear Elke and Jan-Mathijs,

Thank you for your answers. So indeed I now understand the problem, but I still have issues to solve that problem. It’s probably something simple to solve but I do not find it. Basically, I have now tried to use the ft_sourceinterpolate, as suggested. As far as I understand, this has to be done after the ft_sourceanalysis. However, I constantly have an issue with cfg_parameters, which should be the positions of the electrodes. I run the following code (full code below):

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)
 
I get the following error message: "Reference to non-existent field 'elec’. », which I do not get since I do have my ‘elec’ file which is indeed opened, with a .chanpos that contains the positions of the electrodes. 

Perhaps I am doing something wrong with ft_sourceinterpolate. But in fact I am also worried about the fact that the file which results from the ft_sourceanalysis has lots of NaN (see screenshot in attachement) and I am not sure it should be the case or if I should have obtained full data in each case. From the tutorials, the source model have a .tri but I don’t have one in the source model I have created. Perhaps it may also be the source of the issue?

Thank you in advance for your time!

Emilie




load biosemi64.mat
q=angles;
 
ph = cell2mat(q(:,2));
th = cell2mat(q(:,3));
x = sin(ph*pi/180) .* cos(th*pi/180);
y = sin(ph*pi/180) .* sin(th*pi/180);
z = cos(ph*pi/180);
 
plot3(x, y, z, '.');
elec.label = q(:,1);
elec.pnt = [x y z];
 
cfg.sourcemodel.pos = elec.pnt;
sourcemodel = ft_prepare_sourcemodel(cfg);
 
headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
%electr_pos=ft_read_sens('Biosemi-Cap64.sfp');
 
%% realign electrodes to headmodel
cfg = [];
cfg.method = 'interactive';
cfg.elec = elec;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg);
 
%save new electrodes
save elec64.mat elec
 
%ERPsAll.elec = ft_read_sens('Biosemi-Cap64.sfp');
 
% Prepare leadfield
cfg                 = [];
cfg.elec            = elec;
cfg.headmodel             = headmodel;
cfg.reducerank      = 3;
cfg.resolution = 1;   % use a 3-D grid with a 1 cm resolution
cfg.sourcemodel.unit       = 'cm';
cfg.channel ={'all'};
leadfield = ft_prepare_leadfield(cfg);
 
%% mne
cfg              = [];
cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
cfg.elec         = elec; %grid.cfg.elec;%
cfg.headmodel          = headmodel;
cfg.grid = leadfield;
%cfg.sourcemodel = sourcemodel;
% cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
%cfg.reducerank          = 2;
 
source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)
 

cfg = [];
cfg.projectmom = 'yes';
sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);
 
sdDIFF         = sdNoShock;
sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
 
save sd sdDIFF;
 
cfg = [];
cfg.funparameter = 'pow';
ft_sourcemovie(cfg,sdDIFF);



---------------------------------------------
Emilie Caspar, Ph.D
 
CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB 
Voice : +32 2 650 32 95 
mail : ecaspar at ulb.ac.be
office: DB10-138 

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl

> Le 31 mars 2020 à 12:02, Eelke Spaak <e.spaak at donders.ru.nl> a écrit :
> 
> Hi Emilie,
> 
> To add to Jan-Mathijs' explanation of why this does not work: you can
> use ft_sourceinterpolate to interpolate your volumetric source data
> onto a surface, which you can then plot using ft_sourcemovie (or the
> newer, though still somewhat experimental, ft_sourceplot_interactive).
> 
> Best,
> Eelke
> 
> On Tue, 31 Mar 2020 at 11:07, Schoffelen, J.M. (Jan Mathijs)
> <jan.schoffelen at donders.ru.nl> wrote:
>> 
>> Hi Emilie,
>> 
>> ft_sourcemovie has been designed to operate on source level data that is defined on a cortical surface based source model.
>> The code you pasted in suggests that you used a 3-dimensional grid as a sourcemodel. So this is never going to work.
>> Apparently, you managed to fool the function by post-hoc including a so-called ’tri’ field, which is the hallmark that fieldtrip uses to determine whether the sourcemodel geometry was a mesh or not.
>> However, there is no relation whatsoever between the specified triangulation (which you took from the headmodel) and the dipole positions at which your source activity has been estimated.
>> 
>> Best wishes,
>> Jan-Mathijs
>> 
>> 
>> On 31 Mar 2020, at 10:42, Emilie Caspar <ecaspar at ulb.ac.be> wrote:
>> 
>> Dear all,
>> 
>> I am trying to compute a source reconstruction of different ERPs between two experimental conditions. Well, good news is that the script ‘works’, but the issue is that I am producing contemporary art instead of a brain with ft_sourcemovie (see figure in attachement). The headmodel I used is the standard one available for download. The leadfield I built seems to look like a brain with a correct positions of the electrodes (see also figure in attachement).
>> 
>> I really have no cue about how I produced such output with ft_sourcemovie and what could possibly be the issue (code is below). If someone can help transforming this to a brain? ;-)
>> The only thing that differs (I think) from the tutorial is that I don’t have a headmodel.tri but rather a headmodel.bnd.tri. Don’t know if it makes any difference. Perhaps the sourcespace defined in the tutorial is something different?
>> 
>> Thank you,
>> 
>> Emilie
>> 
>> <ft_sourcemovie.png><leadfield.png><ft_plot_mesh.png>
>> 
>> CODE
>> 
>> q=biosim64;
>> ph = cell2mat(q(:,2));
>> th = cell2mat(q(:,3));
>> x = sin(ph*pi/180) .* cos(th*pi/180);
>> y = sin(ph*pi/180) .* sin(th*pi/180);
>> z = cos(ph*pi/180);
>> 
>> plot3(x, y, z, '.');
>> elec.label = q(:,1);
>> elec.pnt = [x y z];
>> 
>> cfg.sourcemodel.pos = elec.pnt;
>> sourcemodel = ft_prepare_sourcemodel(cfg);
>> 
>> headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
>> 
>> % realign electrodes to headmodel
>> cfg = [];
>> cfg.method = 'interactive';
>> cfg.elec = elec;
>> cfg.headshape = headmodel.bnd(1); %1 = skin
>> elec = ft_electroderealign(cfg);
>> 
>> %save new electrodes
>> save elec64.mat elec
>> 
>> ERPsAll.elec = ft_read_sens('elec64.mat’);
>> 
>> % Prepare leadfield
>> cfg                 = [];
>> cfg.elec            = ERPsAll.elec;
>> cfg.vol             = headmodel;
>> cfg.reducerank      = 3;
>> cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
>> cfg.grid.unit       = 'cm';
>> cfg.channel ={'all'};
>> leadfield = ft_prepare_leadfield(cfg);
>> 
>> 
>> 
>> %%mne
>> cfg              = [];
>> cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
>> cfg.elec         = ERPsAll.elec; %grid.cfg.elec;%
>> cfg.headmodel          = headmodel;
>> cfg.grid = leadfield;
>> %cfg.sourcemodel = sourcemodel;
>> % cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
>> cfg.mne.prewhiten = 'yes';
>> cfg.mne.lambda    = 3;
>> cfg.mne.scalesourcecov = 'yes';
>> %cfg.reducerank          = 2;
>> 
>> source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
>> source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);
>> 
>> save source_C_Shock.mat source_C_Shock
>> save source_C_Noshock.mat source_C_Noshock
>> 
>> bnd.pos = headmodel.bnd.pos;
>> bnd.tri = headmodel.bnd.tri;
>> 
>> m=source_C_Shock.avg.pow(:,450);
>> %timeN1 = [1232:1301];timeP3 = [1722:1927];timeeLPP = [1928:2356];timelLPP = [2357:2868];
>> ft_plot_mesh(bnd, 'vertexcolor', m);
>> view([180 0]); h = light; set(h, 'position', [0 1 0.2]); lighting gouraud; material dull
>> 
>> cfg = [];
>> cfg.projectmom = 'yes';
>> sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
>> sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);
>> 
>> sdDIFF         = sdNoShock;
>> sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
>> sdDIFF.tri = headmodel.bnd.tri;
>> 
>> save sd sdDIFF;
>> 
>> cfg = [];
>> cfg.funparameter = 'pow';
>> %cfg.method       = 'surface';
>> ft_sourcemovie(cfg,sdDIFF);
>> 
>> 
>> ---------------------------------------------
>> Emilie Caspar, Ph.D
>> 
>> CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
>> Voice : +32 2 650 32 95
>> mail : ecaspar at ulb.ac.be
>> office: DB10-138
>> 
>> Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
>> mail : e.caspar at nin.knaw.nl
>> 
>> _______________________________________________
>> 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/20200402/8269e5d7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NaN.png
Type: image/png
Size: 284872 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200402/8269e5d7/attachment.png>

From huiyu_kang at fudan.edu.cn  Fri Apr  3 03:16:59 2020
From: huiyu_kang at fudan.edu.cn (=?utf-8?Q?huiyu=5Fkang?=)
Date: Fri, 3 Apr 2020 09:16:59 +0800
Subject: [FieldTrip] =?utf-8?q?Post-doc_Positions_=7C_Neural_and_Intellig?=
 =?utf-8?q?ence_Engineering_Center=2C_Institute_of_Science_and_Technology_?=
 =?utf-8?q?for_Brain-inspired_Intelligence?=
Message-ID: <29EAC6E8-0B89-4660-9F47-F58DD67A5FF0@fudan.edu.cn>

An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200403/c7b30c99/attachment.htm>

From jan.schoffelen at donders.ru.nl  Fri Apr  3 19:02:26 2020
From: jan.schoffelen at donders.ru.nl (Schoffelen, J.M. (Jan Mathijs))
Date: Fri, 3 Apr 2020 17:02:26 +0000
Subject: [FieldTrip] ft_sourcemovie - producing 'contemporary art'
 instead of a brain
In-Reply-To: <252CC2F3-58A2-4B50-9FB9-72D48D3816C4@ulb.ac.be>
References: <B7A355FC-6AFF-496E-94EE-485D44429D28@ulb.ac.be>
 <C3B27185-3A5B-4CCB-A846-7DA76498A063@donders.ru.nl>
 <CABPNLUooq6DXdvBZabmWGcG0T0wDrF65+YGykG0qY=Vchaa+hw@mail.gmail.com>
 <252CC2F3-58A2-4B50-9FB9-72D48D3816C4@ulb.ac.be>
Message-ID: <0C841ED8-4315-4F71-B12F-1D4DAFE01F5A@donders.ru.nl>

Hi Emilie,

Hmmm, a few pointers:

Yes, it seems that you are expecting something from ft_sourceinterpolate that the function cannot deliver. In the pasted code you specify that you want to interpolate the parameter ‘elec.chanpos’. This is incorrect. If anything, you can only meaningfully interpolate parameters that are defined with a scalar per source dipole position, and in addition only using fields in a structure that are available in the input data structure. since source_C_Shock by construction should not contain an elec field, this is never going to work. In addition, the elec.chanpos field does not map onto the source dipole positions, so this is the second reason why this is never going to work.
Also, if I am not mistaken ft_sourceinterpoalte cannot deal with data that are vectors (e.g. source activity time courses) for each source position, so even if you would specify cfg.parameter to be ‘pow’, or ‘avg.pow’ this will probably not work.

Once again, indeed the tutorial mentions the ’tri’ field as a prerequisite to be able to visualize data in ft_sourcemovie. Since you created your sourcemodel to be a 3D grid, which is volumetric in nature, and not the expected surface description (that is based on a combination of vertex positions (in fieldtrip speak: pos) and faces (in fieldtrip speak: tri)) the visualization you wish for does not work. Hence Eelke’s suggestion to use ft_sourceinterpolate first, which I question as per my comment above.

Besides, in general I would recommend against using a 3D grid as a sourcemodel when using a distributed inverse modelling approach. The reason for this is that activity is going to be ‘mapped’ onto locations that does not make sense a priori (white matter).

Finally, your current results containing a lot of NaNs is perfectly fine, since this corresponds to source dipole locations that lie outside the volume of interest, i.e. outside the head.

Best wishes,
Jan-Mathijs


On 2 Apr 2020, at 17:33, Emilie Caspar <ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>> wrote:

Dear Elke and Jan-Mathijs,

Thank you for your answers. So indeed I now understand the problem, but I still have issues to solve that problem. It’s probably something simple to solve but I do not find it. Basically, I have now tried to use the ft_sourceinterpolate, as suggested. As far as I understand, this has to be done after the ft_sourceanalysis. However, I constantly have an issue with cfg_parameters, which should be the positions of the electrodes. I run the following code (full code below):

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)

I get the following error message: "Reference to non-existent field 'elec’. », which I do not get since I do have my ‘elec’ file which is indeed opened, with a .chanpos that contains the positions of the electrodes.

Perhaps I am doing something wrong with ft_sourceinterpolate. But in fact I am also worried about the fact that the file which results from the ft_sourceanalysis has lots of NaN (see screenshot in attachement) and I am not sure it should be the case or if I should have obtained full data in each case. From the tutorials, the source model have a .tri but I don’t have one in the source model I have created. Perhaps it may also be the source of the issue?

Thank you in advance for your time!

Emilie

<NaN.png>


load biosemi64.mat
q=angles;

ph = cell2mat(q(:,2));
th = cell2mat(q(:,3));
x = sin(ph*pi/180) .* cos(th*pi/180);
y = sin(ph*pi/180) .* sin(th*pi/180);
z = cos(ph*pi/180);

plot3(x, y, z, '.');
elec.label = q(:,1);
elec.pnt = [x y z];

cfg.sourcemodel.pos = elec.pnt;
sourcemodel = ft_prepare_sourcemodel(cfg);

headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
%electr_pos=ft_read_sens('Biosemi-Cap64.sfp');

%% realign electrodes to headmodel
cfg = [];
cfg.method = 'interactive';
cfg.elec = elec;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg);

%save new electrodes
save elec64.mat elec

%ERPsAll.elec = ft_read_sens('Biosemi-Cap64.sfp');

% Prepare leadfield
cfg                 = [];
cfg.elec            = elec;
cfg.headmodel             = headmodel;
cfg.reducerank      = 3;
cfg.resolution = 1;   % use a 3-D grid with a 1 cm resolution
cfg.sourcemodel.unit       = 'cm';
cfg.channel ={'all'};
leadfield = ft_prepare_leadfield(cfg);



%% mne
cfg              = [];
cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
cfg.elec         = elec; %grid.cfg.elec;%
cfg.headmodel          = headmodel;
cfg.grid = leadfield;
%cfg.sourcemodel = sourcemodel;
% cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
%cfg.reducerank          = 2;

source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)


cfg = [];
cfg.projectmom = 'yes';
sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);

sdDIFF         = sdNoShock;
sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;

save sd sdDIFF;

cfg = [];
cfg.funparameter = 'pow';
ft_sourcemovie(cfg,sdDIFF);



---------------------------------------------
Emilie Caspar, Ph.D

CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
Voice : +32 2 650 32 95
mail : ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>
office: DB10-138

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl<mailto:e.caspar at nin.knaw.nl>

Le 31 mars 2020 à 12:02, Eelke Spaak <e.spaak at donders.ru.nl<mailto:e.spaak at donders.ru.nl>> a écrit :

Hi Emilie,

To add to Jan-Mathijs' explanation of why this does not work: you can
use ft_sourceinterpolate to interpolate your volumetric source data
onto a surface, which you can then plot using ft_sourcemovie (or the
newer, though still somewhat experimental, ft_sourceplot_interactive).

Best,
Eelke

On Tue, 31 Mar 2020 at 11:07, Schoffelen, J.M. (Jan Mathijs)
<jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> wrote:

Hi Emilie,

ft_sourcemovie has been designed to operate on source level data that is defined on a cortical surface based source model.
The code you pasted in suggests that you used a 3-dimensional grid as a sourcemodel. So this is never going to work.
Apparently, you managed to fool the function by post-hoc including a so-called ’tri’ field, which is the hallmark that fieldtrip uses to determine whether the sourcemodel geometry was a mesh or not.
However, there is no relation whatsoever between the specified triangulation (which you took from the headmodel) and the dipole positions at which your source activity has been estimated.

Best wishes,
Jan-Mathijs


On 31 Mar 2020, at 10:42, Emilie Caspar <ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>> wrote:

Dear all,

I am trying to compute a source reconstruction of different ERPs between two experimental conditions. Well, good news is that the script ‘works’, but the issue is that I am producing contemporary art instead of a brain with ft_sourcemovie (see figure in attachement). The headmodel I used is the standard one available for download. The leadfield I built seems to look like a brain with a correct positions of the electrodes (see also figure in attachement).

I really have no cue about how I produced such output with ft_sourcemovie and what could possibly be the issue (code is below). If someone can help transforming this to a brain? ;-)
The only thing that differs (I think) from the tutorial is that I don’t have a headmodel.tri but rather a headmodel.bnd.tri. Don’t know if it makes any difference. Perhaps the sourcespace defined in the tutorial is something different?

Thank you,

Emilie

<ft_sourcemovie.png><leadfield.png><ft_plot_mesh.png>

CODE

q=biosim64;
ph = cell2mat(q(:,2));
th = cell2mat(q(:,3));
x = sin(ph*pi/180) .* cos(th*pi/180);
y = sin(ph*pi/180) .* sin(th*pi/180);
z = cos(ph*pi/180);

plot3(x, y, z, '.');
elec.label = q(:,1);
elec.pnt = [x y z];

cfg.sourcemodel.pos = elec.pnt;
sourcemodel = ft_prepare_sourcemodel(cfg);

headmodel = ft_read_headmodel('headmodel/standard_bem.mat');

% realign electrodes to headmodel
cfg = [];
cfg.method = 'interactive';
cfg.elec = elec;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg);

%save new electrodes
save elec64.mat elec

ERPsAll.elec = ft_read_sens('elec64.mat’);

% Prepare leadfield
cfg                 = [];
cfg.elec            = ERPsAll.elec;
cfg.vol             = headmodel;
cfg.reducerank      = 3;
cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
cfg.grid.unit       = 'cm';
cfg.channel ={'all'};
leadfield = ft_prepare_leadfield(cfg);



%%mne
cfg              = [];
cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
cfg.elec         = ERPsAll.elec; %grid.cfg.elec;%
cfg.headmodel          = headmodel;
cfg.grid = leadfield;
%cfg.sourcemodel = sourcemodel;
% cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
%cfg.reducerank          = 2;

source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

save source_C_Shock.mat source_C_Shock
save source_C_Noshock.mat source_C_Noshock

bnd.pos = headmodel.bnd.pos;
bnd.tri = headmodel.bnd.tri;

m=source_C_Shock.avg.pow(:,450);
%timeN1 = [1232:1301];timeP3 = [1722:1927];timeeLPP = [1928:2356];timelLPP = [2357:2868];
ft_plot_mesh(bnd, 'vertexcolor', m);
view([180 0]); h = light; set(h, 'position', [0 1 0.2]); lighting gouraud; material dull

cfg = [];
cfg.projectmom = 'yes';
sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);

sdDIFF         = sdNoShock;
sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
sdDIFF.tri = headmodel.bnd.tri;

save sd sdDIFF;

cfg = [];
cfg.funparameter = 'pow';
%cfg.method       = 'surface';
ft_sourcemovie(cfg,sdDIFF);


---------------------------------------------
Emilie Caspar, Ph.D

CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
Voice : +32 2 650 32 95
mail : ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>
office: DB10-138

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl<mailto:e.caspar at nin.knaw.nl>

_______________________________________________
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/20200403/15fdec57/attachment.htm>

From saeedzahran at hotmail.com  Sat Apr  4 13:39:40 2020
From: saeedzahran at hotmail.com (Saeed Zahran)
Date: Sat, 4 Apr 2020 11:39:40 +0000
Subject: [FieldTrip] Forward model
In-Reply-To: <mailman.9.1585994402.9067.fieldtrip@science.ru.nl>
References: <mailman.9.1585994402.9067.fieldtrip@science.ru.nl>
Message-ID: <BN3PR01MB2051194898682D1FE771686BB7C40@BN3PR01MB2051.prod.exchangelabs.com>

Hello,

Is there here someone solve the forward model with OPM-MEG sensors with 3 axis measurement in fieldtrip?

Thank you

Best regards
Saeed ZAHRAN

________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of fieldtrip-request at science.ru.nl <fieldtrip-request at science.ru.nl>
Sent: Saturday, April 4, 2020 1:00 PM
To: fieldtrip at science.ru.nl <fieldtrip at science.ru.nl>
Subject: fieldtrip Digest, Vol 113, Issue 4

Send fieldtrip mailing list submissions to
        fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
        https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
or, via email, send a message with subject or body 'help' to
        fieldtrip-request at science.ru.nl

You can reach the person managing the list at
        fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."


Today's Topics:

   1. Re: ft_sourcemovie - producing 'contemporary art' instead of
      a brain (Schoffelen, J.M. (Jan Mathijs))


----------------------------------------------------------------------

Message: 1
Date: Fri, 3 Apr 2020 17:02:26 +0000
From: "Schoffelen, J.M. (Jan Mathijs)" <jan.schoffelen at donders.ru.nl>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] ft_sourcemovie - producing 'contemporary art'
        instead of a brain
Message-ID: <0C841ED8-4315-4F71-B12F-1D4DAFE01F5A at donders.ru.nl>
Content-Type: text/plain; charset="utf-8"

Hi Emilie,

Hmmm, a few pointers:

Yes, it seems that you are expecting something from ft_sourceinterpolate that the function cannot deliver. In the pasted code you specify that you want to interpolate the parameter ‘elec.chanpos’. This is incorrect. If anything, you can only meaningfully interpolate parameters that are defined with a scalar per source dipole position, and in addition only using fields in a structure that are available in the input data structure. since source_C_Shock by construction should not contain an elec field, this is never going to work. In addition, the elec.chanpos field does not map onto the source dipole positions, so this is the second reason why this is never going to work.
Also, if I am not mistaken ft_sourceinterpoalte cannot deal with data that are vectors (e.g. source activity time courses) for each source position, so even if you would specify cfg.parameter to be ‘pow’, or ‘avg.pow’ this will probably not work.

Once again, indeed the tutorial mentions the ’tri’ field as a prerequisite to be able to visualize data in ft_sourcemovie. Since you created your sourcemodel to be a 3D grid, which is volumetric in nature, and not the expected surface description (that is based on a combination of vertex positions (in fieldtrip speak: pos) and faces (in fieldtrip speak: tri)) the visualization you wish for does not work. Hence Eelke’s suggestion to use ft_sourceinterpolate first, which I question as per my comment above.

Besides, in general I would recommend against using a 3D grid as a sourcemodel when using a distributed inverse modelling approach. The reason for this is that activity is going to be ‘mapped’ onto locations that does not make sense a priori (white matter).

Finally, your current results containing a lot of NaNs is perfectly fine, since this corresponds to source dipole locations that lie outside the volume of interest, i.e. outside the head.

Best wishes,
Jan-Mathijs


On 2 Apr 2020, at 17:33, Emilie Caspar <ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>> wrote:

Dear Elke and Jan-Mathijs,

Thank you for your answers. So indeed I now understand the problem, but I still have issues to solve that problem. It’s probably something simple to solve but I do not find it. Basically, I have now tried to use the ft_sourceinterpolate, as suggested. As far as I understand, this has to be done after the ft_sourceanalysis. However, I constantly have an issue with cfg_parameters, which should be the positions of the electrodes. I run the following code (full code below):

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)

I get the following error message: "Reference to non-existent field 'elec’. », which I do not get since I do have my ‘elec’ file which is indeed opened, with a .chanpos that contains the positions of the electrodes.

Perhaps I am doing something wrong with ft_sourceinterpolate. But in fact I am also worried about the fact that the file which results from the ft_sourceanalysis has lots of NaN (see screenshot in attachement) and I am not sure it should be the case or if I should have obtained full data in each case. From the tutorials, the source model have a .tri but I don’t have one in the source model I have created. Perhaps it may also be the source of the issue?

Thank you in advance for your time!

Emilie

<NaN.png>


load biosemi64.mat
q=angles;

ph = cell2mat(q(:,2));
th = cell2mat(q(:,3));
x = sin(ph*pi/180) .* cos(th*pi/180);
y = sin(ph*pi/180) .* sin(th*pi/180);
z = cos(ph*pi/180);

plot3(x, y, z, '.');
elec.label = q(:,1);
elec.pnt = [x y z];

cfg.sourcemodel.pos = elec.pnt;
sourcemodel = ft_prepare_sourcemodel(cfg);

headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
%electr_pos=ft_read_sens('Biosemi-Cap64.sfp');

%% realign electrodes to headmodel
cfg = [];
cfg.method = 'interactive';
cfg.elec = elec;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg);

%save new electrodes
save elec64.mat elec

%ERPsAll.elec = ft_read_sens('Biosemi-Cap64.sfp');

% Prepare leadfield
cfg                 = [];
cfg.elec            = elec;
cfg.headmodel             = headmodel;
cfg.reducerank      = 3;
cfg.resolution = 1;   % use a 3-D grid with a 1 cm resolution
cfg.sourcemodel.unit       = 'cm';
cfg.channel ={'all'};
leadfield = ft_prepare_leadfield(cfg);



%% mne
cfg              = [];
cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
cfg.elec         = elec; %grid.cfg.elec;%
cfg.headmodel          = headmodel;
cfg.grid = leadfield;
%cfg.sourcemodel = sourcemodel;
% cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
%cfg.reducerank          = 2;

source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

cfg = [];
cfg.parameter = 'elec.chanpos';
cfg.interpmethod  = 'nearest';
interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)


cfg = [];
cfg.projectmom = 'yes';
sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);

sdDIFF         = sdNoShock;
sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;

save sd sdDIFF;

cfg = [];
cfg.funparameter = 'pow';
ft_sourcemovie(cfg,sdDIFF);



---------------------------------------------
Emilie Caspar, Ph.D

CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
Voice : +32 2 650 32 95
mail : ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>
office: DB10-138

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl<mailto:e.caspar at nin.knaw.nl>

Le 31 mars 2020 à 12:02, Eelke Spaak <e.spaak at donders.ru.nl<mailto:e.spaak at donders.ru.nl>> a écrit :

Hi Emilie,

To add to Jan-Mathijs' explanation of why this does not work: you can
use ft_sourceinterpolate to interpolate your volumetric source data
onto a surface, which you can then plot using ft_sourcemovie (or the
newer, though still somewhat experimental, ft_sourceplot_interactive).

Best,
Eelke

On Tue, 31 Mar 2020 at 11:07, Schoffelen, J.M. (Jan Mathijs)
<jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>> wrote:

Hi Emilie,

ft_sourcemovie has been designed to operate on source level data that is defined on a cortical surface based source model.
The code you pasted in suggests that you used a 3-dimensional grid as a sourcemodel. So this is never going to work.
Apparently, you managed to fool the function by post-hoc including a so-called ’tri’ field, which is the hallmark that fieldtrip uses to determine whether the sourcemodel geometry was a mesh or not.
However, there is no relation whatsoever between the specified triangulation (which you took from the headmodel) and the dipole positions at which your source activity has been estimated.

Best wishes,
Jan-Mathijs


On 31 Mar 2020, at 10:42, Emilie Caspar <ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>> wrote:

Dear all,

I am trying to compute a source reconstruction of different ERPs between two experimental conditions. Well, good news is that the script ‘works’, but the issue is that I am producing contemporary art instead of a brain with ft_sourcemovie (see figure in attachement). The headmodel I used is the standard one available for download. The leadfield I built seems to look like a brain with a correct positions of the electrodes (see also figure in attachement).

I really have no cue about how I produced such output with ft_sourcemovie and what could possibly be the issue (code is below). If someone can help transforming this to a brain? ;-)
The only thing that differs (I think) from the tutorial is that I don’t have a headmodel.tri but rather a headmodel.bnd.tri. Don’t know if it makes any difference. Perhaps the sourcespace defined in the tutorial is something different?

Thank you,

Emilie

<ft_sourcemovie.png><leadfield.png><ft_plot_mesh.png>

CODE

q=biosim64;
ph = cell2mat(q(:,2));
th = cell2mat(q(:,3));
x = sin(ph*pi/180) .* cos(th*pi/180);
y = sin(ph*pi/180) .* sin(th*pi/180);
z = cos(ph*pi/180);

plot3(x, y, z, '.');
elec.label = q(:,1);
elec.pnt = [x y z];

cfg.sourcemodel.pos = elec.pnt;
sourcemodel = ft_prepare_sourcemodel(cfg);

headmodel = ft_read_headmodel('headmodel/standard_bem.mat');

% realign electrodes to headmodel
cfg = [];
cfg.method = 'interactive';
cfg.elec = elec;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg);

%save new electrodes
save elec64.mat elec

ERPsAll.elec = ft_read_sens('elec64.mat’);

% Prepare leadfield
cfg                 = [];
cfg.elec            = ERPsAll.elec;
cfg.vol             = headmodel;
cfg.reducerank      = 3;
cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
cfg.grid.unit       = 'cm';
cfg.channel ={'all'};
leadfield = ft_prepare_leadfield(cfg);



%%mne
cfg              = [];
cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
cfg.elec         = ERPsAll.elec; %grid.cfg.elec;%
cfg.headmodel          = headmodel;
cfg.grid = leadfield;
%cfg.sourcemodel = sourcemodel;
% cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
%cfg.reducerank          = 2;

source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

save source_C_Shock.mat source_C_Shock
save source_C_Noshock.mat source_C_Noshock

bnd.pos = headmodel.bnd.pos;
bnd.tri = headmodel.bnd.tri;

m=source_C_Shock.avg.pow(:,450);
%timeN1 = [1232:1301];timeP3 = [1722:1927];timeeLPP = [1928:2356];timelLPP = [2357:2868];
ft_plot_mesh(bnd, 'vertexcolor', m);
view([180 0]); h = light; set(h, 'position', [0 1 0.2]); lighting gouraud; material dull

cfg = [];
cfg.projectmom = 'yes';
sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);

sdDIFF         = sdNoShock;
sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
sdDIFF.tri = headmodel.bnd.tri;

save sd sdDIFF;

cfg = [];
cfg.funparameter = 'pow';
%cfg.method       = 'surface';
ft_sourcemovie(cfg,sdDIFF);


---------------------------------------------
Emilie Caspar, Ph.D

CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
Voice : +32 2 650 32 95
mail : ecaspar at ulb.ac.be<mailto:ecaspar at ulb.ac.be>
office: DB10-138

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl<mailto:e.caspar at nin.knaw.nl>

_______________________________________________
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/20200403/15fdec57/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://doi.org/10.1371/journal.pcbi.1002202


------------------------------

End of fieldtrip Digest, Vol 113, Issue 4
*****************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200404/4cbe3764/attachment.htm>

From saeedzahran at hotmail.com  Tue Apr  7 02:52:51 2020
From: saeedzahran at hotmail.com (Saeed Zahran)
Date: Tue, 7 Apr 2020 00:52:51 +0000
Subject: [FieldTrip] read fif file
In-Reply-To: <mailman.9.1585994402.9067.fieldtrip@science.ru.nl>
References: <mailman.9.1585994402.9067.fieldtrip@science.ru.nl>
Message-ID: <BN3PR01MB205128828727C453CE75A17AB7C30@BN3PR01MB2051.prod.exchangelabs.com>

Hello,

I want to read fif file from mne that contains the forward model; sample-fwd.fif
what function should I used inorder to read it infieldtrip?

Best regards
Saeed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200407/08a9902c/attachment.htm>

From david.pascucci at epfl.ch  Tue Apr  7 10:54:46 2020
From: david.pascucci at epfl.ch (Pascucci David)
Date: Tue, 7 Apr 2020 08:54:46 +0000
Subject: [FieldTrip] Open PostDoc and PhD positions
Message-ID: <d1d59f9c9a9d4a2e8f9fc6381409fccb@epfl.ch>

The Icelandic Vision Lab (www.visionlab.is<http://www.visionlab.is/>) advertises two positions: 1) A post-doctoral position, for two years, potentially extendable for one year 2) A 3-year PhD position. Both are fully funded by a grant from the Icelandic Research Fund (IRF). The successful candidates will work under the supervision of Professor Árni Kristjánsson (University of Iceland) and Dr. David Pascucci (at the EPFL Lausanne). People with backgrounds from various disciplines will be considered, e.g. Neuroscience, Biology, Psychology, Mathematics, Engineering. A PhD (for the post-doc position) and a Masters degree (for the PhD position) in relevant disciplines are required.

The positions involve research into representations of statistical variation in artificial displays and natural scenes. Recent evidence shows that observers can have a remarkably detailed representation of the distributions of stimuli in the environment. The work will involve investigations into how this feature distribution learning interacts with other history based learning effects such as serial dependence. Research findings relevant to the project have been published in various prominent academic journals (see for example www.visionlab.is/publications<http://www.visionlab.is/publications>).

The project will involve behavioral studies, computational modelling and EEG work. The work will involve a collaboration between the laboratories that the principle investigators run at the University of Iceland and EPFL in Lausanne. The primary place of work will be the Icelandic Vision Lab in Reykjavik but the work will include extensive collaboration with the laboratory of Psychophysics at EPFL in Lausanne.



Experience with experimental psychology software (PsychoPy/Psychtoolbox), programming (Python/MATLAB/C/C++), statistical software such as R, computational modelling in vision, are all definite benefits but promising candidates showing enthusiasm and willingness to learn these methods will also be considered.

The Icelandic Vision Lab offers a stimulating academic environment, and is headed by professors Árni Kristjánsson, Heiða María Sigurðardóttir and Árni Gunnar Ásgeirsson. The laboratory has an extended network of collaborations, from all over the world and is in many ways unique in this international aspect. The planned collaboration will involve potential periods abroad at EPFL, one of the leading universities in Europe.

The successful candidates will join this vibrant community of graduate students, post-docs and faculty who all work on varied aspects of visual perception. The lab is well funded with grants from the Icelandic Research Fund, The European Research Council and the Research Fund of the University of Iceland. There is good access to necessary equipment for the studies. The lab has high-end equipment for EEG, eye movement studies as well as extensive experience with high quality psychophysical studies.

Iceland consistently ranks as one of the best places in the world to live: (http://worldhappiness.report/ed/2019/), life satisfaction is among the highest in the world (http://www.oecdbetterlifeindex.org/topics/life-satisfaction), and the country is consistently rated the most peaceful in the world (http://worldpopulationreview.com/countries/most-peaceful-countries/). Iceland also ranks at the top of the world in terms of gender equality (https://www.weforum.org/agenda/2019/12/gender-gap-equality-women-parity-countries/). Applicants of any gender are strongly encouraged to apply.



Starting May 1st we will start evaluating applications, but no firm deadline is set at this point.

Please send applications or enquiries to IVLapplications2020 at gmail.com<mailto:IVLapplications2020 at gmail.com>.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200407/bec57cf1/attachment.htm>

From raufanwar at uet.edu.pk  Tue Apr  7 12:51:08 2020
From: raufanwar at uet.edu.pk (Abdul Rauf Anwar)
Date: Tue, 7 Apr 2020 10:51:08 +0000
Subject: [FieldTrip] Cross frequency coupling
Message-ID: <DB7PR07MB479486A90F5D3EB91E20220A9AC30@DB7PR07MB4794.eurprd07.prod.outlook.com>

Hi

Is there any example available how to use 'ft_crossfrequencyanalysis' in fieldtrip ? I would be obliged if someone could share a basic example or tutorial with any arbitrary dataset and how to view the output parameters.

Thanks
Rauf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200407/369c9393/attachment.htm>

From A.Marchina at bham.ac.uk  Tue Apr  7 18:36:09 2020
From: A.Marchina at bham.ac.uk (A.Marchina at bham.ac.uk)
Date: Tue, 7 Apr 2020 16:36:09 +0000
Subject: [FieldTrip] Download FielTrip toolbox and tutorial datasets
Message-ID: <89cf3d493581427b8f840cd908c5bdf2@bham.ac.uk>

Hello,


I am taking my first steps in downloading FieldTrip toolbox to be run in Matlab and further getting access to exapmple datasets to make practice on while following tutorial steps.


I see that in order to get access to both FieldTrip versions to be dowloaded and datasets I have to map FTP server you provide onto my laptop. I would like you to help me out with your these trivial steps: do I need some remote access authorization to have access to the FTP server from my laptop? When I create it I cannot have access to its content.


Looking forward to help!


Best regards,

Andrea
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200407/7d286a27/attachment.htm>

From v.litvak at ucl.ac.uk  Wed Apr  8 05:56:22 2020
From: v.litvak at ucl.ac.uk (Vladimir Litvak)
Date: Wed, 8 Apr 2020 04:56:22 +0100
Subject: [FieldTrip] =?utf-8?q?Fwd=3A_PhD_studentship_=E2=80=93_Modelling?=
	=?utf-8?q?_cortico-subcortical_oscillatory_connectivity=2E?=
In-Reply-To: <CACq1BhL_AcbHq9D0P5Yw3s5xOOwj0OBw4qNxdLKtWJ2==dCKsw@mail.gmail.com>
References: <CACq1BhL_AcbHq9D0P5Yw3s5xOOwj0OBw4qNxdLKtWJ2==dCKsw@mail.gmail.com>
Message-ID: <CACq1BhLB1TnpvDzGhtdOUnGw6X0Uy18r-jfGVYvcf4wxgrkRxQ@mail.gmail.com>

Dear all,

Please note that we accept applications for this position despite the
COVID19 crisis. The interviews will be held online in necessary. The
deadline is Apr 30. Please do not miss the chance as it's a great Ph.D.
program. Just mind the requirement of not spending more than 12 months
prior to the starting date in the UK.

Good luck and stay safe!

Vladimir

---------- Forwarded message ---------
From: Vladimir Litvak <v.litvak at ucl.ac.uk>
Date: Tue, Feb 18, 2020 at 9:34 AM
Subject: PhD studentship – Modelling cortico-subcortical oscillatory
connectivity.
To: SPM at JISCMAIL.AC.UK <SPM at jiscmail.ac.uk>


*PhD Studentship – Modelling cortico-subcortical oscillatory connectivity.*



Applications are invited for a 3-year funded PhD studentship in the
Wellcome Centre for Human Neuroimaging (https://www.fil.ion.ucl.ac.uk/)
under the supervision of Dr. Vladimir Litvak and Dr. Simon Farmer and in
collaboration with the Computational Neuroscience Group (CNS,
https://www.upf.edu/web/cns), led by Prof. Gustavo Deco, at the Center for
Brain and Cognition (https://www.upf.edu/web/cbc), Pompeu Fabra University
(Barcelona, Spain).  The position is part of the EU-funded Innovative
Training Network euSNN (“European School of Network Neuroscience”) and
available, with full-time employment, for a duration of 3 years with
immediate start.



The euSNN Innovative Training Network integrates 16 leading European groups
in network neuroscience and 7 companies to train students who want to
pursue a successful career in the field of network neuroscience. The euSNN
training programme offers a unique combination of experimental, analysis
and modelling approaches. Exploiting intense collaborations between
experimental, theoretical and clinical groups, euSNN links basic research
on large-scale brain dynamics with new pathophysiological approaches and
clinical applications. The euSNN network is coordinated by Prof. Dr.
Andreas K. Engel. Further information on the euSNN network can be found at
http://eusnn.eu.



*Project details*



Deep Brain Stimulation (DBS) is an effective treatment method for a range
of neurological and psychiatric conditions. It involves placing electrodes
deep in a patient’s brain, usually in precisely targeted subcortical
nuclei. DBS surgery affords a unique opportunity to study the neural
activity of these nuclei via recording of local electrical signals known as
local field potentials (LFP). Our group pioneered simultaneous recording of
subcortical LFP with non-invasive whole brain imaging using
magnetoencephalography (MEG). This makes it possible to map out
cortico-subcortical oscillatory coherent networks which have characteristic
frequencies and cortical topographies for each subcortical target. Over the
years we collected data from several different subcortical nuclei and
characterised their oscillatory networks. The aim of the proposed project
is to establish a modelling framework which could accommodate these
findings and make quantitative predictions for future experiments. This
will require extending existing models of cortical dynamics and integrating
information from additional imaging modalities such as functional MRI and
Diffusion Tensor Modelling (DTI).



The euSNN training network offers exciting and unique opportunities for the
student to pursue this project including interactions with top experts in
neuroimaging brain modelling and exposure to several different modelling
frameworks and approaches that the student will have to master and
integrate to achieve the project’s goals. There might also be opportunities
towards the end of the project to test some of the predictions
experimentally. In addition, the student will have a chance to work on
secondments with commercial companies on topics relevant to the project.



*Funding notes*

The starting date can be any date between being offered the position and 1st
October 2020 and the contract is for 36 months. The studentship includes
UK/EU tuition fees and a stipend along with additional funds to cover
travel and accommodation during secondments and network activities.
Overseas fees cannot be covered.



*Entry requirements*

Applicants should have an Honours Degree (minimum 2:1) in a quantitative
discipline: Physics/ Mathematics/Engineering/Computer science, strong
mathematical background and interest in neuroscience. Knowledge of
scientific programming languages, particularly Matlab, background in
modelling complex physical systems and a relevant Masters qualification is
desirable. Applicants should be willing to travel to attend the network
activities and spend prolonged periods of time (up to a few months at a
time and at least 8 months in total) doing secondments outside the UK.
*Applicants
must not have been residing in the UK for more than 12 months prior to the
start of the appointment.*



*Deadline 30th April 2020. Shortlisted candidates will be interviewed in
May.*



*How to apply:*

Applicants should submit 1) a CV, 2) a 1-page statement detailing why you
want to do the PhD, motivation, interest and suitability for the project,
3) a copy of your strongest single piece of academic work (e.g. thesis,
publication), and 4) contact details of two referees. Please ensure that
each document is clearly labelled with your surname. Please send all
documents to Kamlyn Ramkissoon k.ramkissoon at ucl.ac.uk
<k.ramkissoon at ucl.ac.uk%20>by *30th April 2020*. Interviews will be held in May
2020. Informal enquiries are welcome to Dr Vladimir Litvak (email:
v.litvak at ucl.ac.uk).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200408/5a3df6ed/attachment.htm>

From pierpaolo12croce at gmail.com  Wed Apr  8 12:15:11 2020
From: pierpaolo12croce at gmail.com (Pierpaolo Croce)
Date: Wed, 8 Apr 2020 12:15:11 +0200
Subject: [FieldTrip] openbci2ft
Message-ID: <CALkLzZ78M8piRW1g6Ra1NNFOXgbDY4E-zb6Pyqopz4JAUVSskw@mail.gmail.com>

Hi everyone,
I'm trying to use realtime fieldtrip with the openbci (arduino) hardware.
I would like to send the data to the PC where the openbci is to another PC
of the same network.
The openbic is running on a windows10 PC. To stream data I'm using the
script openbct2ft.exe in the following manner:

.\openbci2ft COM3: nameofthedestinationhost 1972

I get the feedback in the picture attached
[image: Schermata 2020-04-08 alle 12.12.51.png]
Can someone help me? May be a windows 10 problem? May be I have to activate
the port in some way?
Thanks in advance.
I obtain the same also if i try to stream in the local buffer.

-- 

Ing. Pierpaolo Croce, PhD.
Institute for Advanced Biomedical Technologies - ITAB
and
Department of Neuroscience and Imaging
University of Chieti "G. D'Annunzio"
Via dei Vestini, 33
66013 Chieti, Italy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200408/1b5e99b8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Schermata 2020-04-08 alle 12.12.51.png
Type: image/png
Size: 201770 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200408/1b5e99b8/attachment.png>

From sara.hussain at nih.gov  Fri Apr 10 19:31:14 2020
From: sara.hussain at nih.gov (Hussain, Sara (NIH/NINDS) [F])
Date: Fri, 10 Apr 2020 17:31:14 +0000
Subject: [FieldTrip] DICS beamforming
Message-ID: <06C4F7AD-5952-4A71-B793-D1F3A76DF187@contoso.com>

Hi all –

I am trying to source localize some broadband oscillatory data using the ‘dics’ beamforming option, as documented in the tutorial “Localizing visual gamma and corticomuscular coherence.” I am currently using standard mri and segmentation via the fieldtrip templates, and generating a dipole grid with 500 dipoles using the ‘basedonvol’ approach. I then compute the leadfield based on the positions of these dipoles. Up to this point, everything seems ok and checks out during plotting. But when I try to run ft_sourceanalysis I am getting the following error:

Warning: dipole lies on boundary of volume model
> In inf_medium_leadfield (line 54)
  In eeg_leadfieldb (line 92)
  In ft_compute_leadfield (line 443)
  In beamformer_dics (line 305)
  In ft_sourceanalysis (line 674)
Error using svd
Input to SVD must not contain NaN or Inf.

Error in beamformer_dics>pinv (line 643)
  [U,S,V] = svd(A,0);

Error in beamformer_dics (line 336)
        filt = pinv(lf' * invCf * lf) * lf' * invCf;              % Gross eqn. 3, use PINV/SVD
        to cover rank deficient leadfield

Error in ft_sourceanalysis (line 674)
          dip(i) = beamformer_dics(grid, sens, headmodel, [],  squeeze_Cf, optarg{:});


I’ve seen this error asked in other threads but I’ve tried what those suggest with no luck. I’m assuming this has something to do with the fact that the dipoles aren’t fully embedded in the grey matter – but I’ve tried changing the inward shift parameter etc during grid generation and it hasn’t solved it. Any suggestions?  Code is below..

===================

% housekeeping
clearvars
basedir='/net/nindsdirfs.ninds.nih.gov/ifs/shares/HCPS/';
addpath([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718']);
ft_defaults;

% read standard mri
cd([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718/template/headmodel']);
mri=load('standard_mri.mat');
mri=mri.mri;

% read standard segmentation
seg=load('standard_seg.mat');
seg=seg.mri;

% read standard headmodel
vol=load('standard_bem.mat'); %vol
vol=vol.vol;

% create sourcemodel/grid based on standard mri
cfg=[];
cfg.headmodel=vol;
cfg.moveinward=2;
cfg.grid.unit='mm';
grid=ft_prepare_sourcemodel(cfg);

% check segmentation
seg.transform=mri.transform;
seg.anatomy=mri.anatomy;
cfg=[];
cfg.funparameter='gray';
ft_sourceplot(cfg,seg);
pause; close all;

% check volume conduction model
figure; ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain
figure; ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull
figure; ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp
pause; close all;

% check electrode positions
figure;
elec=ft_read_sens('standard_1005.elc','senstype','eeg');
ft_plot_mesh(vol.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.4,'edgecolor','none','edgealpha',0.05); hold on;
ft_plot_mesh(vol.bnd(2),'edgecolor','none','facealpha',0.4);
ft_plot_mesh(vol.bnd(1),'edgecolor','none','facecolor',[0.4 0.6 0.4]);
ft_plot_sens(elec,'label','yes');
pause; close all

% check grid position
figure;
ft_plot_mesh(vol.bnd(3),'edgecolor','none'); hold on; alpha 0.4; %brain
ft_plot_mesh(grid.pos(grid.inside,:));
pause; close all;

% load data
cd([basedir 'SaraHussain/SS_42H_63/clean_tep_data']);
load([peak_subj{jjj} '_double_cleaned_peak.mat']);

% demean/detrend and update channel names
cfg=[];
cfg.demean='yes';
cfg.detrend='yes';
data=ft_preprocessing(cfg,clean_data);
data.label=labels;

% select relevant post-stim latencies and channels
cfg=[];
short=ft_selectdata(cfg,data);

% calculate post-stim frequency using mtmfft approach
cfg=[];
cfg.method='mtmfft';
cfg.output='powandcsd';
cfg.tapsmofrq=48;
cfg.foi=52;
peak=ft_freqanalysis(cfg,short);

% create leadfield
cfg=[];
cfg.headmodel=vol;
cfg.grid.pos=grid.pos;
cfg.grid.inside=grid.inside;
cfg.elec=elec;
lead=ft_prepare_leadfield(cfg,peak);

% get source localized data
cfg=[];
cfg.elec=elec;
cfg.method='dics';
cfg.sourcemodel=lead;
cfg.headmodel=vol;
source_peak=ft_sourceanalysis(cfg,peak);






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200410/9454620a/attachment.htm>

From kris.de_meyer at kcl.ac.uk  Sat Apr 11 13:24:06 2020
From: kris.de_meyer at kcl.ac.uk (De Meyer, Kris)
Date: Sat, 11 Apr 2020 11:24:06 +0000
Subject: [FieldTrip] automatic artifact rejection
Message-ID: <AM6PR03MB38638D8319CC9A28C66EF67497DF0@AM6PR03MB3863.eurprd03.prod.outlook.com>

Hi all,

Looking at the documentation page for automatic artifact rejection<http://www.fieldtriptoolbox.org/tutorial/automatic_artifact_rejection/>, it contains a detail that comes across to me as odd.

At end of Section III. Z-transforming the filtered data and averaging it over channels, it says that the averaging is done by summing the z-transformed values for each time-point over all channels, and then dividing them by the square root of the number of channels.

I don't understand what the square root is doing in that formula. In my case I have 14 channels I want to average over for the artifact rejection, and if all of them had a z-value of 1, and my threshold was 3 or 3.5 (sensible values, given they are z scores) then my final averaged value is higher than my threshold only because of the summation!

To me this doesn't make much sense because it means that, rather than being able to set a constant threshold regardless of how many channels one averages over, it now means we need to use a different threshold for different numbers of channels.

What am I missing?

Best,

Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200411/85534394/attachment.htm>

From nea26 at cam.ac.uk  Mon Apr 13 10:07:02 2020
From: nea26 at cam.ac.uk (Dr N.E. Adams)
Date: Mon, 13 Apr 2020 09:07:02 +0100
Subject: [FieldTrip] mesh realignment
Message-ID: <0058cae8f18181bc13c77ab58fb30a4e@cam.ac.uk>

Dear Fieldtrip Community

I would like to align two brain meshes and I can't figure out how.
Specifically, I would like to align a MEG-coregistered segmented brain 
mesh that has been normalized (mesh_brain) to an atlas cortical mesh 
(mesh_atlas). The two meshes, in this example, are about 20mm off 
alignment with each other in the rostral-caudal dimensnion in the 
attached images and I'd like to correct for this sort of alignment 
issue.

Can I do this with ft_volumerealign()? If I can, I can't figure out the 
settings.

Attempted workaround:
I tried using icp() to get the affine to tranform one to the other, but 
I do not know how to then apply this affine to meshes rather than 
volumes, nor if this has worked. I tried converting the mesh to a 
volume, but this was only partially successful and I'm unclear how to 
convert it back. Thinking this was a rabbit-hole I thought there must be 
an easier solution. Anyone know?

Thank you in advance for you help
Natalie Adams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesh_atlas.JPG
Type: image/jpeg
Size: 19417 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200413/b0f82a8e/attachment.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mesh_brain.JPG
Type: image/jpeg
Size: 25956 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200413/b0f82a8e/attachment-0001.jpe>

From pdhami06 at gmail.com  Mon Apr 13 23:39:13 2020
From: pdhami06 at gmail.com (Paul Dhami)
Date: Mon, 13 Apr 2020 17:39:13 -0400
Subject: [FieldTrip] Interpretation of Sensor Level Clusters and Relating to
 Cortical Sources
Message-ID: <CABqnCmDGe12Mnc4zeZLcAJv3T1x-9DhQ_BjAoi5Nr56EtOkgAw@mail.gmail.com>

Dear FieldTrip community,

I have two time-frequency datasets, and I am interested in testing whether
there is any significance difference between them, and if so, finding the
potential cortical sources of such differences.

At the sensor level, I have used the cluster-based permutation method to
establish that there is indeed a significant difference between the two
datasets.

My question is if I can use the features of the cluster to predefine my
source analysis, or would that involve the incorrect interpretation of the
cluster method?

For example, let's say the largest cluster was found to exist in the range
of 100 - 300 ms in the frequency band alpha (8 - 12 Hz). Would it then make
sense to limit my source analysis to this time and frequency window? Is
this an incorrect approach? Or correct but perhaps too conservative?

Any insight would be much appreciated.

Best,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200413/e1f7faf0/attachment.htm>

From parkerjo at stanford.edu  Tue Apr 14 03:56:03 2020
From: parkerjo at stanford.edu (Jonathon James Parker)
Date: Tue, 14 Apr 2020 01:56:03 +0000
Subject: [FieldTrip] ft_plot_sens Question
Message-ID: <3667C1CA-5562-4FC0-8ACF-7EE34B076F04@contoso.com>



Hi Fieldtrippers:



I am trying to make a figure where I label sets of two sensors with different colors on the background of all the sensors (SEEG contacts).



For instance I would like to make two contacts red (stimulation contacts) and two contacts blue (recording contacts), with the rest of the contacts black spheres.



I attempted the following:



ft_plot_sens(electrode_map); %plots all contacts without labels in black

ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',stim_electrode_clr,'chantype',{stimA,stimB});

ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',rec_electrode_clr,'chantype',{RecA,RecB});



stimA, stimB, RecA, RecB are the strings for the respective channels.



I am getting the following error anytime I try to call ft_plot_sens() with fewer than three sensors….



I receive the following error:





Error using delaunay

At least three input points must be provided to define a triangular mesh.



Error in projecttri (line 83)

    tri = delaunay(prj(:,1), prj(:,2));



Error in ft_plot_sens (line 303)

    tri = projecttri(pos, 'delaunay');



Error in jpPlotElectrodes (line 7)

ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',stim_electrode_clr,'chantype',{stimA,stimB});


I dug down into the implementation of ft_plot_sens() and see that it relies in the depth on a call to deuaunay(…) which looks like needs three arguments.

I attempted to “trick” the function by putting in a dummy 0,0,0 corner electrode and plotting, however, that messes with the scale of the plot.

Has anyone developed a work around for independently labeling two channels/electrodes at a time a different color?

Kindest regards. Hope everyone is staying healthy out there.

Best,
JP



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200414/a6cd5147/attachment.htm>

From mailtome.2113 at gmail.com  Tue Apr 14 04:21:52 2020
From: mailtome.2113 at gmail.com (Arti Abhishek)
Date: Tue, 14 Apr 2020 12:21:52 +1000
Subject: [FieldTrip] Alternatives to cluster based permutation test in
 sparse electrode montanges
Message-ID: <CA+N_CJqGAwBMx9SO+qPH5T2rHLy2Thq=oqAXBUTr0_i6anALCw@mail.gmail.com>

Dear list,

I have the mismatch negativity (MMN) recorded from 14 channels. I have used
cluster stats in my earlier studies; however I believe it is not ideal here
due to the sparse electrode montage. What would be a good alternative here?
I thought of using Guthrie and Buchwald method (*Guthrie, D., & Buchwald,
J. S. (1991). Significance testing of difference
potentials. Psychophysiology, 28(2), 240-244.*) on selected electrodes (as
MMN is generally seen in fronto-central electrodes). However there are
criticisms of this method *(Piai, V., Dahlslätt, K., & Maris, E. (2015).
Statistically comparing EEG/MEG waveforms through successive significant
univariate tests: How bad can it be?. Psychophysiology, 52**(3), 440-443.*).
Could anyone help an alternative method.

Kind regards,
Arti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200414/a889a39f/attachment.htm>

From jan.schoffelen at donders.ru.nl  Tue Apr 14 08:35:41 2020
From: jan.schoffelen at donders.ru.nl (Schoffelen, J.M. (Jan Mathijs))
Date: Tue, 14 Apr 2020 06:35:41 +0000
Subject: [FieldTrip] mesh realignment
In-Reply-To: <0058cae8f18181bc13c77ab58fb30a4e@cam.ac.uk>
References: <0058cae8f18181bc13c77ab58fb30a4e@cam.ac.uk>
Message-ID: <93CF29D1-B86B-499D-91DF-6A99B39F7E0D@donders.ru.nl>

Dear Natalie,

I am not sure whether I understand the reason why you would want this. Could you explain why you think you’d need to ‘align’ the meshes in 3D space?

Typically, when doing a cortical mesh based source reconstruction, while at the same time using information from an (anatomical) that’s defined on a cortical mesh, the game would be to have the topologies of the meshes aligned, and not the exact position of the geometric objects. In other words, the goal (and recommended approach) is to use surface based registration techniques (and possibly re-tessellation) to have a one-to-one correspondence of the vertices in both meshes. 

If, however, you insist on doing a 3D alignment using icp (and assuming that it worked), you can apply the affine matrix to the mesh using the ft_transform_geometry function.

I would not try to do an intermediate interpolation to 3D space.

Best wishes,
Jan-Mathijs


> On 13 Apr 2020, at 10:07, Dr N.E. Adams <nea26 at cam.ac.uk> wrote:
> 
> Dear Fieldtrip Community
> 
> I would like to align two brain meshes and I can't figure out how.
> Specifically, I would like to align a MEG-coregistered segmented brain mesh that has been normalized (mesh_brain) to an atlas cortical mesh (mesh_atlas). The two meshes, in this example, are about 20mm off alignment with each other in the rostral-caudal dimensnion in the attached images and I'd like to correct for this sort of alignment issue.
> 
> Can I do this with ft_volumerealign()? If I can, I can't figure out the settings.
> 
> Attempted workaround:
> I tried using icp() to get the affine to tranform one to the other, but I do not know how to then apply this affine to meshes rather than volumes, nor if this has worked. I tried converting the mesh to a volume, but this was only partially successful and I'm unclear how to convert it back. Thinking this was a rabbit-hole I thought there must be an easier solution. Anyone know?
> 
> Thank you in advance for you help
> Natalie Adams<mesh_atlas.JPG><mesh_brain.JPG>_______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202




From jan.schoffelen at donders.ru.nl  Tue Apr 14 08:47:07 2020
From: jan.schoffelen at donders.ru.nl (Schoffelen, J.M. (Jan Mathijs))
Date: Tue, 14 Apr 2020 06:47:07 +0000
Subject: [FieldTrip] ft_plot_sens Question
In-Reply-To: <3667C1CA-5562-4FC0-8ACF-7EE34B076F04@contoso.com>
References: <3667C1CA-5562-4FC0-8ACF-7EE34B076F04@contoso.com>
Message-ID: <63709810-926C-4DC9-9F2A-50EC8FF0DC62@donders.ru.nl>

Dear Jonathon,

What you want to achieve should be possible, but fails in your case probably due to the fact that the ‘chantype’ key only works if the values provided match the entries in (your) electrode_map.chantype field. So, providing channel labels, as I interpret from the description in the e-mail, is not going to work.

You probably need to do something like this (no success guaranteed, but you can use the below snippet of code to get started):

stim_idx = match_str(electrode_map.label, {stimA,stimB});
rec_idx = match_str(electrode_map.label, {RecA,RecB});
if ~isfield(electrode_map, ‘chantype’)
  for k = 1:numel(electrode_map.label)
    electrode_map.chantype{k,1} = ‘unknown’;
  end
end
electrode_map.chantype(stim_idx) = {’stim’};
electrode_map.chantype(rec_idx) = {‘rec’};

ft_plot_sens…
ft_plot_sens(…, ‘chantype’, ’stim’);
ft_plot_sens(…, ‘chantype’, ‘rec’);

Best wishes,
Jan-Mathijs



On 14 Apr 2020, at 03:56, Jonathon James Parker <parkerjo at stanford.edu<mailto:parkerjo at stanford.edu>> wrote:


Hi Fieldtrippers:

I am trying to make a figure where I label sets of two sensors with different colors on the background of all the sensors (SEEG contacts).

For instance I would like to make two contacts red (stimulation contacts) and two contacts blue (recording contacts), with the rest of the contacts black spheres.

I attempted the following:

ft_plot_sens(electrode_map); %plots all contacts without labels in black
ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',stim_electrode_clr,'chantype',{stimA,stimB});
ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',rec_electrode_clr,'chantype',{RecA,RecB});

stimA, stimB, RecA, RecB are the strings for the respective channels.

I am getting the following error anytime I try to call ft_plot_sens() with fewer than three sensors….

I receive the following error:


Error using delaunay
At least three input points must be provided to define a triangular mesh.

Error in projecttri (line 83)
    tri = delaunay(prj(:,1), prj(:,2));

Error in ft_plot_sens (line 303)
    tri = projecttri(pos, 'delaunay');

Error in jpPlotElectrodes (line 7)
ft_plot_sens(electrode_map, 'label', 'on', 'fontcolor', 'b','facecolor',stim_electrode_clr,'chantype',{stimA,stimB});


I dug down into the implementation of ft_plot_sens() and see that it relies in the depth on a call to deuaunay(…) which looks like needs three arguments.

I attempted to “trick” the function by putting in a dummy 0,0,0 corner electrode and plotting, however, that messes with the scale of the plot.

Has anyone developed a work around for independently labeling two channels/electrodes at a time a different color?

Kindest regards. Hope everyone is staying healthy out there.

Best,
JP



_______________________________________________
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/20200414/4617250e/attachment.htm>

From nea26 at cam.ac.uk  Tue Apr 14 11:01:18 2020
From: nea26 at cam.ac.uk (Dr N.E. Adams)
Date: Tue, 14 Apr 2020 10:01:18 +0100
Subject: [FieldTrip] mesh realignment
In-Reply-To: <93CF29D1-B86B-499D-91DF-6A99B39F7E0D@donders.ru.nl>
References: <0058cae8f18181bc13c77ab58fb30a4e@cam.ac.uk>
 <93CF29D1-B86B-499D-91DF-6A99B39F7E0D@donders.ru.nl>
Message-ID: <2f396d695a818dc7b11ab27b34c92374@cam.ac.uk>

Dear Jan-Mathijs

Ah, thank you, I believe this question has been answered for me, and it 
is really useful to know about ft_transform_geometry - that script had 
passed me by. I have now preprocessed my data in SPM and was looking to 
be able to look up atlas coordinates for the source-reconstruction step. 
The spatial model for the inversion is based on a mesh of the 
(coregistered) individual's brain shape, but an normalized version of 
this mesh acts as a look-up table for coordinates. My atlas needed to be 
registered to this normalized brain for me to know I was looking in the 
right area of the brain for specific brain regions based on the atlas 
label. All sorted now.

Thanks and kind regards
Natalie


On 2020-04-14 07:35, Schoffelen, J.M. (Jan Mathijs) wrote:
> Dear Natalie,
> 
> I am not sure whether I understand the reason why you would want this.
> Could you explain why you think you’d need to ‘align’ the meshes in 3D
> space?
> 
> Typically, when doing a cortical mesh based source reconstruction,
> while at the same time using information from an (anatomical) that’s
> defined on a cortical mesh, the game would be to have the topologies
> of the meshes aligned, and not the exact position of the geometric
> objects. In other words, the goal (and recommended approach) is to use
> surface based registration techniques (and possibly re-tessellation)
> to have a one-to-one correspondence of the vertices in both meshes.
> 
> If, however, you insist on doing a 3D alignment using icp (and
> assuming that it worked), you can apply the affine matrix to the mesh
> using the ft_transform_geometry function.
> 
> I would not try to do an intermediate interpolation to 3D space.
> 
> Best wishes,
> Jan-Mathijs
> 
> 
>> On 13 Apr 2020, at 10:07, Dr N.E. Adams <nea26 at cam.ac.uk> wrote:
>> 
>> Dear Fieldtrip Community
>> 
>> I would like to align two brain meshes and I can't figure out how.
>> Specifically, I would like to align a MEG-coregistered segmented brain 
>> mesh that has been normalized (mesh_brain) to an atlas cortical mesh 
>> (mesh_atlas). The two meshes, in this example, are about 20mm off 
>> alignment with each other in the rostral-caudal dimensnion in the 
>> attached images and I'd like to correct for this sort of alignment 
>> issue.
>> 
>> Can I do this with ft_volumerealign()? If I can, I can't figure out 
>> the settings.
>> 
>> Attempted workaround:
>> I tried using icp() to get the affine to tranform one to the other, 
>> but I do not know how to then apply this affine to meshes rather than 
>> volumes, nor if this has worked. I tried converting the mesh to a 
>> volume, but this was only partially successful and I'm unclear how to 
>> convert it back. Thinking this was a rabbit-hole I thought there must 
>> be an easier solution. Anyone know?
>> 
>> Thank you in advance for you help
>> Natalie 
>> Adams<mesh_atlas.JPG><mesh_brain.JPG>_______________________________________________
>> 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


From ecaspar at ulb.ac.be  Tue Apr 14 13:44:26 2020
From: ecaspar at ulb.ac.be (Emilie Caspar)
Date: Tue, 14 Apr 2020 13:44:26 +0200
Subject: [FieldTrip] ft_sourcemovie - producing 'contemporary art'
 instead of a brain
In-Reply-To: <0C841ED8-4315-4F71-B12F-1D4DAFE01F5A@donders.ru.nl>
References: <B7A355FC-6AFF-496E-94EE-485D44429D28@ulb.ac.be>
 <C3B27185-3A5B-4CCB-A846-7DA76498A063@donders.ru.nl>
 <CABPNLUooq6DXdvBZabmWGcG0T0wDrF65+YGykG0qY=Vchaa+hw@mail.gmail.com>
 <252CC2F3-58A2-4B50-9FB9-72D48D3816C4@ulb.ac.be>
 <0C841ED8-4315-4F71-B12F-1D4DAFE01F5A@donders.ru.nl>
Message-ID: <A6FCE8B5-4C88-4A27-8C29-88DCF5B94976@ulb.ac.be>

Dear Jan-Mathijs,

Thank you for those pointers because indeed now I have obtained a nice brain instead of my contemporary piece of art (see Figure attached!) (I write below the full code, if others would find it relevant as well).

I am however struggled to find out how to extract the coordinates of the source reconstruction in order to use them as a ROI on MRI data. If I use the ft_sourcemovie, I can obtain the indications of the coordinates when I click on a specific location. But I guess it’s not the most proper method?

I have used the ft_sourceplot function based on an atlas that I uploaded in the templates. However, it does not plot the data, only a template brain with unknown as X Y and Z coordinates. 

atlas = ft_read_atlas('ROI_MNI_V4.nii');            
statint.coordsys = 'mni';
cfg               = [];
cfg.method        = 'ortho';
cfg.funparameter  = 'stat';
cfg.maskparameter = 'mask';
cfg.locationcoordinates = 'head';
cfg.atlas         = atlas;
cfg.location = 'max';
cfg.funcolorlim   = [-5 5];
cfg.funcolormap = 'jet';
ft_sourceplot(cfg,sdDIFFC);
 
I also used the ft_volumelookup function as follow

cfg = [];
cfg.atlas = atlas;
cfg.inputcoord = 'mni';
cfg.maskparameter = 'inside';
labels = ft_volumelookup(cfg,sdDIFFC);


But it fails to recognize the atlas

Do you want to change the anatomical labels for the axes [Y, n]? Y
What is the anatomical label for the positive X-axis [r, l, a, p, s, i]? r
What is the anatomical label for the positive Y-axis [r, l, a, p, s, i]? a
What is the anatomical label for the positive Z-axis [r, l, a, p, s, i]? s
Is the origin of the coordinate system at the a(nterior commissure), i(nterauricular), n(ot a landmark)? n
Warning: The field cfg.inputcoord is forbidden, it will be removed from your configuration
 
 In ft_checkconfig at line 224
 In ft_volumelookup at line 119

Error using atlas_lookup (line 89)
the mismatch between the coordinate system in the atlas and the coordinate system in the data cannot be
resolved

Therefore, I was wondering what the most reliable option is to exact coordinates from the EEG source reconstruction than I can later implement as ROI in MRI data. Any suggestions is welcome!

Thanks a lot for the help, 

Emilie



—— Code used:

load Subject01_sourcemodel_15684;
headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
electr_pos=ft_read_sens('Biosemi-Cap64.sfp');

load('GA_C_Shock.mat')
load('GA_C_NOShock.mat')

cfg = [];
cfg.method = 'interactive';
cfg.elec = electr_pos;
cfg.headshape = headmodel.bnd(1); %1 = skin
elec = ft_electroderealign(cfg, electr_pos);

cfg         = [];
cfg.elec = elec;   % sensor information
cfg.channel = elec.label;%;  % the used channels
cfg.sourcemodel    = sourcemodel;   % source points
cfg.headmodel = headmodel;   % volume conduction model
cfg.singleshell.batchsize = 5000; % speeds up the computation
leadfield   = ft_prepare_leadfield(cfg);

cfg               = [];
cfg.method        = 'mne';
cfg.elec = elec;
cfg.grid          = leadfield;
cfg.headmodel     = headmodel;
cfg.mne.prewhiten = 'yes';
cfg.mne.lambda    = 3;
cfg.mne.scalesourcecov = 'yes';
source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);

cfg = [];
cfg.projectmom = 'yes';
sd_C_SHOCK  = ft_sourcedescriptives(cfg,source_C_Shock);
 
cfg = [];
cfg.projectmom = 'yes';
sd_C_NOshock = ft_sourcedescriptives(cfg, source_C_Noshock);
 

 
sdDIFFC         = sd_C_SHOCK;
sdDIFFC.avg.pow = sd_C_SHOCK.avg.pow - sd_C_NOshock.avg.pow;
 

figure
m=sdDIFFC.avg.pow(:,500); % plotting the result at the 450th time-point that is
                         % 500 ms after the zero time-point       
ft_plot_mesh(source_FR_Shock, 'vertexcolor', m);
view([180 0]); 
h = light; 
set(h, 'position', [0 1 0.2]); 
lighting gouraud; 
material dull







---------------------------------------------
Emilie Caspar, Ph.D
 
CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB 
Voice : +32 2 650 32 95 
mail : ecaspar at ulb.ac.be
office: DB10-138 

Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
mail : e.caspar at nin.knaw.nl

> Le 3 avr. 2020 à 19:02, Schoffelen, J.M. (Jan Mathijs) <jan.schoffelen at donders.ru.nl> a écrit :
> 
> Hi Emilie,
> 
> Hmmm, a few pointers:
> 
> Yes, it seems that you are expecting something from ft_sourceinterpolate that the function cannot deliver. In the pasted code you specify that you want to interpolate the parameter ‘elec.chanpos’. This is incorrect. If anything, you can only meaningfully interpolate parameters that are defined with a scalar per source dipole position, and in addition only using fields in a structure that are available in the input data structure. since source_C_Shock by construction should not contain an elec field, this is never going to work. In addition, the elec.chanpos field does not map onto the source dipole positions, so this is the second reason why this is never going to work.
> Also, if I am not mistaken ft_sourceinterpoalte cannot deal with data that are vectors (e.g. source activity time courses) for each source position, so even if you would specify cfg.parameter to be ‘pow’, or ‘avg.pow’ this will probably not work.
> 
> Once again, indeed the tutorial mentions the ’tri’ field as a prerequisite to be able to visualize data in ft_sourcemovie. Since you created your sourcemodel to be a 3D grid, which is volumetric in nature, and not the expected surface description (that is based on a combination of vertex positions (in fieldtrip speak: pos) and faces (in fieldtrip speak: tri)) the visualization you wish for does not work. Hence Eelke’s suggestion to use ft_sourceinterpolate first, which I question as per my comment above.
> 
> Besides, in general I would recommend against using a 3D grid as a sourcemodel when using a distributed inverse modelling approach. The reason for this is that activity is going to be ‘mapped’ onto locations that does not make sense a priori (white matter). 
> 
> Finally, your current results containing a lot of NaNs is perfectly fine, since this corresponds to source dipole locations that lie outside the volume of interest, i.e. outside the head.
> 
> Best wishes,
> Jan-Mathijs
> 
> 
>> On 2 Apr 2020, at 17:33, Emilie Caspar <ecaspar at ulb.ac.be <mailto:ecaspar at ulb.ac.be>> wrote:
>> 
>> Dear Elke and Jan-Mathijs,
>> 
>> Thank you for your answers. So indeed I now understand the problem, but I still have issues to solve that problem. It’s probably something simple to solve but I do not find it. Basically, I have now tried to use the ft_sourceinterpolate, as suggested. As far as I understand, this has to be done after the ft_sourceanalysis. However, I constantly have an issue with cfg_parameters, which should be the positions of the electrodes. I run the following code (full code below):
>> 
>> cfg = [];
>> cfg.parameter = 'elec.chanpos';
>> cfg.interpmethod  = 'nearest';
>> interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)
>>  
>> I get the following error message: "Reference to non-existent field 'elec’. », which I do not get since I do have my ‘elec’ file which is indeed opened, with a .chanpos that contains the positions of the electrodes. 
>> 
>> Perhaps I am doing something wrong with ft_sourceinterpolate. But in fact I am also worried about the fact that the file which results from the ft_sourceanalysis has lots of NaN (see screenshot in attachement) and I am not sure it should be the case or if I should have obtained full data in each case. From the tutorials, the source model have a .tri but I don’t have one in the source model I have created. Perhaps it may also be the source of the issue?
>> 
>> Thank you in advance for your time!
>> 
>> Emilie
>> 
>> <NaN.png>
>> 
>> 
>> load biosemi64.mat
>> q=angles;
>>  
>> ph = cell2mat(q(:,2));
>> th = cell2mat(q(:,3));
>> x = sin(ph*pi/180) .* cos(th*pi/180);
>> y = sin(ph*pi/180) .* sin(th*pi/180);
>> z = cos(ph*pi/180);
>>  
>> plot3(x, y, z, '.');
>> elec.label = q(:,1);
>> elec.pnt = [x y z];
>>  
>> cfg.sourcemodel.pos = elec.pnt;
>> sourcemodel = ft_prepare_sourcemodel(cfg);
>>  
>> headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
>> %electr_pos=ft_read_sens('Biosemi-Cap64.sfp');
>>  
>> %% realign electrodes to headmodel
>> cfg = [];
>> cfg.method = 'interactive';
>> cfg.elec = elec;
>> cfg.headshape = headmodel.bnd(1); %1 = skin
>> elec = ft_electroderealign(cfg);
>>  
>> %save new electrodes
>> save elec64.mat elec
>>  
>> %ERPsAll.elec = ft_read_sens('Biosemi-Cap64.sfp');
>>  
>> % Prepare leadfield
>> cfg                 = [];
>> cfg.elec            = elec;
>> cfg.headmodel             = headmodel;
>> cfg.reducerank      = 3;
>> cfg.resolution = 1;   % use a 3-D grid with a 1 cm resolution
>> cfg.sourcemodel.unit       = 'cm';
>> cfg.channel ={'all'};
>> leadfield = ft_prepare_leadfield(cfg);
>>  
>> %% mne
>> cfg              = [];
>> cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
>> cfg.elec         = elec; %grid.cfg.elec;%
>> cfg.headmodel          = headmodel;
>> cfg.grid = leadfield;
>> %cfg.sourcemodel = sourcemodel;
>> % cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
>> cfg.mne.prewhiten = 'yes';
>> cfg.mne.lambda    = 3;
>> cfg.mne.scalesourcecov = 'yes';
>> %cfg.reducerank          = 2;
>>  
>> source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
>> source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);
>> 
>> cfg = [];
>> cfg.parameter = 'elec.chanpos';
>> cfg.interpmethod  = 'nearest';
>> interp = ft_sourceinterpolate(cfg, source_C_Shock, sourcemodel)
>>  
>> 
>> cfg = [];
>> cfg.projectmom = 'yes';
>> sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
>> sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);
>>  
>> sdDIFF         = sdNoShock;
>> sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
>>  
>> save sd sdDIFF;
>>  
>> cfg = [];
>> cfg.funparameter = 'pow';
>> ft_sourcemovie(cfg,sdDIFF);
>> 
>> 
>> 
>> ---------------------------------------------
>> Emilie Caspar, Ph.D
>>  
>> CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB 
>> Voice : +32 2 650 32 95 
>> mail : ecaspar at ulb.ac.be <mailto:ecaspar at ulb.ac.be>
>> office: DB10-138 
>> 
>> Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
>> mail : e.caspar at nin.knaw.nl <mailto:e.caspar at nin.knaw.nl>
>> 
>>> Le 31 mars 2020 à 12:02, Eelke Spaak <e.spaak at donders.ru.nl <mailto:e.spaak at donders.ru.nl>> a écrit :
>>> 
>>> Hi Emilie,
>>> 
>>> To add to Jan-Mathijs' explanation of why this does not work: you can
>>> use ft_sourceinterpolate to interpolate your volumetric source data
>>> onto a surface, which you can then plot using ft_sourcemovie (or the
>>> newer, though still somewhat experimental, ft_sourceplot_interactive).
>>> 
>>> Best,
>>> Eelke
>>> 
>>> On Tue, 31 Mar 2020 at 11:07, Schoffelen, J.M. (Jan Mathijs)
>>> <jan.schoffelen at donders.ru.nl <mailto:jan.schoffelen at donders.ru.nl>> wrote:
>>>> 
>>>> Hi Emilie,
>>>> 
>>>> ft_sourcemovie has been designed to operate on source level data that is defined on a cortical surface based source model.
>>>> The code you pasted in suggests that you used a 3-dimensional grid as a sourcemodel. So this is never going to work.
>>>> Apparently, you managed to fool the function by post-hoc including a so-called ’tri’ field, which is the hallmark that fieldtrip uses to determine whether the sourcemodel geometry was a mesh or not.
>>>> However, there is no relation whatsoever between the specified triangulation (which you took from the headmodel) and the dipole positions at which your source activity has been estimated.
>>>> 
>>>> Best wishes,
>>>> Jan-Mathijs
>>>> 
>>>> 
>>>> On 31 Mar 2020, at 10:42, Emilie Caspar <ecaspar at ulb.ac.be <mailto:ecaspar at ulb.ac.be>> wrote:
>>>> 
>>>> Dear all,
>>>> 
>>>> I am trying to compute a source reconstruction of different ERPs between two experimental conditions. Well, good news is that the script ‘works’, but the issue is that I am producing contemporary art instead of a brain with ft_sourcemovie (see figure in attachement). The headmodel I used is the standard one available for download. The leadfield I built seems to look like a brain with a correct positions of the electrodes (see also figure in attachement).
>>>> 
>>>> I really have no cue about how I produced such output with ft_sourcemovie and what could possibly be the issue (code is below). If someone can help transforming this to a brain? ;-)
>>>> The only thing that differs (I think) from the tutorial is that I don’t have a headmodel.tri but rather a headmodel.bnd.tri. Don’t know if it makes any difference. Perhaps the sourcespace defined in the tutorial is something different?
>>>> 
>>>> Thank you,
>>>> 
>>>> Emilie
>>>> 
>>>> <ft_sourcemovie.png><leadfield.png><ft_plot_mesh.png>
>>>> 
>>>> CODE
>>>> 
>>>> q=biosim64;
>>>> ph = cell2mat(q(:,2));
>>>> th = cell2mat(q(:,3));
>>>> x = sin(ph*pi/180) .* cos(th*pi/180);
>>>> y = sin(ph*pi/180) .* sin(th*pi/180);
>>>> z = cos(ph*pi/180);
>>>> 
>>>> plot3(x, y, z, '.');
>>>> elec.label = q(:,1);
>>>> elec.pnt = [x y z];
>>>> 
>>>> cfg.sourcemodel.pos = elec.pnt;
>>>> sourcemodel = ft_prepare_sourcemodel(cfg);
>>>> 
>>>> headmodel = ft_read_headmodel('headmodel/standard_bem.mat');
>>>> 
>>>> % realign electrodes to headmodel
>>>> cfg = [];
>>>> cfg.method = 'interactive';
>>>> cfg.elec = elec;
>>>> cfg.headshape = headmodel.bnd(1); %1 = skin
>>>> elec = ft_electroderealign(cfg);
>>>> 
>>>> %save new electrodes
>>>> save elec64.mat elec
>>>> 
>>>> ERPsAll.elec = ft_read_sens('elec64.mat’);
>>>> 
>>>> % Prepare leadfield
>>>> cfg                 = [];
>>>> cfg.elec            = ERPsAll.elec;
>>>> cfg.vol             = headmodel;
>>>> cfg.reducerank      = 3;
>>>> cfg.grid.resolution = 1;   % use a 3-D grid with a 1 cm resolution
>>>> cfg.grid.unit       = 'cm';
>>>> cfg.channel ={'all'};
>>>> leadfield = ft_prepare_leadfield(cfg);
>>>> 
>>>> 
>>>> 
>>>> %%mne
>>>> cfg              = [];
>>>> cfg.method       = 'mne'; %pcc: partial cannonical correlation/coherence
>>>> cfg.elec         = ERPsAll.elec; %grid.cfg.elec;%
>>>> cfg.headmodel          = headmodel;
>>>> cfg.grid = leadfield;
>>>> %cfg.sourcemodel = sourcemodel;
>>>> % cfg.channel ={'all'};%, '-spmnas', '-spmlpa', '-spmrpa'};
>>>> cfg.mne.prewhiten = 'yes';
>>>> cfg.mne.lambda    = 3;
>>>> cfg.mne.scalesourcecov = 'yes';
>>>> %cfg.reducerank          = 2;
>>>> 
>>>> source_C_Shock = ft_sourceanalysis(cfg, GA_C_Shock);
>>>> source_C_Noshock = ft_sourceanalysis(cfg, GA_C_NOshock);
>>>> 
>>>> save source_C_Shock.mat source_C_Shock
>>>> save source_C_Noshock.mat source_C_Noshock
>>>> 
>>>> bnd.pos = headmodel.bnd.pos;
>>>> bnd.tri = headmodel.bnd.tri;
>>>> 
>>>> m=source_C_Shock.avg.pow(:,450);
>>>> %timeN1 = [1232:1301];timeP3 = [1722:1927];timeeLPP = [1928:2356];timelLPP = [2357:2868];
>>>> ft_plot_mesh(bnd, 'vertexcolor', m);
>>>> view([180 0]); h = light; set(h, 'position', [0 1 0.2]); lighting gouraud; material dull
>>>> 
>>>> cfg = [];
>>>> cfg.projectmom = 'yes';
>>>> sdShock  = ft_sourcedescriptives(cfg,source_C_Shock);
>>>> sdNoShock = ft_sourcedescriptives(cfg,source_C_Noshock);
>>>> 
>>>> sdDIFF         = sdNoShock;
>>>> sdDIFF.avg.pow = sdNoShock.avg.pow - sdShock.avg.pow;
>>>> sdDIFF.tri = headmodel.bnd.tri;
>>>> 
>>>> save sd sdDIFF;
>>>> 
>>>> cfg = [];
>>>> cfg.funparameter = 'pow';
>>>> %cfg.method       = 'surface';
>>>> ft_sourcemovie(cfg,sdDIFF);
>>>> 
>>>> 
>>>> ---------------------------------------------
>>>> Emilie Caspar, Ph.D
>>>> 
>>>> CO3, Centre de Recherche Cognition et Neurosciences (CRCN), ULB
>>>> Voice : +32 2 650 32 95
>>>> mail : ecaspar at ulb.ac.be <mailto:ecaspar at ulb.ac.be>
>>>> office: DB10-138
>>>> 
>>>> Social Brain Lab, Netherlands Institute for Neuroscience (NIN), KNAW
>>>> mail : e.caspar at nin.knaw.nl <mailto:e.caspar at nin.knaw.nl>
>>>> 
>>>> _______________________________________________
>>>> fieldtrip mailing list
>>>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
>>>> https://doi.org/10.1371/journal.pcbi.1002202 <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://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
>>> https://doi.org/10.1371/journal.pcbi.1002202 <https://doi.org/10.1371/journal.pcbi.1002202>
>> 
>> _______________________________________________
>> fieldtrip mailing list
>> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <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/20200414/472f1ee8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SourceLoc.jpg
Type: image/jpeg
Size: 98533 bytes
Desc: not available
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200414/472f1ee8/attachment.jpg>

From nathanweisz at me.com  Wed Apr 15 07:25:41 2020
From: nathanweisz at me.com (Nathan Weisz)
Date: Wed, 15 Apr 2020 07:25:41 +0200
Subject: [FieldTrip] The Melcher Lab is recruiting
Message-ID: <A3B4A72A-2C0A-452C-A8D5-E4BDE8C52244@me.com>


Multiple positions available (predoctoral, postdoctoral) in Perception and Active Cognition, NYUAD (EEG/MEG)

Multiple positions will be available for fall 2020 in the Perception and Active Cognition lab, which will be headed by David Melcher, at NYU Abu Dhabi. Starting date is flexible, but we are aiming to bring in new researchers as soon as September, 2020. The appointment will be based at New York University in Abu Dhabi, but we anticipate you may also spend time in New York because of the collaborative nature of the project. The initial appointment is for two years, with the possibility of renewal up to four years total.
 
Research in the Perception and Active Cognition (PAC) laboratory investigates how the brain constructs our subjective experience of the world as we actively engage with our surroundings. We study the interaction of perception, attention, memory and action within a cognitive neuroscience framework. Research in the lab focuses on the role of brain rhythms in temporal aspects of the active perception of objects, scenes and events, the perception of a stable world despite eye movements and the role of attention and awareness in cognition.

Researchers receive a generous and highly competitive salary, plus relocation and housing costs, and will have access to cutting edge research facilities, including MEG, EEG, fMRI, eyetracking and psychophysics laboratories.

The PAC lab is located on the NYUAD campus on Saadiyat Island (Abu Dhabi’s cultural hub), minutes away from the white sand beaches as well as the world class entertainment, big city and nature activities that have made the area one of the top ten tourist destinations in the world. More information about living in Abu Dhabi can be found here: http://nyuad.nyu.edu/en/campus-life/residential-education-and- <http://nyuad.nyu.edu/en/campus-life/residential-education-and->housing/living-in-abu-dhabi.html

For the Postdoctoral Associate positions, applicants must have a Ph.D. in Psychology, Cognitive Neuroscience, or a related field, and should possess strong programming skills (e.g., Python or Matlab). Prior experience with time series data analysis (MEG or EEG) and psychophysical techniques is highly preferred. Postdocs would be expected to focus on either MEG/EEG or fMRI.

The predoctoral Research Assistant position is ideal for a graduating or recently graduated student (Bachelor’s or Research Master’s degree) to gain valuable, hands-on experience in cognitive neuroscience prior to applying for graduate school or industry positions.

Informal inquiries regarding the position, university, or area, are encouraged. To apply online through interfolio, individuals should upload a curriculum vita, a brief statement of research interests, the expected date of availability, and contact information of two referees.

Predoctoral Research assistant: http://apply.interfolio.com/75579 <http://apply.interfolio.com/75579>

Postdoctoral Researcher positions:   http://apply.interfolio.com/75539 <http://apply.interfolio.com/75539> and http://apply.interfolio.com/75540 <http://apply.interfolio.com/75540>

See also: https://nyuad.nyu.edu/en/about/careers/postdoctoral-and-research.html <https://nyuad.nyu.edu/en/about/careers/postdoctoral-and-research.html>

For opportunities for graduate studies (application deadline in December 2020), see further information about the NYU Cognition & Perception Ph.D. program below:

https://as.nyu.edu/content/nyu-as/as/departments/psychology/graduate/phd-cognition-perception.html <https://as.nyu.edu/content/nyu-as/as/departments/psychology/graduate/phd-cognition-perception.html>

All questions and correspondence should be sent to David Melcher (david.melcher at unitn.it <mailto:david.melcher at unitn.it> or dm93 at nyu.edu <mailto:dm93 at nyu.edu>)

New York University has established itself as a Global Network University, a multi-site, organically connected network encompassing key global cities and idea capitals. The network has three foundational degree-granting campuses: New York, Abu Dhabi, and Shanghai, complimented by a network of eleven research and study-away sites across five continents. Faculty and students circulate within this global network in pursuit of common research interests and the promotion of cross-cultural and interdisciplinary solutions for problems both local and global.

Representative publications:
Buonocore A, Dimigen O, Melcher D (2020) Post-saccadic face processing is modulated by pre-saccadic preview: Evidence from fixation-related potentials. Journal of Neuroscience, 40 (11) 2305-2313.
Wutz A, Melcher D, Samaha J (2018) Frequency modulation of neural oscillations according to visual task demands. Proceedings of the National Academy of Sciences, 115 (6) 1346-1351.Ronconi L, Oosterhof
 N, Bonmassar C & Melcher D (2017) Multiple oscillatory rhythms determine the temporal organization of perception. Proceedings of the National Academy of Sciences, 114(51):13435-13440.
Ronconi L & Melcher D (2017) The role of oscillatory phase in determining the temporal organization of perception: evidence from sensory entrainment. Journal of Neuroscience, 37 (44) 10636-10644.
Wutz A, Muschter E, van Koningsbruggen MG, Weisz N & Melcher D (2016) Temporal integration windows in neural processing and perception aligned to saccadic eye movements. Current Biology, 26, 1-10.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200415/fabd0051/attachment.htm>

From ffein at stanford.edu  Wed Apr 15 20:52:14 2020
From: ffein at stanford.edu (Franklin Feingold)
Date: Wed, 15 Apr 2020 18:52:14 +0000
Subject: [FieldTrip] BIDS v1.3.0 release and next focus
Message-ID: <65AFB8A2-B18C-4E2F-9A9E-22B7A9DE00E8@stanford.edu>

The Brain Imaging Data Structure<https://bids.neuroimaging.io/> (BIDS) community is pleased to announce version 1.3.0 of the BIDS standard! This release includes the addition of genetic descriptors<https://bids-specification.readthedocs.io/en/v1.3.0/04-modality-specific-files/08-genetic-descriptor.html> for linking BIDS datasets to genetic datasets. We would like to thank contributors to the Genetic Information BIDS Extension Proposal, led by Cyril Pernet, Clara Moreau with contributions from Tom Nichols and Jessica Turner. We’d also like to thank Arshitha Basavaraj and Tom Nichols for rendering the specification as a PDF<https://zenodo.org/record/3720628#.XpYUPNNKjFQ>.

Our next priority will be finalizing the specification of BIDS-Derivatives<https://github.com/bids-standard/bids-specification/pull/265>. Please feel free to review the draft<https://bids-specification.readthedocs.io/en/common-derivatives/05-derivatives/01-introduction.html> and comment. The specification of spatial references, in particular composite surface/volume spaces, remains an open question<https://github.com/bids-standard/bids-specification/pull/301> with room for expert review.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200415/9531404e/attachment.htm>

From sara.hussain at nih.gov  Thu Apr 16 20:56:25 2020
From: sara.hussain at nih.gov (Hussain, Sara (NIH/NINDS) [F])
Date: Thu, 16 Apr 2020 18:56:25 +0000
Subject: [FieldTrip] DICS beamforming
Message-ID: <347706DB-43B9-47E4-A2A4-F29E0ECD77AD@nih.gov>

I wanted to follow up on this problem in case anyone else was having the same one. I had been following the “Localizing visual gamma and corticomuscular coherence” tutorial, where it stated that the inputs to ft_sourceanalysis should include your leadfield in cfg.sourcemodel. However, after some debugging it become apparent that this was not recognizing the leadfield, and that the leadfield should instead be specific in cfg.grid. This completely solves the problem – and may in fact be a version-related issue.

Hopefully this can help someone else avoid frustration upon encountering a similar error!

From: "Hussain, Sara (NIH/NINDS) [F]" <sara.hussain at nih.gov>
Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Date: Friday, April 10, 2020 at 2:28 PM
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] DICS beamforming

Hi all –

I am trying to source localize some broadband oscillatory data using the ‘dics’ beamforming option, as documented in the tutorial “Localizing visual gamma and corticomuscular coherence.” I am currently using standard mri and segmentation via the fieldtrip templates, and generating a dipole grid with 500 dipoles using the ‘basedonvol’ approach. I then compute the leadfield based on the positions of these dipoles. Up to this point, everything seems ok and checks out during plotting. But when I try to run ft_sourceanalysis I am getting the following error:

Warning: dipole lies on boundary of volume model
> In inf_medium_leadfield (line 54)
  In eeg_leadfieldb (line 92)
  In ft_compute_leadfield (line 443)
  In beamformer_dics (line 305)
  In ft_sourceanalysis (line 674)
Error using svd
Input to SVD must not contain NaN or Inf.

Error in beamformer_dics>pinv (line 643)
  [U,S,V] = svd(A,0);

Error in beamformer_dics (line 336)
        filt = pinv(lf' * invCf * lf) * lf' * invCf;              % Gross eqn. 3, use PINV/SVD
        to cover rank deficient leadfield

Error in ft_sourceanalysis (line 674)
          dip(i) = beamformer_dics(grid, sens, headmodel, [],  squeeze_Cf, optarg{:});


I’ve seen this error asked in other threads but I’ve tried what those suggest with no luck. I’m assuming this has something to do with the fact that the dipoles aren’t fully embedded in the grey matter – but I’ve tried changing the inward shift parameter etc during grid generation and it hasn’t solved it. Any suggestions?  Code is below..

===================

% housekeeping
clearvars
basedir='/net/nindsdirfs.ninds.nih.gov/ifs/shares/HCPS/';
addpath([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718']);
ft_defaults;

% read standard mri
cd([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718/template/headmodel']);
mri=load('standard_mri.mat');
mri=mri.mri;

% read standard segmentation
seg=load('standard_seg.mat');
seg=seg.mri;

% read standard headmodel
vol=load('standard_bem.mat'); %vol
vol=vol.vol;

% create sourcemodel/grid based on standard mri
cfg=[];
cfg.headmodel=vol;
cfg.moveinward=2;
cfg.grid.unit='mm';
grid=ft_prepare_sourcemodel(cfg);

% check segmentation
seg.transform=mri.transform;
seg.anatomy=mri.anatomy;
cfg=[];
cfg.funparameter='gray';
ft_sourceplot(cfg,seg);
pause; close all;

% check volume conduction model
figure; ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain
figure; ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull
figure; ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp
pause; close all;

% check electrode positions
figure;
elec=ft_read_sens('standard_1005.elc','senstype','eeg');
ft_plot_mesh(vol.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.4,'edgecolor','none','edgealpha',0.05); hold on;
ft_plot_mesh(vol.bnd(2),'edgecolor','none','facealpha',0.4);
ft_plot_mesh(vol.bnd(1),'edgecolor','none','facecolor',[0.4 0.6 0.4]);
ft_plot_sens(elec,'label','yes');
pause; close all

% check grid position
figure;
ft_plot_mesh(vol.bnd(3),'edgecolor','none'); hold on; alpha 0.4; %brain
ft_plot_mesh(grid.pos(grid.inside,:));
pause; close all;

% load data
cd([basedir 'SaraHussain/SS_42H_63/clean_tep_data']);
load([peak_subj{jjj} '_double_cleaned_peak.mat']);

% demean/detrend and update channel names
cfg=[];
cfg.demean='yes';
cfg.detrend='yes';
data=ft_preprocessing(cfg,clean_data);
data.label=labels;

% select relevant post-stim latencies and channels
cfg=[];
short=ft_selectdata(cfg,data);

% calculate post-stim frequency using mtmfft approach
cfg=[];
cfg.method='mtmfft';
cfg.output='powandcsd';
cfg.tapsmofrq=48;
cfg.foi=52;
peak=ft_freqanalysis(cfg,short);

% create leadfield
cfg=[];
cfg.headmodel=vol;
cfg.grid.pos=grid.pos;
cfg.grid.inside=grid.inside;
cfg.elec=elec;
lead=ft_prepare_leadfield(cfg,peak);

% get source localized data
cfg=[];
cfg.elec=elec;
cfg.method='dics';
cfg.sourcemodel=lead;
cfg.headmodel=vol;
source_peak=ft_sourceanalysis(cfg,peak);






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200416/753f1cea/attachment.htm>

From pierpaolo12croce at gmail.com  Thu Apr 16 21:59:27 2020
From: pierpaolo12croce at gmail.com (Pierpaolo Croce)
Date: Thu, 16 Apr 2020 21:59:27 +0200
Subject: [FieldTrip] dipoli algrithm
Message-ID: <CALkLzZ7ukpzGe2Xp5aT=f1gshun88krmNiEmfPoSdOASUrivYQ@mail.gmail.com>

I'm trying to use dipoli algorithm for BEM generation using the function:

cfg = [];

cfg.method='dipoli';

cfg.spmversion = 'spm12'

vol = ft_prepare_headmodel(cfg, segmentedmri)


I get the following error:


using the executable
"/Users/pp/Documents/MATLAB/fieldtrip-20200408/external/dipoli/dipoli.maci"
/private/var/folders/bp/tc3bps1s72v2s4rqd82k1w8h0000gn/T/tp6c367f3f_b5f6_4086_8ccc_eed138d85f7c.sh:
line 3:
/Users/pp/Documents/MATLAB/fieldtrip-20200408/external/dipoli/dipoli.maci:
Bad CPU type in executable
Error using ft_headmodel_dipoli (line 211)
an error ocurred while running the dipoli executable - please look at the
screen output


Can some one help me in solving this problem?

-- 

Ing. Pierpaolo Croce, PhD.
Institute for Advanced Biomedical Technologies - ITAB
and
Department of Neuroscience and Imaging
University of Chieti "G. D'Annunzio"
Via dei Vestini, 33
66013 Chieti, Italy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200416/57e42c8b/attachment.htm>

From huiyu_kang at fudan.edu.cn  Fri Apr 17 04:16:25 2020
From: huiyu_kang at fudan.edu.cn (=?utf-8?Q?huiyu=5Fkang?=)
Date: Fri, 17 Apr 2020 10:16:25 +0800
Subject: [FieldTrip] =?utf-8?q?Post-doc_Positions_=7C_Neural_and_Intellig?=
 =?utf-8?q?ence_Engineering_Center=2C_Institute_of_Science_and_Technology_?=
 =?utf-8?q?for_Brain-inspired_Intelligence?=
Message-ID: <85E68B8D-5A2B-49E2-A68C-6037D6D30F5B@fudan.edu.cn>

An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200417/77c0d308/attachment.htm>

From huiyu_kang at fudan.edu.cn  Fri Apr 17 04:18:16 2020
From: huiyu_kang at fudan.edu.cn (=?utf-8?Q?huiyu=5Fkang?=)
Date: Fri, 17 Apr 2020 10:18:16 +0800
Subject: [FieldTrip] =?utf-8?q?=5BEXTERNAL=5D_One_week_until_NYC_Neuromod?=
 =?utf-8?q?ulation_2020_Online_Conference?=
Message-ID: <A7660BDF-D96E-4D76-B839-12B0E57C2358@fudan.edu.cn>

An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200417/50caff4e/attachment.htm>

From e.spaak at donders.ru.nl  Fri Apr 17 11:01:11 2020
From: e.spaak at donders.ru.nl (Eelke Spaak)
Date: Fri, 17 Apr 2020 11:01:11 +0200
Subject: [FieldTrip] DICS beamforming
In-Reply-To: <347706DB-43B9-47E4-A2A4-F29E0ECD77AD@nih.gov>
References: <347706DB-43B9-47E4-A2A4-F29E0ECD77AD@nih.gov>
Message-ID: <CABPNLUoSy0cuDmRb-ZN00SQvCikvsBMj7hpCpy6S2HiH--jcrA@mail.gmail.com>

Hi Sara,

Thanks for following up! It's very likely that this is indeed a
version-related issue. cfg.sourcemodel is the correct configuration
parameter, cfg.grid has been deprecated for a long time (several
years) now. So, if you are using a recent version of FieldTrip then it
should indeed be cfg.sourcemodel.

Best,
Eelke



On Thu, 16 Apr 2020 at 20:56, Hussain, Sara (NIH/NINDS) [F]
<sara.hussain at nih.gov> wrote:
>
> I wanted to follow up on this problem in case anyone else was having the same one. I had been following the “Localizing visual gamma and corticomuscular coherence” tutorial, where it stated that the inputs to ft_sourceanalysis should include your leadfield in cfg.sourcemodel. However, after some debugging it become apparent that this was not recognizing the leadfield, and that the leadfield should instead be specific in cfg.grid. This completely solves the problem – and may in fact be a version-related issue.
>
>
>
> Hopefully this can help someone else avoid frustration upon encountering a similar error!
>
>
>
> From: "Hussain, Sara (NIH/NINDS) [F]" <sara.hussain at nih.gov>
> Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Date: Friday, April 10, 2020 at 2:28 PM
> To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
> Subject: [FieldTrip] DICS beamforming
>
>
>
> Hi all –
>
>
>
> I am trying to source localize some broadband oscillatory data using the ‘dics’ beamforming option, as documented in the tutorial “Localizing visual gamma and corticomuscular coherence.” I am currently using standard mri and segmentation via the fieldtrip templates, and generating a dipole grid with 500 dipoles using the ‘basedonvol’ approach. I then compute the leadfield based on the positions of these dipoles. Up to this point, everything seems ok and checks out during plotting. But when I try to run ft_sourceanalysis I am getting the following error:
>
>
>
> Warning: dipole lies on boundary of volume model
>
> > In inf_medium_leadfield (line 54)
>
>   In eeg_leadfieldb (line 92)
>
>   In ft_compute_leadfield (line 443)
>
>   In beamformer_dics (line 305)
>
>   In ft_sourceanalysis (line 674)
>
> Error using svd
>
> Input to SVD must not contain NaN or Inf.
>
>
>
> Error in beamformer_dics>pinv (line 643)
>
>   [U,S,V] = svd(A,0);
>
>
>
> Error in beamformer_dics (line 336)
>
>         filt = pinv(lf' * invCf * lf) * lf' * invCf;              % Gross eqn. 3, use PINV/SVD
>
>         to cover rank deficient leadfield
>
>
>
> Error in ft_sourceanalysis (line 674)
>
>           dip(i) = beamformer_dics(grid, sens, headmodel, [],  squeeze_Cf, optarg{:});
>
>
>
>
>
> I’ve seen this error asked in other threads but I’ve tried what those suggest with no luck. I’m assuming this has something to do with the fact that the dipoles aren’t fully embedded in the grey matter – but I’ve tried changing the inward shift parameter etc during grid generation and it hasn’t solved it. Any suggestions?  Code is below..
>
>
>
> ===================
>
>
>
> % housekeeping
>
> clearvars
>
> basedir='/net/nindsdirfs.ninds.nih.gov/ifs/shares/HCPS/';
>
> addpath([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718']);
>
> ft_defaults;
>
>
>
> % read standard mri
>
> cd([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718/template/headmodel']);
>
> mri=load('standard_mri.mat');
>
> mri=mri.mri;
>
>
>
> % read standard segmentation
>
> seg=load('standard_seg.mat');
>
> seg=seg.mri;
>
>
>
> % read standard headmodel
>
> vol=load('standard_bem.mat'); %vol
>
> vol=vol.vol;
>
>
>
> % create sourcemodel/grid based on standard mri
>
> cfg=[];
>
> cfg.headmodel=vol;
>
> cfg.moveinward=2;
>
> cfg.grid.unit='mm';
>
> grid=ft_prepare_sourcemodel(cfg);
>
>
>
> % check segmentation
>
> seg.transform=mri.transform;
>
> seg.anatomy=mri.anatomy;
>
> cfg=[];
>
> cfg.funparameter='gray';
>
> ft_sourceplot(cfg,seg);
>
> pause; close all;
>
>
>
> % check volume conduction model
>
> figure; ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain
>
> figure; ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull
>
> figure; ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp
>
> pause; close all;
>
>
>
> % check electrode positions
>
> figure;
>
> elec=ft_read_sens('standard_1005.elc','senstype','eeg');
>
> ft_plot_mesh(vol.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.4,'edgecolor','none','edgealpha',0.05); hold on;
>
> ft_plot_mesh(vol.bnd(2),'edgecolor','none','facealpha',0.4);
>
> ft_plot_mesh(vol.bnd(1),'edgecolor','none','facecolor',[0.4 0.6 0.4]);
>
> ft_plot_sens(elec,'label','yes');
>
> pause; close all
>
>
>
> % check grid position
>
> figure;
>
> ft_plot_mesh(vol.bnd(3),'edgecolor','none'); hold on; alpha 0.4; %brain
>
> ft_plot_mesh(grid.pos(grid.inside,:));
>
> pause; close all;
>
>
>
> % load data
>
> cd([basedir 'SaraHussain/SS_42H_63/clean_tep_data']);
>
> load([peak_subj{jjj} '_double_cleaned_peak.mat']);
>
>
>
> % demean/detrend and update channel names
>
> cfg=[];
>
> cfg.demean='yes';
>
> cfg.detrend='yes';
>
> data=ft_preprocessing(cfg,clean_data);
>
> data.label=labels;
>
>
>
> % select relevant post-stim latencies and channels
>
> cfg=[];
>
> short=ft_selectdata(cfg,data);
>
>
>
> % calculate post-stim frequency using mtmfft approach
>
> cfg=[];
>
> cfg.method='mtmfft';
>
> cfg.output='powandcsd';
>
> cfg.tapsmofrq=48;
>
> cfg.foi=52;
>
> peak=ft_freqanalysis(cfg,short);
>
>
>
> % create leadfield
>
> cfg=[];
>
> cfg.headmodel=vol;
>
> cfg.grid.pos=grid.pos;
>
> cfg.grid.inside=grid.inside;
>
> cfg.elec=elec;
>
> lead=ft_prepare_leadfield(cfg,peak);
>
>
>
> % get source localized data
>
> cfg=[];
>
> cfg.elec=elec;
>
> cfg.method='dics';
>
> cfg.sourcemodel=lead;
>
> cfg.headmodel=vol;
>
> source_peak=ft_sourceanalysis(cfg,peak);
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202



From sara.hussain at nih.gov  Fri Apr 17 14:05:57 2020
From: sara.hussain at nih.gov (Hussain, Sara (NIH/NINDS) [F])
Date: Fri, 17 Apr 2020 12:05:57 +0000
Subject: [FieldTrip] DICS beamforming
In-Reply-To: <CABPNLUoSy0cuDmRb-ZN00SQvCikvsBMj7hpCpy6S2HiH--jcrA@mail.gmail.com>
References: <347706DB-43B9-47E4-A2A4-F29E0ECD77AD@nih.gov>
 <CABPNLUoSy0cuDmRb-ZN00SQvCikvsBMj7hpCpy6S2HiH--jcrA@mail.gmail.com>
Message-ID: <3FAD42A3-2847-409A-AA05-1A94BFE5AD50@nih.gov>

Yes, I use a version from 2016 so that is likely the issue. Thanks Eelke!

﻿On 4/17/20, 5:57 AM, "Eelke Spaak" <e.spaak at donders.ru.nl> wrote:

    Hi Sara,
    
    Thanks for following up! It's very likely that this is indeed a
    version-related issue. cfg.sourcemodel is the correct configuration
    parameter, cfg.grid has been deprecated for a long time (several
    years) now. So, if you are using a recent version of FieldTrip then it
    should indeed be cfg.sourcemodel.
    
    Best,
    Eelke
    
    
    
    On Thu, 16 Apr 2020 at 20:56, Hussain, Sara (NIH/NINDS) [F]
    <sara.hussain at nih.gov> wrote:
    >
    > I wanted to follow up on this problem in case anyone else was having the same one. I had been following the “Localizing visual gamma and corticomuscular coherence” tutorial, where it stated that the inputs to ft_sourceanalysis should include your leadfield in cfg.sourcemodel. However, after some debugging it become apparent that this was not recognizing the leadfield, and that the leadfield should instead be specific in cfg.grid. This completely solves the problem – and may in fact be a version-related issue.
    >
    >
    >
    > Hopefully this can help someone else avoid frustration upon encountering a similar error!
    >
    >
    >
    > From: "Hussain, Sara (NIH/NINDS) [F]" <sara.hussain at nih.gov>
    > Reply-To: FieldTrip discussion list <fieldtrip at science.ru.nl>
    > Date: Friday, April 10, 2020 at 2:28 PM
    > To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
    > Subject: [FieldTrip] DICS beamforming
    >
    >
    >
    > Hi all –
    >
    >
    >
    > I am trying to source localize some broadband oscillatory data using the ‘dics’ beamforming option, as documented in the tutorial “Localizing visual gamma and corticomuscular coherence.” I am currently using standard mri and segmentation via the fieldtrip templates, and generating a dipole grid with 500 dipoles using the ‘basedonvol’ approach. I then compute the leadfield based on the positions of these dipoles. Up to this point, everything seems ok and checks out during plotting. But when I try to run ft_sourceanalysis I am getting the following error:
    >
    >
    >
    > Warning: dipole lies on boundary of volume model
    >
    > > In inf_medium_leadfield (line 54)
    >
    >   In eeg_leadfieldb (line 92)
    >
    >   In ft_compute_leadfield (line 443)
    >
    >   In beamformer_dics (line 305)
    >
    >   In ft_sourceanalysis (line 674)
    >
    > Error using svd
    >
    > Input to SVD must not contain NaN or Inf.
    >
    >
    >
    > Error in beamformer_dics>pinv (line 643)
    >
    >   [U,S,V] = svd(A,0);
    >
    >
    >
    > Error in beamformer_dics (line 336)
    >
    >         filt = pinv(lf' * invCf * lf) * lf' * invCf;              % Gross eqn. 3, use PINV/SVD
    >
    >         to cover rank deficient leadfield
    >
    >
    >
    > Error in ft_sourceanalysis (line 674)
    >
    >           dip(i) = beamformer_dics(grid, sens, headmodel, [],  squeeze_Cf, optarg{:});
    >
    >
    >
    >
    >
    > I’ve seen this error asked in other threads but I’ve tried what those suggest with no luck. I’m assuming this has something to do with the fact that the dipoles aren’t fully embedded in the grey matter – but I’ve tried changing the inward shift parameter etc during grid generation and it hasn’t solved it. Any suggestions?  Code is below..
    >
    >
    >
    > ===================
    >
    >
    >
    > % housekeeping
    >
    > clearvars
    >
    > basedir='/net/nindsdirfs.ninds.nih.gov/ifs/shares/HCPS/';
    >
    > addpath([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718']);
    >
    > ft_defaults;
    >
    >
    >
    > % read standard mri
    >
    > cd([basedir 'SaraHussain/Analysis_Tools/fieldtrip-20160718/template/headmodel']);
    >
    > mri=load('standard_mri.mat');
    >
    > mri=mri.mri;
    >
    >
    >
    > % read standard segmentation
    >
    > seg=load('standard_seg.mat');
    >
    > seg=seg.mri;
    >
    >
    >
    > % read standard headmodel
    >
    > vol=load('standard_bem.mat'); %vol
    >
    > vol=vol.vol;
    >
    >
    >
    > % create sourcemodel/grid based on standard mri
    >
    > cfg=[];
    >
    > cfg.headmodel=vol;
    >
    > cfg.moveinward=2;
    >
    > cfg.grid.unit='mm';
    >
    > grid=ft_prepare_sourcemodel(cfg);
    >
    >
    >
    > % check segmentation
    >
    > seg.transform=mri.transform;
    >
    > seg.anatomy=mri.anatomy;
    >
    > cfg=[];
    >
    > cfg.funparameter='gray';
    >
    > ft_sourceplot(cfg,seg);
    >
    > pause; close all;
    >
    >
    >
    > % check volume conduction model
    >
    > figure; ft_plot_mesh(vol.bnd(3),'facecolor','none'); %brain
    >
    > figure; ft_plot_mesh(vol.bnd(2),'facecolor','none'); %skull
    >
    > figure; ft_plot_mesh(vol.bnd(1),'facecolor','none'); %scalp
    >
    > pause; close all;
    >
    >
    >
    > % check electrode positions
    >
    > figure;
    >
    > elec=ft_read_sens('standard_1005.elc','senstype','eeg');
    >
    > ft_plot_mesh(vol.bnd(3),'edgecolor','none','facecolor',[0.2 0.2 0.2],'facealpha',0.4,'edgecolor','none','edgealpha',0.05); hold on;
    >
    > ft_plot_mesh(vol.bnd(2),'edgecolor','none','facealpha',0.4);
    >
    > ft_plot_mesh(vol.bnd(1),'edgecolor','none','facecolor',[0.4 0.6 0.4]);
    >
    > ft_plot_sens(elec,'label','yes');
    >
    > pause; close all
    >
    >
    >
    > % check grid position
    >
    > figure;
    >
    > ft_plot_mesh(vol.bnd(3),'edgecolor','none'); hold on; alpha 0.4; %brain
    >
    > ft_plot_mesh(grid.pos(grid.inside,:));
    >
    > pause; close all;
    >
    >
    >
    > % load data
    >
    > cd([basedir 'SaraHussain/SS_42H_63/clean_tep_data']);
    >
    > load([peak_subj{jjj} '_double_cleaned_peak.mat']);
    >
    >
    >
    > % demean/detrend and update channel names
    >
    > cfg=[];
    >
    > cfg.demean='yes';
    >
    > cfg.detrend='yes';
    >
    > data=ft_preprocessing(cfg,clean_data);
    >
    > data.label=labels;
    >
    >
    >
    > % select relevant post-stim latencies and channels
    >
    > cfg=[];
    >
    > short=ft_selectdata(cfg,data);
    >
    >
    >
    > % calculate post-stim frequency using mtmfft approach
    >
    > cfg=[];
    >
    > cfg.method='mtmfft';
    >
    > cfg.output='powandcsd';
    >
    > cfg.tapsmofrq=48;
    >
    > cfg.foi=52;
    >
    > peak=ft_freqanalysis(cfg,short);
    >
    >
    >
    > % create leadfield
    >
    > cfg=[];
    >
    > cfg.headmodel=vol;
    >
    > cfg.grid.pos=grid.pos;
    >
    > cfg.grid.inside=grid.inside;
    >
    > cfg.elec=elec;
    >
    > lead=ft_prepare_leadfield(cfg,peak);
    >
    >
    >
    > % get source localized data
    >
    > cfg=[];
    >
    > cfg.elec=elec;
    >
    > cfg.method='dics';
    >
    > cfg.sourcemodel=lead;
    >
    > cfg.headmodel=vol;
    >
    > source_peak=ft_sourceanalysis(cfg,peak);
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > _______________________________________________
    > 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
    




From giorgio.arcara at gmail.com  Fri Apr 17 16:01:21 2020
From: giorgio.arcara at gmail.com (Giorgio Arcara)
Date: Fri, 17 Apr 2020 16:01:21 +0200
Subject: [FieldTrip] Post-doc positions at S. Camillo IRCCS Research Center
 in Venice, Italy.
Message-ID: <CAEwiN=LMDRsaXFKOyTQ_F0gqZyqU82irqiYuLL+obL6Z_eZVUw@mail.gmail.com>

*4 post-doc positions at S. Camillo IRCCS Research Center in Venice, Italy.*

The *San Camillo IRCCS* is a clinical and research center accredited by the
Italian Ministry of Health for the *study and treatment of neurological
patients*. It is the hub of a large neuroscientific and health care
network, serving more than five million people in Venice-Veneto region,
Italy.

We are looking for brilliant post-doctoral researchers with background in
neuroscience, neurology, and engineering interested in working in the
fields of translational neuroimaging, non-invasive brain stimulation,
advanced neurophysiology, computational neuroscience.

You can apply to work directly/in collaboration with: *Dante Mantini,
Giorgio Arcara, Giovanni Pellegrino, Daniele Marinazzo *(Ghent University).

Research activities are conducted in Venice and in collaboration with other
internationally renowned partners (i.e. University of Padua, Leuven
University, Montreal Neurological Institute - McGill University, and more).

You will have access to the following in-home equipment: simultaneous
EEG-MEG (300+ sensors), 3T MRI scanner (Philips), hd-EEG (several systems,
up to 250 channels), TMS (3 machines for all types of stimulations),
tDCS/tACS (several, including high-resolution stimulation and simultaneous
tDCS/EEG), near-infrared spectroscopy, two neuronavigation systems (optic
and magnetic), eye tracking, BCI, instrumentation for simultaneous TMS-EEG
and simultaneous EEG-fMRI, BCI and much more. In home genetic profiling
will be soon available as well.

*Salary and benefit package*: Gross annual salary: 21000 to 30000 euros,
depending on experience. Duration: 2 years renewable up to 5 years  *Benefit
package*: free access to private beach, full public health coverage,
administrative assistance for newcomers, working time flexibility and
possibility of remote/smart working, possibility of free/cheap on site
housing, free/cheap on site hosting of visitors/collaborators/friends,
welcome package with Venice transportation pass / Visitor card / City tour,
free one-to-one or group Italian class, generous annual research allowance,
travel/conference/training/IT, public transportation pass, cheap cantine
(1.5E/meal).

*To apply*, send a CV, brief research interest statement (10 lines is
enough), as well as names and email addresses of 1-2 references to Dante
Mantini (Scientific Director, dante.mantini at hsancamillo.it ) and PI of your
choice. Knowledge of Italian is an advantage, but is not required. The call
will remain open until all positions are filled.

S. Camillo IRCCS is committed to equal opportunity employment and seeks
qualified candidates for all posted employment opportunities without regard
to race, color, age, religion, gender, national origin, disability or other
status.

Additional contact info: giorgio.arcara at gmail.com;
giovannipellegrino at gmail.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200417/05ee41e5/attachment.htm>

From pdhami06 at gmail.com  Sat Apr 18 20:14:06 2020
From: pdhami06 at gmail.com (Paul Dhami)
Date: Sat, 18 Apr 2020 14:14:06 -0400
Subject: [FieldTrip] 3 x 2 Mixed ANOVA or MANOVA?
Message-ID: <CABqnCmCV2221Pbv3_c-3Pi=dNTXy5LhH_kbJAuVkg2Pa7wQT8Q@mail.gmail.com>

Dear FieldTrip community,

I have a dataset with a between (3 groups) and within (2 time points)
factors. I would like to test for an interaction effect in a mixed 3 x 2
ANOVA context. I came across this post:
https://mailman.science.ru.nl/pipermail/fieldtrip/2016-July/036592.html

The post suggests that to test for an interaction effect in this scenario,
I would take the difference across the 2 time points for each group, and
run a one-way ANOVA. Then to test for main effects, I would collapse the
appropriate factors.

I just was hoping to confirm with the community if this would be the
correct approach in my case? Or would I need to implement a MANOVA in my
case (as seems to be implied here:
http://www.fieldtriptoolbox.org/faq/how_can_i_test_an_interaction_effect_using_cluster-based_permutation_tests/

Best,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200418/8736b163/attachment.htm>

From anni_jo at web.de  Tue Apr 21 09:39:13 2020
From: anni_jo at web.de (anni_jo at web.de)
Date: Tue, 21 Apr 2020 09:39:13 +0200
Subject: [FieldTrip] stat tetsing of connectivity analysis
Message-ID: <trinity-e5842da1-a881-4807-b7be-842e81f5bd29-1587454753968@3c-app-webde-bs01>

An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200421/e0913477/attachment.htm>

From tony.w.wilson at gmail.com  Wed Apr 22 12:53:39 2020
From: tony.w.wilson at gmail.com (Tony W. Wilson)
Date: Wed, 22 Apr 2020 05:53:39 -0500
Subject: [FieldTrip] Postdoc Positions in Omaha, USA
Message-ID: <CAON5n1uv68ydap-6h4TUeDfGSASvzCdKpyx9L_TwAL8gN59Dsg@mail.gmail.com>

Sorry for cross-posting. We have three open postdoctoral positions. Area of
research focus is flexible, but demonstrated expertise in neuroimaging,
statistical modeling, and/or cognitive neuroscience is essential.
Applicants with previous experience in developmental psychology and/or
aging neuroscience will be given preference. However, we have a broad
umbrella of existing projects and primarily seek the best candidates to
join our team. Major research-dedicated tools in the laboratory include a
306-sensor MEG system (MEGIN), a 3T Siemens Prisma magnet,
high-definition transcranial direct-current and alternating-current
stimulation (HD-tDCS/tACS) equipment,
and extensive support staff for neuropsychological testing and recruitment.



Successful candidates will have a MD, PhD, or MD/PhD in neuroscience,
psychology, computer science, or a related field, with an excellent
publication record for their career stage. They will join a
vibrant and growing group of cognitive neuroscientists in Omaha using
state-of-the-art neuroimaging equipment and resources, with ample local
opportunities for career development and promotion to faculty through a
newly awarded P20 Center for Cognitive Neuroscience. A list of recent
publications can be found here <https://diconlab.org/publications/>.



Please submit a curriculum vitae or NIH biosketch and a one-page cover
letter detailing research experience and goals. Reference letters will be
requested at a later time. Applications should be submitted online at:
https://unmc.peopleadmin.com/postings/40453. Review of applications will
begin immediately and continue until the positions are filled. Start dates
are negotiable, but could be as early as May 1, 2020 or as late mid-2021.
Salary commensurate with experience level, following NIH guidance.



For further information: see https://DiconLab.org <https://diconlab.org/>




_____________________________________________________________
Tony W. Wilson, Ph.D.
Associate Professor, Department of Neurological Sciences
Director, Center for Magnetoencephalography (MEG)
Director, Core for Advanced Magnetic Resonance Imaging (CAMRI)
Vice Chair, Basic & Translational Research
University of Nebraska Medical Center
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200422/cd6a25a9/attachment.htm>

From puszta.andris at gmail.com  Wed Apr 22 13:19:37 2020
From: puszta.andris at gmail.com (=?UTF-8?Q?Andr=C3=A1s_Puszta?=)
Date: Wed, 22 Apr 2020 13:19:37 +0200
Subject: [FieldTrip] stat tetsing of connectivity analysis
In-Reply-To: <trinity-e5842da1-a881-4807-b7be-842e81f5bd29-1587454753968@3c-app-webde-bs01>
References: <trinity-e5842da1-a881-4807-b7be-842e81f5bd29-1587454753968@3c-app-webde-bs01>
Message-ID: <CAH-KfLydQ7QaVwPE_dHeSZ=3G8AUXJRrmLH+Ow5LKfv=ydoZzA@mail.gmail.com>

 Hi Anni,

You might try topoplot_connect
https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/32563/versions/2/previews/topoplot_connect.m/index.html
Hope it helps

Andras

<anni_jo at web.de> ezt írta (időpont: 2020. ápr. 21., K, 9:56):

> Dear Community,
>
> I have run a connectivity analysis using cfg.paramter = wpli with all
> possible channel combinations and several timepoints for 23 subjects.
> Now my aim is to test the result statistically for significance, which I
> have done by using cfg.statistic = depsamplesT over montecarlo simulations.
> I have received a tf_stat struct with the usual fiels "prob", "mask",
> "stat" and so on. Now my question ist, how do I plot most effectively the
> results? For plotting I would choose "prob", furthermore I was thinking
> about a topoplot, but this is denied by the error message "Array indices
> must be positive integers or logical values."
> Do you have any suggestions for any kinf of plotting those statistical
> results?
>
> Thank you so much, every suggestiong will be appreciated,
> best,
> Anni
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202
>


-- 
András Puszta MD, PhD
Helgeland Hospital / Univerity of Oslo
Department of Neuropsychology
Skjervengan 17 8657 Mosjøen, Norway
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200422/ceb73436/attachment.htm>

From parkerjo at stanford.edu  Wed Apr 22 20:12:11 2020
From: parkerjo at stanford.edu (Jonathon James Parker)
Date: Wed, 22 Apr 2020 18:12:11 +0000
Subject: [FieldTrip] Difficulty using "plotfiltresp" --- trying to plot
 frequency response curve on my data
Message-ID: <80B32BBD-0307-40A7-AF2E-DEE86E9994D8@stanford.edu>

Hi Fieldtrippers:

I am interested in looking at the Frequency response curve after applying different filter types to extract high-gamma band (70-170Hz) in my dataset.

I have used the cfg.plotfiltresp = ‘yes’ flag in running preprocessing on a subset of my data. The call to ft_preprocessing runs without issue, but there is no plot of the filter response curve.

Here is an example of the cfg I am using for the call to ft_preprocessing


 cfgi = [];

    cfgi.bpfilter = 'yes';

    cfgi.bpfreq = [l70 170];

    cfgi.bpfilttype = 'but';

    cfgi.bpinstabilityfix = 'reduce';

    cfgi.bpfiltrord = 8;

    cfgi.poltfiltresp = ‘yes’;





I searched the code of ft_preprocessing and only see the “plotfiltresp” referenced in handling the cfg. flag, thus I am guessing this parameter is simply passed to a lower level pre_proc function depending on the filter type.

Has anyone else had this problem and can offer advice on how to get this functionality to work?

I am running Fieldtrip August 2019 build.

Hope everyone is staying healthy.

Kindest regards and thank you,

Jonathon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jonathon “JP" Parker MD, PhD
Resident in Neurosurgery | PGY5
Morgridge Endowed Postdoctoral Fellow
Maternal & Child Health Research Institute
Department of Neurosurgery
Stanford University
E: parkerjo at stanford.edu




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200422/019ddd28/attachment.htm>

From jan.schoffelen at donders.ru.nl  Wed Apr 22 20:29:21 2020
From: jan.schoffelen at donders.ru.nl (Schoffelen, J.M. (Jan Mathijs))
Date: Wed, 22 Apr 2020 18:29:21 +0000
Subject: [FieldTrip] Difficulty using "plotfiltresp" --- trying to plot
 frequency response curve on my data
In-Reply-To: <80B32BBD-0307-40A7-AF2E-DEE86E9994D8@stanford.edu>
References: <80B32BBD-0307-40A7-AF2E-DEE86E9994D8@stanford.edu>
Message-ID: <8D02F2B0-C330-4E69-AE45-48FC5AD6C771@donders.ru.nl>

Hi Jonathon,
There’s a typo in the cfg specification: cfg.poltfiltresp should read: cfg.plotfiltresp.

Best wishes,
JM


On 22 Apr 2020, at 20:12, Jonathon James Parker <parkerjo at stanford.edu<mailto:parkerjo at stanford.edu>> wrote:

Hi Fieldtrippers:

I am interested in looking at the Frequency response curve after applying different filter types to extract high-gamma band (70-170Hz) in my dataset.

I have used the cfg.plotfiltresp = ‘yes’ flag in running preprocessing on a subset of my data. The call to ft_preprocessing runs without issue, but there is no plot of the filter response curve.

Here is an example of the cfg I am using for the call to ft_preprocessing

 cfgi = [];
    cfgi.bpfilter = 'yes';
    cfgi.bpfreq = [l70 170];
    cfgi.bpfilttype = 'but';
    cfgi.bpinstabilityfix = 'reduce';
    cfgi.bpfiltrord = 8;
    cfgi.poltfiltresp = ‘yes’;



I searched the code of ft_preprocessing and only see the “plotfiltresp” referenced in handling the cfg. flag, thus I am guessing this parameter is simply passed to a lower level pre_proc function depending on the filter type.

Has anyone else had this problem and can offer advice on how to get this functionality to work?

I am running Fieldtrip August 2019 build.

Hope everyone is staying healthy.

Kindest regards and thank you,

Jonathon

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jonathon “JP" Parker MD, PhD
Resident in Neurosurgery | PGY5
Morgridge Endowed Postdoctoral Fellow
Maternal & Child Health Research Institute
Department of Neurosurgery
Stanford University
E: parkerjo at stanford.edu<mailto:parkerjo at stanford.edu>




_______________________________________________
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/20200422/c9edc6c2/attachment.htm>

From jan.schoffelen at donders.ru.nl  Thu Apr 23 07:56:55 2020
From: jan.schoffelen at donders.ru.nl (Schoffelen, J.M. (Jan Mathijs))
Date: Thu, 23 Apr 2020 05:56:55 +0000
Subject: [FieldTrip] Fwd: Source localisation mom results
References: <EF3CE54F-7F48-4AB9-ABA0-7A6E69D3CBA3@auckland.ac.nz>
Message-ID: <59596F30-D4D2-4DF5-908D-D02FB0A26DB3@donders.ru.nl>

Dear Xavier,

Thanks for your message. Let me forward your questions to the fieldtrip discussion list. If you haven’t signed up yet, please do so (http://www.fieldtriptoolbox.org/discussion_list/).

I prefer to have the interaction through the list, because then more people will benefit from the discussion. Also, other people who have an opinion about the questions can also chime in. Both points make the transfer of knowledge more efficient.

At the moment, I don’t have much time to look in detail at your questions, since we are running our annual toolkit course at the Donders Centre right now (this year for the first time fully online). Therefore, I hope that somebody reading this might pick up on your message.

Some quick pointers:
1.  It depends on the connectivity metric of interest, but for most I’d compute the source level data for the frequency filtered signals (assuming a beamformer). When you’d be using a distributed source modelling approach (e.g. minimum norm estimate) the order probably doesn’t matter too much.
2. No, 2 different measurements are likely too different (different electrode positions, SNR characteristics etc), so that appending them before the source reconstruction does not make sense.
3. I did not check in detail, but your descriptions looks OK. This would be one way to get ‘parcellated’ results.
4. In it’s ’naive’ (i.e. without additional settings) application the beamformer has a well-known ‘depth bias’, resulting in a large dynamic range of the amplitude of the dipoles, with dipole locations that are far away from the sensors getting very large amplitudes. See http://www.fieldtriptoolbox.org/tutorial/beamformer/ for another example (although it’s MEG, the same thing applies).

Best wishes,
Jan-Mathijs



Begin forwarded message:

From: Xavier Vrijdag <x.vrijdag at auckland.ac.nz<mailto:x.vrijdag at auckland.ac.nz>>
Subject: Source localisation mom results
Date: 23 April 2020 at 02:12:02 CEST
To: "jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>" <jan.schoffelen at donders.ru.nl<mailto:jan.schoffelen at donders.ru.nl>>

Hello Jan-Mathijs,

I have been using fieldtrip for my EEG analysis for the last year and am really pleased with all the options the toolbox offers and the support given along my journey to understand how to use the toolbox. The documentation on the website is really helpful to understand how to use the various parts of the toolbox.

So far I have programmed a preprocessing pipeline to clean my EEG data that I collected during exposures to various narcotic gases (resting state data). This data is fed into a source localization script with the ultimate goal to do connectivity analysis (mutual information) and network analysis.

I have the following questions:

  1.  Should I filter the EEG data into the standard frequency bands before the source localization, or is it better to filter the mom data that is fed into the connectivity analysis. With the goal to assess the connectivity in various frequency bands
  2.  Should I append the data from two measurements (separate days)  for each participants or keep them separate during the source localization analysis (each measurement contains a baseline and exposure recording).
  3.  Did I correctly use the parcellation functions to source-localize the data to the centroids of the 90 cortical regions?
  4.  I intend to feed the mom field of the parcellated source struct into the connectivity analysis. I found that the range of the is 6.0571e+07. Is this correct/normal?


The script has the following steps (script file can be downloaded from:https://www.dropbox.com/s/jnf5dr56ytj543j/EEGsourselocalisationN2He.m?dl=0):
I currently have a source localization script  that has the following steps:
I have a created a file with the aligned electrode locations
I use the standard BEM head model and the AAL atlas

create a 6 mm grid based leadfield
source interpolate the AAL atlas on the grid
calculate the centroid position for each of the first 90 AAL regions
create new grid based on these center positions
new source interpolation of the AAL atlas on the new grid

Append the baseline and exposure data
Frequency band filter
Calculate the channel covariance matrix for all exposures and for each exposure separately (keep trials)
Calculate LCMV beamformer spatial filter on all exposure matrix
Apply spatial filter and source parcellation on each exposure (keep trials and rawtrial)

Thank you for helping me getting a better understanding of the source localization steps.

Regards,

Xavier Vrijdag

Xavier Vrijdag, MSc

Researcher
Department of Anaesthesiology │ School of Medicine
Faculty of Medical & Health Sciences │ The University of Auckland
Private Bag 92019 │ Auckland 1142 │ New Zealand

M +64 21 0230 4558
E x.vrijdag at auckland.ac.nz<mailto:x.vrijdag at auckland.ac.nz>

[FMHS Logo]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200423/c99901b7/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 22256 bytes
Desc: image001.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200423/c99901b7/attachment.png>

From C.vandenBoomen at uu.nl  Fri Apr 24 14:39:28 2020
From: C.vandenBoomen at uu.nl (Boomen, C. van den (Carlijn))
Date: Fri, 24 Apr 2020 12:39:28 +0000
Subject: [FieldTrip] mexmaci64 cannot be opened
Message-ID: <AM0PR05MB52685F577E9EA8DD7B574EDF89D00@AM0PR05MB5268.eurprd05.prod.outlook.com>

Hi all,

I've a new version of MacOS and fieldtrip functions don't seem to work anymore. I get the error that mexmaci64 files cannot be opened. I've looked at the link below, and followed the instructions. However, this only seems to work for running ft_default, but I keep receiving the error for other functions (e.g. ft_preprocessing). Does anyone know what the problem might be, or have an idea for a solution?

http://www.fieldtriptoolbox.org/faq/mexmaci64_cannot_be_opened_because_the_developer_cannot_be_verified/

Thank you!
Best,
Carlijn

Dr. Carlijn van den Boomen | Departments of Developmental and Experimental Psychology | Utrecht University | Langeveld Building - room H066 | Heidelberglaan 1 | 3584 CS Utrecht | the Netherlands | phone: +31(30) 253 1266 | fax: +31(30) 253 4511
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200424/cf4e9191/attachment.htm>

From gina.brazof at gmail.com  Sun Apr 26 21:41:27 2020
From: gina.brazof at gmail.com (Gina Brazof)
Date: Sun, 26 Apr 2020 21:41:27 +0200
Subject: [FieldTrip] only NaNs in ft_freqgrandaverage output
Message-ID: <CABXoQMe_T5cz4ngdV8XtAC_Fnvso7XOZXmoqqJwge3KAqMp86w@mail.gmail.com>

Dear Community,

I preprocessed my EEG data in EEGlab and now I would like to run a time
frequency analysis using FielTrip. I start by saying that I am new with the
time frequency analysis, matlab and fieldtrip, so I say sorry in advance
for my ignorance.
For each of my experiment conditions (experimental design 2*2
within-subjects), I tried to run a wavelet tranformation and a grandavarage
across all subjects. However, the values of the gandAverage powspctrm in
two out of four conditions are only NaNs and I can not figure out why that
is happening. Indeed, the code has been structurally the same for all
conditions. In addition, the object of the ft_ freqgrandaverage in these
two problematic conditions do not contain the reasonable amount of NaNs to
justify the values in the gandaverage. Could someone help me to undertand
where the problem could be?
Below the example of code I used for each condition:

%%%%% oggPain COONDITION 1

TFreqAv_oggPain = cell(1,nSubjs);
for i = 1:nSubjs

    subs     = subjects{i};
    fileName = '_data.mat';
    dataSet  = strcat('C:\Users\bia\Desktop\dati carlotta\', subs, fileName
);
    %dataSet = fullfile(dataPath,subjects{i},fileName);
    load(dataSet); % loading the variable 'data'

    %%%%%%%%% Computing time-frequency representation for each trial
    cfg = [];
    cfg.method = 'wavelet';
    cfg.foi    = 4:1:30;
    cfg.toi    = -0.8:0.01:1.5;
    cfg.width  = 7;
   %cfg.keeptrials = 'yes';
    cfg.channel    = 'all';
    cfg.trials     = find(celltomat(data.trialinfo(:,1)) == 7 | celltomat
(data.trialinfo(:,1)) == 8 | celltomat(data.trialinfo(:,1)) == 11 |
celltomat(data.trialinfo(:,1)) == 12);  %numbers differ according to exp.
condition
    cfg.outputfile = strcat('C:\Users\bia\Desktop\dati carlotta\',
subs,'_oggPain');
    TFreqAv_oggPain{i}= ft_freqanalysis(cfg,data);
    clear data
end
save TFreqAv_oggPain.mat TFreqAv_oggPain

bslnTFreqAv_oggPain = cell(1,nSubjs);
for i = 1:nSubjs

    subs     = subjects{i};
    fileName = '_oggPain.mat';
    dataSet  = strcat('C:\Users\bia\Desktop\dati carlotta\', subs, fileName
);
    load(dataSet); % loading the variable 'freq'

    %%%%%%%%% Computing the change relative to a baseline
    cfg = [];
    cfg.baselinetype = 'relchange';
    cfg.baseline     = [-0.05 -0.02];
    bslnTFreqAv_oggPain{i} = ft_freqbaseline(cfg,freq);
    clear freq
end
save bslnTFreqAv_oggPain.mat bslnTFreqAv_oggPain

%% Grand average time-frequency data
cfg = [];
gAvgTFreq_oggPain     = ft_freqgrandaverage(cfg,TFreqAv_oggPain{:});
save gAvgTFreq_oggPain.mat gAvgTFreq_oggPain
gAvgBslnTFreq_oggPain = ft_freqgrandaverage(cfg,bslnTFreqAv_oggPain{:});
save gAvgBslnTFreq_oggPain.mat gAvgBslnTFreq_oggPain

Thank for any kind of tips,

Gina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200426/d82656b5/attachment.htm>

From maximilien.chaumon at upmc.fr  Tue Apr 28 10:58:00 2020
From: maximilien.chaumon at upmc.fr (Maximilien Chaumon)
Date: Tue, 28 Apr 2020 10:58:00 +0200
Subject: [FieldTrip] Dipoles to topographies
In-Reply-To: <CAFU3-hHvBbtwpK19EuNzxhimc+K=gwNWvh=677oOrv3T01NFMQ@mail.gmail.com>
References: <CAFU3-hHvBbtwpK19EuNzxhimc+K=gwNWvh=677oOrv3T01NFMQ@mail.gmail.com>
Message-ID: <CAFU3-hGWp8S7Rrqwxdwg2Jj9TrFgE7pS9HDmh2nLbFHgPF3r+w@mail.gmail.com>

Dear all,

Some of you have probably heard about this
<https://github.com/mne-tools/dipole-simulator> recent tool for MNE-python
users.
The FieldTrip community need not be jealous. We also have our
ft_dipole_topo_MEEG <https://github.com/dnacombo/ft_dipole_topo_MEEG> tool.

These interactive tools show how dipoles project to MEG and EEG sensors.
That's useful for teaching and  tuning your own-brain forward-inverse
problem solver. Try it yourself!

Enjoy!
Max

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200428/8debbd93/attachment.htm>

From pereirarosaluismanuel at gmail.com  Tue Apr 28 16:01:55 2020
From: pereirarosaluismanuel at gmail.com (Luis Manuel Pereira Rosa)
Date: Tue, 28 Apr 2020 16:01:55 +0200
Subject: [FieldTrip] source reconstruction
Message-ID: <CAA4BTjAr9a7GeWN7UMhF8hNmGaFB-gVC0Ly3jqQYrOnBbSmjhA@mail.gmail.com>

I am writing to you because I am trying to do a font rebuild much like the
one found in the tutorial
http://www.fieldtriptoolbox.org/tutorial/minimumnormestimate/, but from EEG
data, to get to the forward solution (ft_prepare_leadfield function) I used
a head model  obtained   from an rmi and a source model that I downloaded
from Fieldtrip's own data.

For the inverse solution I used the ft_sourceanalysis function and the
input arguments were the outputs of the ft_prepare_leadfield and
ft_preprocessing functions.

When I use the ft_plot_mesh function to graph the results, the brain
reconstruction is done correctly, but the source in it does not appear
because the array of the SourceFIC.ave.pow field is 0.

If someone has been through the same thing and can help me with that, I
would appreciate it.

Thank you
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200428/24aec252/attachment.htm>

From r.oostenveld at donders.ru.nl  Wed Apr 29 09:49:25 2020
From: r.oostenveld at donders.ru.nl (Robert Oostenveld)
Date: Wed, 29 Apr 2020 09:49:25 +0200
Subject: [FieldTrip] MEG/EEG toolkit course - online materials available
Message-ID: <0EADFE13-D309-4D7E-9658-F4A537948284@donders.ru.nl>

Dear FieldTrip users

Last week we hosted the MEG/EEG toolkit course online. Due to the COVID-19 pandemic we had to transform it in an online format in which almost everyone (participants and tutors) were attending from home. The format consisted of lectures, extended Q&A sessions, and hands-on sessions where participants worked on tutorials on their own computer. Besides doing it online, this posed additional challenges, with kids at home requiring attention, with time-zone differences, and with some participants now also having clinical duties. This required a lot of creativity of everyone involved, resulting in interesting opportunities. In short: it was a great success, with very good interaction between the about 35 participants and the tutors.

We have documented the work that went into the preparations, the instruction “manual” that we wrote for the participants and tutors, and also some of the lessons we learned along the way. Furthermore, where possible we recorded the online Zoom lectures and Q&A sessions, allowing you to learn from them as well. Please see the http://www.fieldtriptoolbox.org/workshop/toolkit2020/ <http://www.fieldtriptoolbox.org/workshop/toolkit2020/> page for all details. 

best regards,
Robert and Jan-Mathijs

PS if you plan to do a similar online training event, you might learn from our format as well. The documentation includes all instructions and notes that we wrote prior and during the workshop. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200429/fe137e48/attachment.htm>

From p.mccolgan at ucl.ac.uk  Wed Apr 29 12:34:32 2020
From: p.mccolgan at ucl.ac.uk (McColgan, Peter)
Date: Wed, 29 Apr 2020 10:34:32 +0000
Subject: [FieldTrip] Registering freesurfer soucremodel to CTF space
In-Reply-To: <AM0PR0102MB3492BE9C72AD4BF8DA7ED92FC4AD0@AM0PR0102MB3492.eurprd01.prod.exchangelabs.com>
References: <AM0PR0102MB34928C5652C26EDDC20C149BC4AF0@AM0PR0102MB3492.eurprd01.prod.exchangelabs.com>,
 <AM0PR0102MB3492BE9C72AD4BF8DA7ED92FC4AD0@AM0PR0102MB3492.eurprd01.prod.exchangelabs.com>
Message-ID: <AM0PR0102MB349297240DA1978312C77DC0C4AD0@AM0PR0102MB3492.eurprd01.prod.exchangelabs.com>


Dear experts,



I am working on relating 7T quantitative MRI to MEG.



I have been following this tutorial http://www.fieldtriptoolbox.org/tutorial/sourcemodel/



However I want to run freesurfer on my 7T image and then transform the source model to CTF space.



I did the following steps



1. I ran freesurfer on my 7T mp2rage.nii (-hires pipeline)



2. Then I register my 7T mp2rage.nii to the CTF realigned mp2rage.nii to generate a transform (using nifiti_reg) -



%% Load transform

transform_fs2ctf = load(fullfile(mri_path,'fs_ctf.txt'));



I then tried to use this transform to put the sourcemodel into CTF space



%% Refine and save source model

sourcemodel = ft_transform_geometry(transform_fs2ctf, sourcemodel);



However I get the following error:



Error using ft_transform_geometry (line 65)

only a global rescaling is allowed.



(transform file attached).



Any idea why this is happening?

I have also tried to use the transform from:

%% Relign anatomical MRI to MEG

cfg          = [];

cfg.method   = 'interactive';

cfg.coordsys = 'ctf';

mri          = ft_volumerealign(cfg, mri);



I have also tried to run freesurfer on after realigning the MRI ctf, then to acpc as in the tutorial however freesurfer fails on the 7T images

Thanks

 Peter












-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200429/f8e5577f/attachment.htm>

From mfzl_mzly at yahoo.com  Wed Apr 29 13:14:48 2020
From: mfzl_mzly at yahoo.com (Mohd Faizal Mohd Zulkifly)
Date: Wed, 29 Apr 2020 11:14:48 +0000 (UTC)
Subject: [FieldTrip] Issue with source grand averaging
References: <1022769010.1360694.1588158888853.ref@mail.yahoo.com>
Message-ID: <1022769010.1360694.1588158888853@mail.yahoo.com>


Dear all,

I am doing source analysis based on subject-specific MRI andcurrently having an issue to do source grandaveraging. I tried to use differentversion of fieldtrips (i.e. Fieldtrip-20181122, Fieldtrip-20191127 andFieltrip-20200109), and it still ended up with the same error: “Error usingft_sourcegrandaverage (line 116) the input sources vary in the field inside”. Ialso aware that this issue was discussed previously https://mailman.science.ru.nl/pipermail/fieldtrip/2015-October/022580.html.Unfortunately, I still facing the same error after specifying source.pos =template_grid.pos. It would be grateful if some of you can help and let me knowmy mistakes in the scripts below. It is a long script and I was thinking itmight be helpful to provide a full script for others to help. Hope to hear fromyou guys soon. Thank you.

***********************************Forwardmodel************************************************************

subject_data= {'A’, ‘B’};

subj={'A’, ‘B’};

nsubj = numel(subject_data);

% MRI Segmentation

%   if do_mri_seg

% read the *mgz files from FreeSurfer

fprintf(['starting forward model for: ', subj{s},'\n '])

mri = ft_read_mri([subject_mri, subj{s},'/','mri/','T1.mgz']);

mri.coordsys = 'ctf';

% interactively set fiducials to align MRI space to EEGspace

cfg = [];

cfg.method = 'interactive';

mri = ft_volumerealign(cfg, mri);

    

cfg          = [];

cfg.output    = {'brain','skull','scalp'};

segmentedmri  = ft_volumesegment(cfg, mri);

% save segmentedmri

 

%%

% Head mesh

 

%if do_head_mesh

addpath 'XXXXXX/fieldtrip-20181122/external/spm12'

segmentedmri.dim = segmentedmri.dim;

segmentedmri.coordsys = segmentedmri.coordsys;

segmentedmri.unit = segmentedmri.unit;

cfg = [];

cfg.tissue = {'brain','skull','scalp'};

cfg.method = 'projectmesh';

cfg.numvertices = [3000 2000 1000];

mri_bnd = [];

mri_bnd.transform = segmentedmri.transform;

mri_bnd.brain = segmentedmri.brain;

    

braindil = imdilate(segmentedmri.brain, strel_bol(6));

mri_bnd.skull = braindil > 0.5;

mri_bnd.scalp = segmentedmri.scalp;

mri_bnd.dim = segmentedmri.dim;

mri_bnd.coordsys = segmentedmri.coordsys;

mri_bnd.unit = segmentedmri.unit;

    

src = ft_prepare_mesh(cfg, mri_bnd);

% save src

%% 

% COMPONENT 1: Headmodel 

addpath 'XXX/fieldtrip-20181122/external/dipoli'

cfg = [];

cfg.method = 'dipoli';

hdm = ft_prepare_headmodel(cfg, src);

% save hdm   

disp(hdm)

    

%%

% COMPONENT 2: Sensoradjustment           %getting electrodes in the right position

 

%if do_sensor_alignment

sens = ft_read_sens([XXX, subj{s}, '.sfp']);   %GEOSCAN   

sens = ft_convert_units(sens, 'mm');

    

nas = mri.cfg.fiducial.nas;

lpa = mri.cfg.fiducial.lpa;

rpa = mri.cfg.fiducial.rpa;

    

% warp NAS LPA and RPA

nas = ft_warp_apply(mri.transform, nas, 'homogenous');

lpa = ft_warp_apply(mri.transform, lpa, 'homogenous');

rpa = ft_warp_apply(mri.transform, rpa, 'homogenous');

fid = [];

fid.elecpos       = [nas; lpa;rpa];       % ctf-coordinates of fiducials

fid.chanpos       = [nas; lpa;rpa];       % ctf-coordinates of fiducials

fid.label        = {char(sens.label(1)); ...

                    char(sens.label(2)); ...

                    char(sens.label(3))};    % samelabels as in elec

    

% alignment

cfg              = [];

cfg.method        ='fiducial';

cfg.target        =fid;                  % see above

cfg.elec         = sens;

cfg.fiducial      ={char(sens.label(1)); ...

                    char(sens.label(2)); ...

                    char(sens.label(3))};  % labels of fiducials in fid and inelec            

elec_aligned      =ft_electroderealign(cfg);

    

cfg = [];

cfg.method = 'project';

cfg.elec = elec_aligned;

cfg.headshape = src(3);

elec_aligned = ft_electroderealign(cfg);

% save elec_aligned   

    

%% 

%COMPONENT 3: Sourcemodel       

% % load a template grid

% NOTE: the path to the template file is user-specific

pathin ='XXX/matlab/toolbox/';

load(fullfile(pathin,'fieldtrip-20200109/template/sourcemodel/standard_sourcemodel3d5mm'));

template = sourcemodel;

clear sourcemodel;

 

% create the subject specific grid, using the template gridthat has just been created

% inverse-warp the template grid to subject specificcoordinates

cfg = [];

cfg.warpmni = 'yes';

cfg.template = template;

cfg.nonlinear = 'yes';

cfg.mri =  mri; %mri - not working properly/ showingscalp

cfg.unit = 'mm';

grid        =ft_prepare_sourcemodel(cfg);

%save grid

 

%% 

% COMPONENT 4: Leadfield

fname_preproc_data = fullfile(XXX,subject_data{s}]); 

preproc_data = load(fname_preproc_data);

EEG_name = cell2mat(fieldnames(preproc_data));

 

% 

cfg                    = [];

cfg.elec               = elec_aligned;

cfg.channel            =preproc_data.conv_data_rpost.label;                % ensure that rejected electrodes are not present

cfg.headmodel          = hdm;

cfg.grid.pos           = sourcemodel.pos;

cfg.normalize          ='no';               %normalize 'yes' it when don't have a contrast to avaoid activity at thecenter (NAI tutorial)

cfg.normalizeparam      = 0.5;

cfg.grid.unit          = 'mm';

leadfield              = ft_prepare_leadfield(cfg);

%save leadfield

 

 % the data consists of fewer channels than theprecomputed

    % leadfields, the following chunk of codetakes care of this

[a,b] = match_str(preproc_data.conv_data_rpost.label,leadfield.label);

for k = 1:numel(leadfield.leadfield)

    if ~isempty(leadfield.leadfield{k})

        tmp =leadfield.leadfield{k};

        tmp = tmp(b,:);

        tmp =tmp-repmat(mean(tmp,1),[size(tmp,1) 1]); % average re-ref

       leadfield.leadfield{k} = tmp;

    end

end

leadfield.label = leadfield.label(b);

%save leadfield

 

*****************************************************source_analysis**************************************

 

subject_rpost_data= {‘A’, ‘B’}; 

 

subj={‘A’, ‘B’ };

 

nsubj = numel(subj);

 

  

    % Loop over subjects

    

    for s=1:nsubj

    fprintf(['starting source analysis for:', subj{s},'\n '])

 

    

    load(fname_preproc_data);

    load(fname_sourcemodel);

    load(fname_leadfield);

    load(fname_headmodel);

    load(fname_elec);

    

    mri =ft_read_mri(fname_seg_mri);   

    mri.coordsys = 'ctf';

 

    load(fname_smri )   

    % transform original mri tosegemented mri transformation info

    trns = segmentedmri.transform /mri.transform;

    clear segmentedmri

    % reslice mri

    mri.coordsys = 'ctf';

    mri = ft_volumereslice([], mri);

    % transform mri to coordinates ofleadfield 

    mri = ft_transform_geometry(trns,mri);

 

    

    % Bring data as in time domain

    % Cut Trial data in baseline and evokedtime segments

    cfg = [];

    cfg.latency = [-1.0 0]; %baseline        % choose baseline as i didwith sensor analysis (100ms)

    datbasl = ft_selectdata(cfg,preproc_data.(EEG_name));

    cfg = [];

    cfg.latency = [0 3]; % evoked activity

    datact = ft_selectdata(cfg,preproc_data.(EEG_name));

    cfg = [];

    cfg.latency = [-1 3];

    datall =ft_selectdata(cfg,preproc_data.(EEG_name));

 

%%          

    % Compute covariance matrix

 

   cfg            = [];

    cfg.covariance = 'yes';

    cfg.keeptrials = 'no'; % 'no' createsaveraged trial

    cfg.removemean = 'yes';

    cfg.channel = {'all', '-E257'};

    

    datbasl_avg =ft_timelockanalysis(cfg, datbasl); %Baseline data (in time domain)

    datact_avg  =ft_timelockanalysis(cfg, datact);  %Activity data

    datall_avg  =ft_timelockanalysis(cfg, datall);  %Data with baseline and activity

 

    

    %% Source analysis

    %

    % adapt leadfield channels to channel ofcurrent eeg data (199 instead

    % of 256)

    [~,b] = match_str(datbasl_avg.label,leadfield.label);

    for k = 1:numel(leadfield.leadfield)

        if~isempty(leadfield.leadfield{k})

           tmp = leadfield.leadfield{k};

           tmp = tmp(b,:);

           tmp = tmp-repmat(mean(tmp,1),[size(tmp,1) 1]); % average re-ref

           leadfield.leadfield{k} = tmp;

        end

    end

    leadfield.label = leadfield.label(b);

   

 

    %   Compute common spatialfilter  

    cfg                  = [];

   cfg.channel           =datall_avg.label;

   cfg.elec             = elec_aligned.elec_aligned;

   cfg.method            ='lcmv';

%    cfg.grid            =leadfield;

   cfg.headmodel         = headmodel.hdm;

    cfg.sourcemodel.grid.pos   =leadfield.pos; % bei FT wird hier der output von ft_leadfield angegeben  

    cfg.grid.resolution   = 5;

    cfg.lcmv.keepfilter   = 'yes';

    cfg.lcmv.fixedori    = 'yes';

    cfg.lcmv.projectnoise = 'yes';

    cfg.lcmv.weightnorm = 'nai';

   cfg.lcmv.lambda       = '5%';

    

    eegsrc_all = ft_sourceanalysis(cfg,datall_avg);     %source data in all time window

  

    % apply common filters to pre andpost stimulus data

   cfg.grid.filter       = eegsrc_all.avg.filter;

    

    % Compute source for baseline andactivty time window

    eegsrc_basl = ft_sourceanalysis(cfg,datbasl_avg);   %source data for baseline time window

    eegsrc_act  = ft_sourceanalysis(cfg,datact_avg);    %source data for activity time window

 

                                                                                                 

    % contrast post stimulus onsetactivity with respect to baseline

    eegsrc_act_basnrm = eegsrc_act;

    eegsrc_act_basnrm.avg.pow =(eegsrc_act.avg.pow - eegsrc_basl.avg.pow)./ eegsrc_basl.avg.pow;

  

  

    %% Choose time of interest

   

   % average across time the dipole momentswithin the N1 latency range

    ind    =find(eegsrc_act_basnrm.time>=0.1 & eegsrc_act_basnrm.time<=0.5); %at18ms-24ms

    timecourse =eegsrc_act_basnrm.avg.mom(eegsrc_act_basnrm.inside);

    tc_toi    =zeros(size(eegsrc_act_basnrm.avg.pow(eegsrc_act_basnrm.inside)));

    

    for ii = 1:length(timecourse)

        tc_toi(ii) =mean(abs(timecourse{ii}(ind)));

    end

    

    source = eegsrc_act_basnrm;

    source.avg.pow(eegsrc_act_basnrm.inside)= tc_toi;

%     source.cfg = rmfield(source.cfg,{'headmodel' 'callinfo'}); % this is removed because it takes up a lot ofmemory

   

    % Save source

       

    % interpolate and normalize toindividual mri

    %first, interpolate

   cfg           = [];

    cfg.parameter = 'pow';

    eeg_source_interp  =ft_sourceinterpolate(cfg, source, mri);

 

    

    % second, normalise

    cfg = [];

    cfg.nonlinear     ='no';

    eeg_source_interp_norm =ft_volumenormalise(cfg, eeg_source_interp);

    

    % save the interpolate andnormalised data 

    

%% 

      % load sourcereconstructed data

%     keep subjects path_data nsubjpath_ft

    

    allsource_rpost = cell(1,nsubj);

    for s = 1:nsubj

        datapath =strcat(fname_eeg_source_interp_norm);

%         datafile =fullfile(datapath, [subj{s}, '_source.mat']);    % take _sourcedata?

        datafile =fullfile(datapath, [subj{s}, '_eeg_source_interp_norm.mat']);   

        load(datafile)

 

       allsource_rpost{s}     = eeg_source_interp_norm;

%        allsource_rpost{s}     = source;

    end

 

 

    % grand average

   cfg             =[];

    cfg.parameter   = 'pow';

%     cfg.keepindividual='yes';

    gasource_rpost  =ft_sourcegrandaverage(cfg, allsource_rpost{:});

    %save gasource_rpost

 

 

 

 

With best wishes,

Faizal Zulkifly

 

--------------------------------------------------------

Mohd Faizal Mohd Zulkifly

University Medical Center Göttingen

University of Göttingen

Clinic for Clinical Neurophysiology

Robert-Koch-Straße40

37075 Göttingen

Germany

Tel: +49 55139-8457

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200429/55638b10/attachment.htm>

From chrichat at hotmail.com  Wed Apr 29 19:55:50 2020
From: chrichat at hotmail.com (Christos Chatzichristos)
Date: Wed, 29 Apr 2020 17:55:50 +0000
Subject: [FieldTrip] IClabel of EEGlab error
In-Reply-To: <CABXoQMe_T5cz4ngdV8XtAC_Fnvso7XOZXmoqqJwge3KAqMp86w@mail.gmail.com>
References: <CABXoQMe_T5cz4ngdV8XtAC_Fnvso7XOZXmoqqJwge3KAqMp86w@mail.gmail.com>
Message-ID: <VI1PR04MB5312A79A2DB6250BE8985664C1AD0@VI1PR04MB5312.eurprd04.prod.outlook.com>

Dear all


I am facing an error while using IClabel
My code is straightforward

EEG=pop_biosig('edf.file');
EEG=pop_runica(EEG,'chanind',[1:22]);
EEG=icalabel(EEG);

And i receive the following error  :

Error using /
Matrix dimensions must agree.

Error in topoplotFast (line 894)
squeezefac = rmax/plotrad;

Error in ICL_feature_extractor (line 33)
topoplotFast(EEG.icawinv(:, it), EEG.chanlocs(EEG.icachansind), ...

Error in iclabel (line 52)
features = ICL_feature_extractor(EEG, flag_autocorr);


The error arises from the fact that STYLE='map';  (line  576 of topoplotfast)  and plotchans=[] from the begininig. Any idea?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200429/7084cdbb/attachment.htm>

From arnodelorme at gmail.com  Wed Apr 29 20:35:06 2020
From: arnodelorme at gmail.com (Arnaud Delorme)
Date: Wed, 29 Apr 2020 13:35:06 -0500
Subject: [FieldTrip] IClabel of EEGlab error
In-Reply-To: <VI1PR04MB5312A79A2DB6250BE8985664C1AD0@VI1PR04MB5312.eurprd04.prod.outlook.com>
References: <CABXoQMe_T5cz4ngdV8XtAC_Fnvso7XOZXmoqqJwge3KAqMp86w@mail.gmail.com>
 <VI1PR04MB5312A79A2DB6250BE8985664C1AD0@VI1PR04MB5312.eurprd04.prod.outlook.com>
Message-ID: <DE4B47C8-0E83-4B65-90E0-6FFE4F99AD1C@gmail.com>

This is an EEGLAB question which you can ask on this list eeglablist at sccn.ucsd.edu

The short answer is that you need to look up channel coordinates, because IClabel needs them.

Best wishes,

Arno

> On Apr 29, 2020, at 12:55 PM, Christos Chatzichristos <chrichat at hotmail.com> wrote:
> 
> Dear all
> 
> 
> 
> I am facing an error while using IClabel
> My code is straightforward
> 
> EEG=pop_biosig('edf.file');
> EEG=pop_runica(EEG,'chanind',[1:22]);
> EEG=icalabel(EEG);
> 
> And i receive the following error  :
> 
> Error using /
> Matrix dimensions must agree.
> 
> Error in topoplotFast (line 894)
> squeezefac = rmax/plotrad;
> 
> Error in ICL_feature_extractor (line 33)
> topoplotFast(EEG.icawinv(:, it), EEG.chanlocs(EEG.icachansind), ...
> 
> Error in iclabel (line 52)
> features = ICL_feature_extractor(EEG, flag_autocorr);
> 
> 
> The error arises from the fact that STYLE='map';  (line  576 of topoplotfast)  and plotchans=[] from the begininig. Any idea?
> _______________________________________________
> fieldtrip mailing list
> https://urldefense.com/v3/__https://mailman.science.ru.nl/mailman/listinfo/fieldtrip__;!!Mih3wA!VdtO5wW0UEzmn9FiPtNEcjHCDdLXyb5qP_x8MkXpWkaGu7ePle7pfMtnCUq-$ 
> https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!Mih3wA!VdtO5wW0UEzmn9FiPtNEcjHCDdLXyb5qP_x8MkXpWkaGu7ePle7pfHl6jlT3$




From pdhami06 at gmail.com  Thu Apr 30 06:17:57 2020
From: pdhami06 at gmail.com (Paul Dhami)
Date: Thu, 30 Apr 2020 00:17:57 -0400
Subject: [FieldTrip] Using ft_regressconfound to remove effects of age from
 group cell array
Message-ID: <CABqnCmDH0qD60Uz5MZZFRP2vni2iB6QWAEw+q2ePwO8j+8Yatg@mail.gmail.com>

Dear FieldTrip community,

I would like to use ft_regressconfound to account for the effects of age.
However, I am unsure how to use it with a cell array containing the outputs
of ft_timelockanalysis with multiple subjects. Even when trying to use
ft_regressconfound on a single subject, I get the error that field "trial"
not present in data.

Any help would be greatly appreciated.

Thank you,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200430/2b5d60f5/attachment.htm>

From e.spaak at donders.ru.nl  Thu Apr 30 10:45:25 2020
From: e.spaak at donders.ru.nl (Eelke Spaak)
Date: Thu, 30 Apr 2020 10:45:25 +0200
Subject: [FieldTrip] Using ft_regressconfound to remove effects of age
 from group cell array
In-Reply-To: <CABqnCmDH0qD60Uz5MZZFRP2vni2iB6QWAEw+q2ePwO8j+8Yatg@mail.gmail.com>
References: <CABqnCmDH0qD60Uz5MZZFRP2vni2iB6QWAEw+q2ePwO8j+8Yatg@mail.gmail.com>
Message-ID: <CABPNLUo6qLoKNz8Vro6w1CUj2HjRa9yhP3geYT995H1yj457-w@mail.gmail.com>

Dear Paul,

ft_regressconfound is (primarily) designed to regress out variance
explained *across trials*, not across individuals. It should work if
you use it on a single subject, with the important caveat that
ft_timelockanalysis needs to have been run with cfg.keeptrials = 'yes'
(yielding a .trial field in the output, in addition to the .avg).

The rather old (because nowadays rarely needed) function
ft_timelockgrandaverage has an option analogous to keeptrials, namely
.keepindividual = 'yes'. If you specify this, you'll get stacked ERFs
in a .individual field in the output.

ft_regressconfound *might* be able to deal with such a .individual
field automatically, but if I'm honest I doubt it. If this doesn't
work, it's a relatively minor hack to simply rename .individual it to
.trial, though, and then call ft_regressconfound on the hacked data
structure (optionally you'll also have to hack .dimord from
'subj_time' to 'rpt_time' or something).

Hope that helps!
Eelke

On Thu, 30 Apr 2020 at 06:17, Paul Dhami <pdhami06 at gmail.com> wrote:
>
> Dear FieldTrip community,
>
> I would like to use ft_regressconfound to account for the effects of age. However, I am unsure how to use it with a cell array containing the outputs of ft_timelockanalysis with multiple subjects. Even when trying to use ft_regressconfound on a single subject, I get the error that field "trial" not present in data.
>
> Any help would be greatly appreciated.
>
> Thank you,
> Paul
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202



From sarah.kirchler at gmail.com  Thu Apr 30 12:05:24 2020
From: sarah.kirchler at gmail.com (Sarah Kirchler)
Date: Thu, 30 Apr 2020 12:05:24 +0200
Subject: [FieldTrip] Analyzing SSVEPs
Message-ID: <5eaaa2e5.1c69fb81.d62fe.d9d7@mx.google.com>

Hi Fieldtrip!

I have a question About analyzing SSVEPs. 
I don’t really know how to make a Connection from Fieldrtrip to my already preprocessed data. I have a Folder named „clean“, where I have saved the data rejected from artifacts. 

You offer only an example script „How to analyze SSVEPs with simulated data“, but I have real data and don’t know how to read it in. 
The function ft_read_data doesn’t support .mat-files, in which I saved my clean data. 

How can I create a dataset out of my clean data? Or how can I read in the clean data with the .mat-endings?

Thanks for your answers! 
And excuse my incorrect english. 

Best, 

Sarah Kirchler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200430/f49ad608/attachment.htm>

From julian.keil at gmail.com  Thu Apr 30 12:25:49 2020
From: julian.keil at gmail.com (Julian Keil)
Date: Thu, 30 Apr 2020 12:25:49 +0200
Subject: [FieldTrip] Analyzing SSVEPs
In-Reply-To: <5eaaa2e5.1c69fb81.d62fe.d9d7@mx.google.com>
References: <5eaaa2e5.1c69fb81.d62fe.d9d7@mx.google.com>
Message-ID: <BC3663E7-916C-404D-B00C-B75D0D158E08@gmail.com>

Hi Sarah,

in the FAQs on the website, you find all the information you need to make your data compatible with fieldtrip:
http://www.fieldtriptoolbox.org/faq/how_can_i_import_my_own_dataformat/ <http://www.fieldtriptoolbox.org/faq/how_can_i_import_my_own_dataformat/>

Hope this helps,

Julian


> Am 30.04.2020 um 12:05 schrieb Sarah Kirchler <sarah.kirchler at gmail.com>:
> 
> Hi Fieldtrip!
> 
> I have a question About analyzing SSVEPs. 
> I don’t really know how to make a Connection from Fieldrtrip to my already preprocessed data. I have a Folder named „clean“, where I have saved the data rejected from artifacts. 
> 
> You offer only an example script „How to analyze SSVEPs with simulated data“, but I have real data and don’t know how to read it in. 
> The function ft_read_data doesn’t support .mat-files, in which I saved my clean data. 
> 
> How can I create a dataset out of my clean data? Or how can I read in the clean data with the .mat-endings?
> 
> Thanks for your answers! 
> And excuse my incorrect english. 
> 
> Best, 
> 
> Sarah Kirchler
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip <https://mailman.science.ru.nl/mailman/listinfo/fieldtrip>
> https://doi.org/10.1371/journal.pcbi.1002202 <https://doi.org/10.1371/journal.pcbi.1002202>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20200430/77f6a7dd/attachment.htm>

From e.spaak at donders.ru.nl  Thu Apr 30 13:10:39 2020
From: e.spaak at donders.ru.nl (Eelke Spaak)
Date: Thu, 30 Apr 2020 13:10:39 +0200
Subject: [FieldTrip] Analyzing SSVEPs
In-Reply-To: <5eaaa2e5.1c69fb81.d62fe.d9d7@mx.google.com>
References: <5eaaa2e5.1c69fb81.d62fe.d9d7@mx.google.com>
Message-ID: <CABPNLUqbstWABU_k-BADXUv+-9naGSOi6DwsWaZ=S_1Q+hhrYA@mail.gmail.com>

Hi Sarah,

If I'm not mistaken, your question is essentially: I already have data
in Matlab arrays, how can I make sure FieldTrip understands this? (So
the question is independent of SSVEP or any specific analysis
pipeline.) Have a look at
http://www.fieldtriptoolbox.org/faq/how_are_the_various_data_structures_defined/
and specifically ft_datatype_raw for pointers.

Best,
Eelke

On Thu, 30 Apr 2020 at 12:05, Sarah Kirchler <sarah.kirchler at gmail.com> wrote:
>
> Hi Fieldtrip!
>
> I have a question About analyzing SSVEPs.
> I don’t really know how to make a Connection from Fieldrtrip to my already preprocessed data. I have a Folder named „clean“, where I have saved the data rejected from artifacts.
>
> You offer only an example script „How to analyze SSVEPs with simulated data“, but I have real data and don’t know how to read it in.
>
> The function ft_read_data doesn’t support .mat-files, in which I saved my clean data.
>
> How can I create a dataset out of my clean data? Or how can I read in the clean data with the .mat-endings?
>
> Thanks for your answers!
> And excuse my incorrect english.
>
> Best,
>
> Sarah Kirchler
>
> _______________________________________________
> fieldtrip mailing list
> https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
> https://doi.org/10.1371/journal.pcbi.1002202



From weberi at staff.uni-marburg.de  Thu Apr 30 22:07:00 2020
From: weberi at staff.uni-marburg.de (Immo Weber)
Date: Thu, 30 Apr 2020 22:07:00 +0200
Subject: [FieldTrip] PhD in Marburg, Germany
Message-ID: <20200430220700.Horde.Ip-TMFwdvh_1x8g0vKweVfl@home.staff.uni-marburg.de>


Dear FieldTrip community,

In Marburg (Germany), we offer an exciting PhD opportunity in  
clinical/cognitive neurophysiology:

Optimization of deep brain stimulation for Parkinson's disease and  
characterization of the underlying neural activity using EEG, fMRI,  
DTI, LFPs and single unit recordings in humans.

For further reference see:  
http://www.clinicalsystemsneuroscience.de/PhD_project_ClinicalNeuroscience.pdf

-- 
Dr. rer. nat. Immo Weber
Department of Neurologie
Dynamical Neuroscience Lab

Universitätsklinikum Giessen und Marburg GmbH,
Marburg
Baldingerstraße
35033 Marburg, Germany

Phone (+49) 06421 - 58 66276
Telefax (+49) 06421 - 58 65298
E-Mail: immo.weber at staff.uni-marburg.de
http://www.systemsneuroscience.de
http://www.nolitia.com



