[FieldTrip] trial error
Schoffelen, J.M. (Jan Mathijs)
janmathijs.schoffelen at donders.ru.nl
Sat Jun 10 11:31:10 CEST 2023
Dear Evelyne,
Hmmm, I think that your question is a bit out of scope for the fieldtrip discussion list, because your problem seems constrained to the a problem with the PhysIO toolbox (which uses SPM, which uses Fieldtrip). It’s great that you already have identified that calling ft_definetrial directly works fine, which makes it unlikely that there’s a bug in the fieldtrip codebase.
I have never worked with this PhysIO toolbox myself, and the combination with the matlabbatch functionality of SPM does not make the detective work straightforward.
My first hunch would be that the (possibly hardcoded) definition of the eventtype/eventvalue is incorrect for your data. I checked the TAPAS code on github, and found the following function: https://urldefense.com/v3/__https://github.com/translationalneuromodeling/tapas/blob/master/PhysIO/code/readin/tapas_physio_read_physlogfiles_brainproducts.m__;!!HJOPV4FYYWzcc1jazlU!5H90oiOLBBCjs7OHHJjplyfnTinW865-Zaby40nl4EbZ9Bda9wsf7NqLgE9m8mYrIAP9JANXm36nW5J0LyH6YNuL50-nLh9h6Ob8-w$ , which looks as if this is the one where things might go wrong. Specifically, starting from line 54 in said function, the eventvalue that defines the ’trials’ within PhysIO is defined hardcoded as ‘R128’, which does not seem to be present in your data.
Could this be what is causing your issue? Given that the eventvalue is hardcoded (i.e. non configurable as an option in your matlabbatch) you can not get it to run without making a change to your version of the code. I would assume that - if this is indeed the cause of the problem - the change of ‘R128’ into ‘R 1’ would be sufficient, and that this will work for all of your recorded subjects. A more principled solution would be to liaise with the PhysIO developers (or to submit a Pull Request) to discuss the possibility of making the eventvalue for the brainproducts data configurable.
If things are unclear, or on the off chance that my suggestions don’t address the problem, please feel free to drop by at the office (01.158) with some data, code and versnaperingen, so that we can have a look at it together.
Best wishes,
Jan-Mathijs
On 9 Jun 2023, at 15:03, Evelyne Fraats via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:
Dear all,
My name is Evelyne and I am just started to explore fieldtrip.
I use fieldtrip to define trials in physiological recordings to estimate physiological regressors for MRI preprocessing.
However, when using the physio toolbox, no trials are detected within my data.
When I run the separate ft_definetrial function, I get trials, but I seem to fail to include this in my matlabbatch.
This is my output with error message:
evaluating trial function 'ft_trialfun_general'
reading the header from '/home/affneu/evefra/Spinalcord/data/Physio/subx19_new_threat_SPINAL.vhdr'
reading the events from '/home/affneu/evefra/Spinalcord/data/Physio/subx19_new_threat_SPINAL.vhdr'
found 169 events
created 20 trials
the call to "ft_definetrial" took 0 seconds and required the additional allocation of an estimated 0 MB
Item model: No field(s) named
event
------------------------------------------------------------------------
09-Jun-2023 15:02:40 - Running job #41
------------------------------------------------------------------------
09-Jun-2023 15:02:40 - Running 'TAPAS PhysIO Toolbox'
Warning: cfg.trialdef.eventtype='?' is deprecated, please specify cfg.trialfun='ft_trialfun_show'
evaluating trial function 'ft_trialfun_show'
reading the events from '/home/affneu/evefra/Spinalcord/data/Physio/subx19_new_threat_SPINAL.vhdr'
the following events were found in the data
event type: 'New Segment'
with event values:
event type: 'Response'
with event values: 'R 1'
event type: 'Stimulus'
with event values: 'S 1' 'S 97'
no trials have been defined yet, see FT_DEFINETRIAL for further help
found 169 events
the call to "ft_definetrial" took 0 seconds and required the additional allocation of an estimated 0 MB
evaluating trial function 'ft_trialfun_general'
reading the header from '/home/affneu/evefra/Spinalcord/data/Physio/subx19_new_threat_SPINAL.vhdr'
reading the events from '/home/affneu/evefra/Spinalcord/data/Physio/subx19_new_threat_SPINAL.vhdr'
09-Jun-2023 15:02:41 - Failed 'TAPAS PhysIO Toolbox'
Error using ft_definetrial
no trials were defined, see FT_DEFINETRIAL for help
The following modules did not run:
Failed: TAPAS PhysIO Toolbox
Error using MATLABbatch system
Job execution failed. The full log of this run can be found in MATLAB command window, starting with the lines (look for the line showing the
exact #job as displayed in this error message)
------------------
Running job #41
------------------
This is my code:
if physio_regressor == 1
%cd /home/affneu/evefra/Spinalcord/data/Physio/
%define log input
data_path_physio = fullfile(data_path, 'Physio');
data_path_physio_sub = dir(fullfile(data_path_physio, sprintf('subx%d*threat*.eeg', sub))) ; %CHANE FORMAT
filenames = {data_path_physio_sub.name};
filenames = filenames';
filefolder = {data_path_physio_sub.folder};
filefolder = filefolder';
filename_folder = cellfun(@(folder, name) fullfile(folder, name), filefolder, filenames, 'UniformOutput', false);
%define vhdr
data_path_physio_sub = dir(fullfile(data_path_physio, sprintf('subx%d*threat*.vhdr', sub))) ; %CHANE FORMAT
filenames = {data_path_physio_sub.name};
filenames = filenames';
filefolder = {data_path_physio_sub.folder};
filefolder = filefolder';
filename_folder_vhdr = cellfun(@(folder, name) fullfile(folder, name), filefolder, filenames, 'UniformOutput', false);
%define vmkr
data_path_physio_sub = dir(fullfile(data_path_physio, sprintf('subx%d*threat*.vmrk', sub))) ; %CHANE FORMAT
filenames = {data_path_physio_sub.name};
filenames = filenames';
filefolder = {data_path_physio_sub.folder};
filefolder = filefolder';
filename_folder_vmrk = cellfun(@(folder, name) fullfile(folder, name), filefolder, filenames, 'UniformOutput', false);
%define trials
cfg = [];
cfg.headerfile = char(filename_folder_vhdr);
cfg.eventfile = char(filename_folder_vmrk);
cfg.trialdef.eventtype = 'Stimulus';
cfg.trialdef.eventvalue = 'S 1';
cfg.trialdef.prestim = 0;
cfg.trialdef.poststim = 0;
%cfg.trialfun = 'ft_trialfun_show';
trials = ft_definetrial(cfg);
%run regressor estimation
clear matlabbatch
matlabbatch{1}.spm.tools.physio.save_dir = {fullfile(data_path_tos_brain,'physio_regressors')};
matlabbatch{1}.spm.tools.physio.log_files.vendor = 'BrainProducts';
matlabbatch{1}.spm.tools.physio.log_files.cardiac = filename_folder;
matlabbatch{1}.spm.tools.physio.log_files.respiration = filename_folder;
matlabbatch{1}.spm.tools.physio.log_files.scan_timing = {''};
matlabbatch{1}.spm.tools.physio.log_files.sampling_interval = [];
matlabbatch{1}.spm.tools.physio.log_files.relative_start_acquisition = 0;
matlabbatch{1}.spm.tools.physio.log_files.align_scan = 'last';
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.Nslices = 44;
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.NslicesPerBeat = [];
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.TR = 3.39;
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.Ndummies = 0;
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.Nscans = 147;
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.onset_slice = 1;
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.time_slice_to_slice = [];
matlabbatch{1}.spm.tools.physio.scan_timing.sqpar.Nprep = [];
matlabbatch{1}.spm.tools.physio.scan_timing.sync.nominal = struct([]);
matlabbatch{1}.spm.tools.physio.preproc.cardiac.modality = 'ECG';
matlabbatch{1}.spm.tools.physio.preproc.cardiac.filter.no = struct([]);
matlabbatch{1}.spm.tools.physio.preproc.cardiac.initial_cpulse_select.auto_matched.min = 0.4;
matlabbatch{1}.spm.tools.physio.preproc.cardiac.initial_cpulse_select.auto_matched.file = 'initial_cpulse_kRpeakfile.mat';
matlabbatch{1}.spm.tools.physio.preproc.cardiac.initial_cpulse_select.auto_matched.max_heart_rate_bpm = 90;
matlabbatch{1}.spm.tools.physio.preproc.cardiac.posthoc_cpulse_select.off = struct([]);
matlabbatch{1}.spm.tools.physio.preproc.respiratory.filter.passband = [0.01 2];
matlabbatch{1}.spm.tools.physio.preproc.respiratory.despike = false;
matlabbatch{1}.spm.tools.physio.model.output_multiple_regressors = 'multiple_regressors.txt';
matlabbatch{1}.spm.tools.physio.model.output_physio = 'physio.mat';
matlabbatch{1}.spm.tools.physio.model.orthogonalise = 'none';
matlabbatch{1}.spm.tools.physio.model.censor_unreliable_recording_intervals = false;
matlabbatch{1}.spm.tools.physio.model.retroicor.yes.order.c = 3;
matlabbatch{1}.spm.tools.physio.model.retroicor.yes.order.r = 4;
matlabbatch{1}.spm.tools.physio.model.retroicor.yes.order.cr = 1;
matlabbatch{1}.spm.tools.physio.model.rvt.no = struct([]);
matlabbatch{1}.spm.tools.physio.model.hrv.no = struct([]);
matlabbatch{1}.spm.tools.physio.model.noise_rois.no = struct([]);
matlabbatch{1}.spm.tools.physio.model.movement.no = struct([]);
matlabbatch{1}.spm.tools.physio.model.other.no = struct([]);
matlabbatch{1}.spm.tools.physio.verbose.level = 2;
matlabbatch{1}.spm.tools.physio.verbose.fig_output_file = '';
matlabbatch{1}.spm.tools.physio.verbose.use_tabs = false;
matlabbatch{1}.spm.tools.physio.model.event.trials = trials.trl(:,1);
spm_jobman('run', matlabbatch)
end
If anybody has some tips, it would be greatly appreciated.
Best,
Evelyne
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8K61M79uymMxxdjPKVyfGBtnWB-RCxy2i6Q6ZvuyiceE0VKbY6x6jPj7xtCmtq14ZNS3x6uHwZAy4xvdqZ3o72A8YRrwcTyAUBGzyA$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230610/aa8e4abc/attachment.htm>
More information about the fieldtrip
mailing list