- Typically, it is advised against adding FieldTrip and its subdirectories entirely to your MATLAB path. This is because FieldTrip includes several external toolboxes within the fieldtrip/external directory that may not be necessary for most users and could potentially lead to conflicts if they coincide with other toolboxes you have.
- The ‘fieldtrip/compat’ directory contains functions meant for backward compatibility, which should only be included in your path if you are working with an older version of MATLAB that requires them.
- It is worth examining the configuration settings in the 'cfg' you utilized when invoking ‘ft_timelockstatistics’ function. Also, verify whether ‘HH_timelock’, ‘HN_timelock’, ‘LH_timelock’, and ‘LN_timelock’ variables include data from individual participants or groups, and confirm if their dimensions are consistent.
ft_preamble errors in ft_timelockstatistics
5 次查看(过去 30 天)
显示 更早的评论
Hello,
I was trying clust-based permutation test using fieldtrip and I got no error until here.
I brought EEG data and conducted timelock analysis for each condition, and then conducted permutation test with montecarlo.
%% Import data from BVA
addpath C:\
addpath C:\Export
addpath C:\Developmental-Neuroscience-Lab-Toolbox-main\Network
addpath C:\fieldtrip-master
ft_defaults
allSubj = {'01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '1 3', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26'};
condition = {'CSD', 'CSD2', 'CSD3', 'CSD4'};
for c = 1:length(condition)
for s = 1:length(allSubj)
filename = ['C:\Export\p',allSubj{s},'_',condition{c}];
data = BVA2Matlab(filename);
save(['Subj_',allSubj{s}, '_ERP_', condition{c}, 'data'], 'data');
end
end
%% timelock analysis
%CSD
datapath = "C:\Export\HH";
nSubjs = numel(allSubj);
for i = 1:nSubjs
fileName = strcat('Subj_', allSubj{i}, '_ERP_CSDdata.mat');
dataSet = fullfile('C:', 'Export', 'HH', fileName);
save dataSet dataSet
load dataSet
cfg = [];
cfg.inputfile = dataSet;
cfg.keeptrials = 'yes';
HH_timelock = ft_timelockanalysis(cfg);
save HH_timelock HH_timelock;
end
%CSD2
datapath = "C:\Export\HN";
nSubjs = numel(allSubj);
for i = 1:nSubjs
fileName2 = strcat('Subj_', allSubj{i}, '_ERP_CSD2data.mat');
dataSet2 = fullfile('C:', 'Export', 'HN', fileName2);
save dataSet2 dataSet2
load dataSet2
cfg = [];
cfg.inputfile = dataSet2;
cfg.keeptrials = 'yes';
HN_timelock = ft_timelockanalysis(cfg);
save HN_timelock HN_timelock;
end
%CSD3
datapath = "C:\Export\LH";
nSubjs = numel(allSubj);
for i = 1:nSubjs
fileName3 = strcat('Subj_', allSubj{i}, '_ERP_CSD3data.mat');
dataSet3 = fullfile('C:', 'Export', 'LH', fileName3);
save dataSet3 dataSet3
load dataSet3
cfg = [];
cfg.inputfile = dataSet3;
cfg.keeptrials = 'yes';
LH_timelock = ft_timelockanalysis(cfg);
save LH_timelock LH_timelock;
end
%CSD4
datapath = "C:\Export\LN";
nSubjs = numel(allSubj);
for i = 1:nSubjs
fileName4 = strcat('Subj_', allSubj{i}, '_ERP_CSD4data.mat');
dataSet4 = fullfile('C:', 'Export', 'LN', fileName4);
save dataSet4 dataSet4
load dataSet4
cfg = [];
cfg.inputfile = dataSet4;
cfg.keeptrials = 'yes';
LN_timelock = ft_timelockanalysis(cfg);
save LN_timelock LN_timelock;
end
%% Permutation test
[ftver, ftpath] = ft_version;
cd(fullfile(ftpath, 'template', 'electrode'));
elec = ft_read_sens('standard_1020.elc');
% there are some of which the orientation cannot be determined (T3, T4, T5, T6)
ft_plot_sens(elec, 'label', 'yes', 'elecshape', 'disc', 'elecsize', 10, 'facecolor', [0.8 0.8 1.0])
% give it a stronger 3D appearance
camlight headlight
cfg = [];
cfg.elec = elec;
cfg.channel = {'Fp1', 'Fpz', 'Fp2', 'F7', 'F3', 'Fz', 'F4', 'F8', 'T7', 'C3', 'Cz', 'C4', 'T8', 'P7', 'P3', 'Pz', 'P4', 'P8', 'O1', 'Oz', 'O2'};
cfg.method = 'distance';
cfg.feedback = 'yes';
cfg.neighbourdist = 100;
neighbours = ft_prepare_neighbours(cfg);
design = zeros(4, nSubjs*4);
design(1,:) = [1:nSubjs 1:nSubjs 1:nSubjs 1:nSubjs];
design(2,:) = [ones(1,nSubjs) ones(1,nSubjs)*2 ones(1,nSubjs)*3 ones(1,nSubjs)*4];
cfg = [];
cfg.channel = {'EEG'};
cfg.latency = [0 0.6];
cfg.method = 'montecarlo';
cfg.neighbours = neighbours;
cfg.statistic = 'ft_statfun_depsamplesFmultivariate';
cfg.correctm = 'cluster';
cfg.clusteralpha = 0.05;
cfg.clusterstatistic = 'maxsum';
cfg.minnbchan = 2;
cfg.tail = 0;
cfg.clustertail = 0;
cfg.alpha = 0.025;
cfg.numrandomization = 500;
cfg.design = design;
cfg.uvar = 1;
cfg.ivar = 2;
After this, however, when I ran the code below,
%% permutation test statistical analysis
[stat] = ft_timelockstatistics(cfg, HH_timelock, HN_timelock, LH_timelock, LN_timelock);
I got some errors as follows:
Error: ft_preamble_loadvar (line 65)
cfg.inputfile should not be used in conjunction with giving input data to this function
Error: ft_preamble (line 83)
evalin('caller', full_cmd);
Error: ft_timelockstatistics (line 70)
ft_preamble loadvar varargin
I could not find the cause of these errors from my code or any solution.
Please help me...
0 个评论
回答(1 个)
Sachin Lodhi
2024-1-8
编辑:Sachin Lodhi
2024-1-8
Hello 재원 오,
To fix the errors, please double-check the setup of the FieldTrip toolbox in MATLAB and the 'cfg' settings you're using. FieldTrip is a freely available MATLAB toolbox for MEG, EEG, and iEEG data analysis. To integrate it with MATLAB, setting up its path correctly is essential. Please refer to the following documentation for instructions on setting up the path: https://www.fieldtriptoolbox.org/faq/installation/
Some more information which would be helpful in troubleshooting your issue -
Hope this helps.
Best Regards,
Sachin
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 EEG/MEG/ECoG 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!