trentool / TRENTOOL3

Open-Source MATLAB toolbox for transfer entropy estimation
http://trentool.github.io/TRENTOOL3/
GNU General Public License v3.0
56 stars 26 forks source link

TEragwitz Error #38

Open lindseyawilson opened 6 months ago

lindseyawilson commented 6 months ago

Hello!

I've seen from looking through previous posts that TRENTOOL is no longer being maintained, but I was hoping that someone here might still be able to help me troubleshoot an issue I've been having.

I'm trying to use transfer entropy for inference of neuronal networks from two-photon calcium imaging data. However, when I pass my data and accompanying cfg file into TEprepare.m, I run into an error when the function tries to call TEragwitz.m and fails on line 62. As far as I can tell, TEragwitz is trying to populate the pointset it creates a few lines above by pulling values out of the data, and the error arises when the index it's trying to pull out of the data array somehow becomes negative. I'll provide the parameters of my cfg file along with a description of my data structure below -- I have a feeling the error has something to do with how I'm setting up my data struct.

I'd really like to take advantage of some of the graph correction functionality in TRENTOOL, but obviously since the rest of the toolbox requires data that's been assembled with TEprepare, I'm sort of stuck here. Is this a problem anyone else has run into?

Thanks so much for your help, Lindsey

%% data struct
data.trial: 1x6 cell, where each cell contains a 154x552 double array of calcium fluorescence values
data.time: 1x6 cell, where each cell contains a 1x552 double array of the time (in seconds) from the start of the imaging run
data.label: 1x154 cell, where each cell contains a character vector containing the label of a cell
data.fsample: a double giving my sampling rate (here, 3.06 Hz)

%% cfg struct
cfgTEP = [];
cfgTEP.calctype = 'VM_ds'
cfgTEP.channel = labelChars; %same character labels as in data.labels
cfgTEP.toi = [1, 3312] first and last overall frame of the imaging run
cfgTEP.predicttime_u = 200; %assumed delay time (in ms)
cfgTEP.ensemblemethod = 'no'
cfgTEP.trialselect = 'no'; %uses all trials (here we only have one trial, and we want to use it)
cfgTEP.verbosity = "debug_fine"
cfgTEP.actthrvalue = 30;
cfgTEP.maxlag = 1000; %listed default value
cfgTEP.TheilerT = 'ACT' %Default
cfgTEP.optimizemethod = 'ragwitz'
cfgTEP.ragdim = 4:8; 
cfgTEP.ragtaurange = [0.1, 1.1]; 
cfgTEP.ragtausteps = 10 %default
cfgTEP.flagNei = 'Mass' %options are range or mass, I just picked one
cfgTEP.sizeNei = 4 %All of the example scripts used this value
cfgTEP.repPred = 100; %All of the example scripts used this value

%% call to TEprepare

imagingOut = TEprepare(cfgTEP, data)

%% Error message

 -Array indices must be positive integers or logical values.

Error in TEragwitz (line 62)
        pointset(ii,jj) = data(ii+(dimMax-1)*tauMax-(jj-1)*tauEmb);

Error in TEprepare (line 805)
                            [mre(rd,rt)] =
                            TEragwitz(cfg,dat,cfg.repPred,1,cfg.flagNei,cfg.sizeNei,cfg.ragdim(rd),tau_sample,TheilerT,max(cfg.ragdim),maxtau);

Error in InteractionDelayReconstruction_calculate (line 108)
dataprep = TEprepare(cfgTEP,data);

Error in C_elegans_connectome (line 98)
celegans_results = InteractionDelayReconstruction_calculate(cfgTEP, cfgTSS, data)
mwibral commented 6 months ago

Dear Lindsey,

it may be worth looking at some figures in the 2011 Lindner et al. BMC paper to see how the pointsets are constructed. My feeling is that your delay/embedding parameters are such that TRENTOOL is looking to far in the past, i.e. it's trying to extract values from your dataset from timepoints that happened before your recording started.

TRENTOOL was most extensively used on electrophysiology (EEG/MEG, intracortical) data, i.e. with smapling rates above 500Hz.

For troubleshooting it may be best to carefully check your settings, i.e. the maximum dimension*tau + the maximum delay must be available before the first data point thst you want to actually analyse. Given that yoour Calcium data has a low sampling rate, it may be that you don't have enough data points for your analysis available (or seen from another perspective you may be asking for too many dimensions, too long taus, etc.

Could you post the exact error message? Is it a TRENTOOL genereted one? or a MATLAB error?

It would also be worth checking if your fieldtrip dataset has all the necessary info and that it is correct. An FT format for CAlcium data did not exist when TRENTOOL was last updated.

Best, Michael

On Tue, 2024-02-20 at 14:51 -0800, Lindsey Wilson wrote:

Hello! I've seen from looking through previous posts that TRENTOOL is no longer being maintained, but I was hoping that someone here might still be able to help me troubleshoot an issue I've been having. I'm trying to use transfer entropy for inference of neuronal networks from two-photon calcium imaging data. However, when I pass my data and accompanying cfg file into TEprepare.m, I run into an error when the function tries to call TEragwitz.m and fails on line 62. As far as I can tell, TEragwitz is trying to populate the pointset it creates a few lines above by pulling values out of the data, and the error arises when the index it's trying to pull out of the data array somehow becomes negative. I'll provide the parameters of my cfg file along with a description of my data structure below -- I have a feeling the error has something to do with how I'm setting up my data struct. I'd really like to take advantage of some of the graph correction functionality in TRENTOOL, but obviously since the rest of the toolbox requires data that's been assembled with TEprepare, I'm sort of stuck here. Is this a problem anyone else has run into? Thanks so much for your help, Lindsey %% data struct data.trial: 1x6 cell, where each cell contains a 154x552 double array of calcium fluorescence values data.time: 1x6 cell, where each cell contains a 1x552 double array of the time (in seconds) from the start of the imaging run data.label: 1x154 cell, where each cell contains a character vector containing the label of a cell data.fsample: a double giving my sampling rate (here, 3.06 Hz)

%% cfg struct cfgTEP = []; cfgTEP.calctype = 'VM_ds' cfgTEP.channel = labelChars; %same character labels as in data.labels cfgTEP.toi = [1, 3312] first and last overall frame of the imaging run cfgTEP.predicttime_u = 200; %assumed delay time (in ms) cfgTEP.ensemblemethod = 'no' cfgTEP.trialselect = 'no'; %uses all trials (here we only have one trial, and we want to use it) cfgTEP.verbosity = "debug_fine" cfgTEP.actthrvalue = 30; cfgTEP.maxlag = 1000; %listed default value cfgTEP.TheilerT = 'ACT' %Default cfgTEP.optimizemethod = 'ragwitz' cfgTEP.ragdim = 4:8; cfgTEP.ragtaurange = [0.1, 1.1]; cfgTEP.ragtausteps = 10 %default cfgTEP.flagNei = 'Mass' %options are range or mass, I just picked one cfgTEP.sizeNei = 4 %All of the example scripts used this value cfgTEP.repPred = 100; %All of the example scripts used this value

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>