[FieldTrip] re FEM (SimBio) stiffness matrix for isotropic and

RICHARDS, JOHN RICHARDS at mailbox.sc.edu
Mon Jul 8 15:50:28 CEST 2019


Eben and Johannes.

I have been working on the wm anisotropy issue using fieldtrip.

In the sb_calc_stiff  this pulls out the conductivity vector

if isfield(vol,'cond') && isfield(vol,'tissue') && isfield(vol,'tissuelabel')
    if length(vol.tissuelabel) == length(vol.cond)
         if length(vol.tissue) == size(elem,2)
             cond = zeros(size(elem,2),1);
             numlabels = length(vol.tissuelabel);
             for i=1:numlabels
                 cond(vol.tissue == i) = vol.cond(i);
             end
        else
            error('Dimensions of vol.tet or vol.hex and vol.tissue do not fit!');
        end
    else
        error('Dimensions of vol.cond and entries of vol.tissuelabel do not fit!');
    end
end

cond is a vector with the length of the size elem.  To make this an isotropic vector, the following should work

conductivity =horzcat(cond,cond,cond,zeros(length(cond),3));

Then pass conductivity to the stiff
    [diinsy,cols,sysmat] = calc_stiff_matrix_val(node,elem,conductivity,mele);

This should be equivalent to the original stiff call with just cond, since the values of the vector are isotropic with zeros in the offdiagonal.  I think at one point in my programming for the construction of the anistropic values I did this and had the same stiff matrix from the "conductivity" and "cond" matrices.

To make this anisotropic for any of the tissue label(s), substitute the dti tensor (or other values) for the tissues you want to be anistropic.  So far I have been successful doing this with the WM from the dti tensor; I have also tried using JUST the l1 or FA values and get similar results. This could also be done for other tissue media if you have some kind of DTi or other measure that would affect the data (e.g., gm, skull, etc).

 Johannes gave me some pseudo code that was very helpful in constructing the wm anisotropic cond vector from the DTI tensor.

John



***********************************************
John E. Richards
Carolina Distinguished Professor
Department of Psychology
University of South Carolina
Columbia, SC  29208
Dept Phone: 803 777 2079
Fax: 803 777 9558
Email: richards-john at sc.edu
https://jerlab.sc.edu
*************************************************

Message: 2
Date: Mon, 8 Jul 2019 04:29:56 +0200
From: eben Andronicus <ebenandronicus at gmail.com>
To: fieldtrip at science.ru.nl
Subject: [FieldTrip] FEM (SimBio) stiffness matrix for isotropic and
	pseudo-anisotropic white matter
Message-ID:
	<CAEz3JhpfToTi=XupM+Smtwvno1a+SmSgSAEJDHj3Z_PozAv6EA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi there,

Following instructions posted earlier by Carsten Wolters,  Johannes Vorwerk, Marios Antonakakis and others on this list, I have managed to get my way to the calc_stiff_matrix_val function call. Verifying on my way sanity of every step and results.

For the sake of curiosity, I have tried to input the regular conductivity values (num_nodes × 1) and the tensor conductivity values for "xx yy zz xy yz zx“ (num_nodes × 6) as suggested by Johannes, but I have cheated a bit, and I have used the same conductivity value for every direction (COND = repmat( cond, [1,6] ).

Now, I haven't expected to get the very same results (identical) for the two inputs, but two very similar matrices would be a sane thing to expect (disregarding noise related to floating point rounding and multiplication by some scaling factor, as I haven't normalized the COND magnitude and only "repmatted" it). The resulting stiffness matrices are highly correlated but not as high as I have expected (the correlation is about 0.9434. However, I have expected something closer to 0.9999).

Can anybody explain what is happening here or point me to math/papers that can provide any insight?

Below is the code snippet. Thank you in advance for any help or suggestions...


[diinsy,cols,sysmat] = calc_stiff_matrix_val(node,elem,cond,mele);
npnt = double(npnt);
diinsy = double(diinsy);
cols = double(cols);
rows = sb_sparse_to_mat(diinsy);
stiff = sparse(rows,cols,sysmat,npnt,npnt,length(sysmat));

