[FieldTrip] TRENTOOL pipeline help

Max Cantor mcantor at umich.edu
Thu Sep 4 20:30:50 CEST 2014


Hi fieldtrippers,

I know trentool is not produced by the Donders Institute, so I'm not 100%
sure if it is appropriate to ask questions about it here, but to the best
of my knowledge they do not have a mailing list and I saw a few trentool
questions in the archives, so I'm going to assume it's ok...

In any case, below is my current pipeline (slightly modified for
comprehensibility):

(notes in bold are comments/questions made in this email, not present in
the pipeline. Sorry in advance for the long post! Any help would be greatly
appreciated as I'm a bit over my head on this but I think I'm close!)

*****

% Prepare group TE data

cfgP                        = [];
cfgP.Path2TSTOOL  = *TSTOOLPATH*
cfgP.TEcalctype       = 'VW_ds';
cfgP.channel            = {'ctfdip_LAC'  'ctfdip_RAC'};

*I'm trying to find the transfer entropy between the left and right
auditory cortices in my experiment. The input is virtual sensor data that
was produced using SAM in fieldtrip on real MEG data. *

% specify u to be scanned

cfgP.predicttime_u    = 30;
cfgP.toi                    = [-0.4 0.4];

*For clarification, the predicttime_u is in seconds but the toi is in
milliseconds. If I understand correctly, the predicttime_u must fit within
the toi, but beyond that are there any benefits to it being earlier or
later?*

% ACT (Autocorrelation Time) estimation and constraints

cfgP.maxlag              = 150;
cfgP.actthrvalue         = 7.5;
cfgP.minnrtrials          = 5;

*My understanding is maxlag should be 1/2 the sampling rate, so since the
data are downsampled to 300hz, it should be 150. I know that the sample
rate and filters are used to determine the actthrvalue, but I don't
actually know the calculation. 7.5 was a rough guess just to test the
pipeline. I'm also uncertain of what minnrtrials should be.*

% Optimization

cfgP.optimizemethod   = 'ragwitz';
cfgP.ragdim                 = 4:8;
cfgP.ragtaurange          = [0.2 0.4];
cfgP.ragtausteps          = 15;
cfgP.repPred                = 100;

*I am completely at a loss for this. I've done some reading into transfer
entropy, mutual information, etc., cited in trentool, but I'm yet to
understand how exactly this optimization works and what the configuration
should be, given my data and experimental intentions.*

% Kernel-based TE estimation

cfgP.flagNei                  = 'Mass';
cfgP.sizeNei                  = 4; % Default

cfgP.ensemblemethod    = 'no';
cfgP.outputpath              = *OUTPUT PATH*;

if ~exist(*Path for TEprepare data object*)
    load VSdat;
    TE_Wrd                     = {};
    for i                           = 1:nConds
        for j                       = 1:Nsub
            TE_Wrd{i}{j}        = TEprepare(cfgP, VSdat{i}{j});
        end
    end
    clear VSdat;
    save('TE_Wrd', 'TE_Wrd');
end

*The configuration and virtual sensor data, organized in a 3 x 15 cell of
structures (condition by subject) are the input. The TEprepare substructure
is added to each individual condition x subject .mat files' data structure
which are stored on disk independently.*

% Use object_to_mat_conversion.m to replace individual condition x subject
virtual sensor data
% .mat files with their TE_Wrd equivalent

*I'm using a separate script to make some manipulations to the objects from
disk; this will all eventually be integrated into the main pipeline*.*
TRENTOOL seems to handle data output very differently from fieldtrip and
I've had trouble thinking through the most logical way to handle the data
so it's a bit haphazard right now.*

load cond080sub01.mat

cfgG                               = [];
cfgG.dim                         = cond080sub01.TEprepare.optdim;
cfgG.tau                          = cond080sub01.TEprepare.opttau;

if isfield(cond080sub01, 'TEprepare')
                              TEgroup_prepare(cfgG, fileCell);
else
    error('Need to run TEprepare before TEgroup_prepare');
end

*For clarification, fileCell is a cell with the name of each condition x
subject .mat file, which as I said before is collectively the same as the 3
x 15 VSdat structure (condition x subject).*

% Replace .mat files with '_for_TEgroup_calculate' version in
% object_to_mat_conversion.m

% TE Group Calculate

load cond080sub01.mat
if isfield(cond080sub01, 'TEgroupprepare')
    for i                   = 1:length(fileCell)
                              TEgroup_calculate(fileCell{i});
    end
else
    error('Need to run TEgroup_prepare before TEgroup_calculate');
end







*At this step I get the following error:Error using transferentropy (line
337)\nTRENTOOL ERROR: not enough data points left after embeddingError in
TEgroup_calculate (line 133)[TEresult] = transferentropy(cfg,data);*

% TE Group Stats

cfgGSTAT                              = [];
cfgGSTAT.design(1,1:2*Nsub) = [ones(1,Nsub) 2*ones(1,Nsub)];
cfgGSTAT.design(2,1:2*Nsub) = [1:Nsub 1:Nsub];

cfgGSTAT.uvar                       = 1;
cfgGSTAT.ivar                        = 2;
cfgGSTAT.fileidout                  = 'test_groupstats';

                              TEgroup_stats(cfgGSTAT, fileCell);

*Given the error above, I am yet to get to this step, but it does not seem
fundamentally different from normal fieldtrip stats.*

*****

In case my notes were not clear or you skipped to the bottom, *my primary
concern is whether the error I'm getting in TEgroup_calculate is a pipeline
issue* (I noticed the example pipeline in trentool, the manual, and
published methods articles all seem to have slightly or significantly
different pipeline compositions), *or if the error is* due to ACT, ragwitz
optimization, or some other faulty parameterization *on my part due to a
lack of understanding of how transfer entropy works on a more
theoretical/mathematical level*. If the latter is the case, is there any
relatively straightforward way to conceptualize this, or is this something
where I'm just going to have to keep reading and rereading until it
eventually makes sense? I've already done quite a bit of that and it hasn't
pierced my thick skull yet but I'm sure it will eventually!

Thank you so much,

Max Cantor


-- 
Max Cantor
Lab Manager
Computational Neurolinguistics Lab
University of Michigan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20140904/1242801c/attachment-0001.html>


More information about the fieldtrip mailing list