COND = repmat( cond, [1,6] );
[diinsy,cols,sysmat] = calc_stiff_matrix_val(node,elem,COND,mele);
npnt = double(npnt);
diinsy = double(diinsy);
cols = double(cols);
rows = sb_sparse_to_mat(diinsy);
STIFF = sparse(rows,cols,sysmat,npnt,npnt,length(sysmat));

<the values are returned to the variables below>

spar_04 = sphe_simbio_vol_headmodel_04_final.stiff(1:20000,1:20000);
spar_05 = sphe_simbio_vol_headmodel_05_isotr.STIFF(1:20000,1:20000);

full_04 = full(spar_04);
full_05 = full(spar_05);

coeff = corrcoef(full_04(:),full_05(:)); coeff


Best
Eben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20190708/1e585c62/attachment.html>

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

Message: 3
Date: Mon, 8 Jul 2019 08:05:39 +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] Time-frequency granger analysis
Message-ID: <6C5BCC00-4399-40FC-A503-A53A5BB60B32 at donders.ru.nl>
Content-Type: text/plain; charset="utf-8"

Hi Daniel,

As with any connectivity metric that needs a cross-spectrum estimate (and specifically for NPSF-based Granger causality estimates), this estimate needs to make sense. In your case, it doesn’t, for several reasons;

1) you only have a single ’trial’ of data, i.e. for every time point the csd is extremely unstable, and will never-ever give meaningful results numerically, even if the rest of the conditions are favorable.
2) in order for the NPSF algorithm to work, the spectral representation needs to be a) smooth, requiring multitapers (+sufficient number of observations) and b) the spectrum needs to be defined from DC to Nyquist.

I recommend you read a bit more in the documentation (and references mentioned) about the underlying algorithmic machinery, and look for some example code in the tutorials/FAQs to get in a more favorable starting position.

Hints:
1) forget about the ’time-frequency’ aspect, and focus on frequency only.
2) this means that you cut your data into smaller snippets, which are to be used as ovbservations, this can be done with ft_redefinetrial
3) then, use ‘mtmfft’ as method for ft_freqanalysis in combination with an appropriate amount of spectral smoothing (’tapsmofrq’) + ‘fourier’ as output.
4) then, think about what your data represents (in terms of referencing etc.) -> if you want a full multivariate NPSF while the data are rank deficient (e.g. with a common average, or another funky referencing scheme), the result will probably be NaN. In which case you’d need to specify cfg.granger.sfmethod = ‘bivariate’, or ditch one of the channels from your multivariate decomposition.

JM


On 6 Jul 2019, at 16:23, daniel.strahnen at uni-ulm.de<mailto:daniel.strahnen at uni-ulm.de> wrote:

Dear FieldTrip – Community,

My goal is to analyse changes of Granger Causality over a certain time period.
Here is the code I use to calculate the wavelet analysis:

data.label = {'CH1'; 'CH2'; 'CH3'; 'CH4'; 'CH5'; 'CH6'; 'CH7'}; data.fsample = 1000; % Sampling rate of 1kH data.time{1} = 1:600000; data.trial{1} = Output_data'; % Matrix organised as follows: 7 chan x 600000 samples

%% Wavelets for time-frequency power analysis
cfg              = [];
cfg.output       = 'powandcsd';
cfg.method       = 'wavelet';
cfg.foi          = 1:48;     % Frequency range from 1 to 48Hz
cfg.t_ftimwin    = ones(length(cfg.foi),1).*0.5;   % length of time window = 0.5 sec
cfg.toi          = 0:600; % 600 seconds (10min) time period
freq_data          = ft_freqanalysis(cfg, data);

Up to this point everything seems to be correct, but the granger analysis only gives my NaNs.

%% Granger causality analysis
cfg_conn = [];
cfg_conn.method = 'granger';
granger_str = ft_connectivityanalysis(cfg_conn, freq_data);

Does anyone has a suggestion what might be the mistake in my code?

Thank you very much and best regards

Daniel

_______________________________________________
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/20190708/0c1400df/attachment.html>

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

Message: 4
Date: Mon, 8 Jul 2019 10:08:53 +0200
From: Johannes <j.vorw01 at gmail.com>
To: FieldTrip discussion list <fieldtrip at science.ru.nl>
Subject: Re: [FieldTrip] FEM (SimBio) stiffness matrix for isotropic
	and pseudo-anisotropic white matter
Message-ID:
	<CAMtnjmVMzGcQrEV71nRsnMxDdgQP4P6+Q_H3X7wvi+89Pfv9+w at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Eben,

please observe that an isotropic conductivity does NOT correspond to a tensor with the same value for every entry as you assume (COND = repmat( cond, [1,6] )), but to a diagonal tensor (xx=yy=zz=COND, all other entries zero), i.e., something like COND = [repmat( cond, [1,3] ),zeros(length(cond),3)] should be correct.

Best,
    Johannes

Am Mo., 8. Juli 2019 um 04:31 Uhr schrieb eben Andronicus <
ebenandronicus at gmail.com>:

> Hi there,
>
> Following instructions posted earlier by Carsten Wolters,  Johannes 
> Vorwerk, Marios Antonakakis and others on this list, I have managed to 
> get my way to the calc_stiff_matrix_val function call. Verifying on my 
> way sanity of every step and results.
>
> For the sake of curiosity, I have tried to input the regular 
> conductivity values (num_nodes × 1) and the tensor conductivity values 
> for "xx yy zz xy yz zx“ (num_nodes × 6) as suggested by Johannes, but 
> I have cheated a bit, and I have used the same conductivity value for 
> every direction (COND = repmat( cond, [1,6] ).
>
> Now, I haven't expected to get the very same results (identical) for 
> the two inputs, but two very similar matrices would be a sane thing to 
> expect (disregarding noise related to floating point rounding and 
> multiplication by some scaling factor, as I haven't normalized the 
> COND magnitude and only "repmatted" it). The resulting stiffness 
> matrices are highly correlated but not as high as I have expected (the 
> correlation is about 0.9434. However, I have expected something closer to 0.9999).
>
> Can anybody explain what is happening here or point me to math/papers 
> that can provide any insight?
>
> Below is the code snippet. Thank you in advance for any help or 
> suggestions...
>
>
> [diinsy,cols,sysmat] = calc_stiff_matrix_val(node,elem,cond,mele);
> npnt = double(npnt);
> diinsy = double(diinsy);
> cols = double(cols);
> rows = sb_sparse_to_mat(diinsy);
> stiff = sparse(rows,cols,sysmat,npnt,npnt,length(sysmat));
>
> COND = repmat( cond, [1,6] );
> [diinsy,cols,sysmat] = calc_stiff_matrix_val(node,elem,COND,mele);
> npnt = double(npnt);
> diinsy = double(diinsy);
> cols = double(cols);
> rows = sb_sparse_to_mat(diinsy);
> STIFF = sparse(rows,cols,sysmat,npnt,npnt,length(sysmat));
>
> <the values are returned to the variables below>
>
> spar_04 = sphe_simbio_vol_headmodel_04_final.stiff(1:20000,1:20000);
> spar_05 = sphe_simbio_vol_headmodel_05_isotr.STIFF(1:20000,1:20000);
>
> full_04 = full(spar_04);
> full_05 = full(spar_05);
>
> coeff = corrcoef(full_04(:),full_05(:)); coeff
>
>
> Best
> Eben
>
>
>
>
> _______________________________________________
> 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/20190708/7101b476/attachment.html>

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

Message: 5
Date: Mon, 8 Jul 2019 09:11:22 +0100
From: Aswin Chari <aswinchari at gmail.com>
To: fieldtrip at science.ru.nl
Subject: [FieldTrip] Freesurfer toolbox for Matlab
Message-ID: <18D8CD88-F02C-4BF9-8E23-8D454F3883E5 at gmail.com>
Content-Type: text/plain;	charset=utf-8

Hello,

I’m trying to familiarise myself with processing of imaging/intracranial EEG data and running through the tutorial. I can’t find any information (on field trip, matlab or freesurfer websites) on how to install the Freesurfer toolbox which is required to read MRIs etc. Can someone help? I am running Matlab 2018b on Mac OS if that makes a difference.

Thanks,
Aswin





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

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 104, Issue 6
*****************************************

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


More information about the fieldtrip mailing list