Hi all
I want to write a batch file for NIRS SPM (the extension for near infrared spectroscopy).
The attached code already exists, but still has some bugs, which you might help to solve.
1. data conversion: this step seems to work.
2. model specification: however, when starting this step the code does not detect the .mat file with the converted data (see error message in previous mail).
-----------------------------------------------------
>> run_hitachi_conversion
Please wait...
Data reading (1/3) has been completed.
Data reading (2/3) has been completed.
Data reading (3/3) has been completed.
Data conversion starts...
Data conversion has been completed.
Error using load
Number of columns on line 2 of ASCII file
C:\Users\lisa\Documents\DATA\ZInEP\TP1_NIRS_Data\01_Data_raw\stroop\20118010_MES_Probe1.csv must be the same
as previous lines.
Error in specification_batch (line 91)
load(fname_nirs);
Error in run_hitachi_conversion (line 33)
[SPM_nirs] = specification_batch(fname_nirs, hb, HPF, LPF, method_cor, dir_save, flag_window, hrf_type);
-----------------------------------------------------
3. model estimation: there is also another error in this step (see below):
-----------------------------------------------------
Undefined function or variable "pathn".
Error in estimation_batch (line 19)
pathn = fname_SPM(1:pathn(end));
Error in run_hitachi_conversion (line 45)
[SPM_nirs] = estimation_batch(fname_spm, fname_nirs);
------------------------------------------------------
Thanks for your support.
Lisa
system = 'hitachi_1set_OD';
name_dir = 'C:\Users\lisa\Documents\DATA\ZInEP\TP1_NIRS_Data\01_Data_rawCopy\stroopraw\'; % Please specify your data directory.
listing = dir(name_dir);
listing = listing(3:end, 1);
nfiles = size(listing, 1);
for i = 1:nfiles
fname_nirs = fullfile(name_dir, listing(i, 1).name);
% [nirs_data] = data_conversion_batch(fname_nirs, system);
[pathstr, name, ext] = fileparts(fname_nirs);
save(fullfile(name_dir, [name, '.mat']), 'nirs_data');
% model specification
dir_save = fullfile(name_dir, name);
if ~isdir(dir_save)
mkdir(dir_save);
end
% Please specify the parameters of your dataset
hb = 'hbo';
HPF = 'wavelet';
LPF = 'hrf';
method_cor = 0;
flag_window = 1;
hrf_type = 0;
% units = 1;
% names{1} = 'right finger tapping';
% onsets{1} = 42:51:501;
% durations{1} = 21 * ones(10,1);
[SPM_nirs] = specification_batch(fname_nirs, hb, HPF, LPF, method_cor, dir_save, flag_window, hrf_type);
% step 3: model estimation
switch hb
case 'hbo'
fname_SPM = fullfile(dir_save, 'SPM_indiv_HbO.mat');
case 'hbr'
fname_SPM = fullfile(dir_save, 'SPM_indiv_HbR.mat');
case 'hbt'
fname_SPM = fullfile(dir_save, 'SPM_indiv_HbT.mat');
end
[SPM_nirs] = estimation_batch(fname_SPM, fname_nirs);
% step 4: activation map (T-statistic, EC-corrected p-value < 0.05)
% Please specify the name of channel, and parameters
fname_ch = 'C:\Users\lisa\Documents\DATA\ZInEP\Settings\frontal52_ch_33_opt';
con_name = 'Right finger tapping';
con_vec = [1 0 0 0]';
STAT = 'T';
spec_hemi = 'ventral';
p_value = 0.05;
correct_p = 'EC';
disp_fig = 1;
[stat_brain, act_brain, threshold] = activation_map_batch(fname_SPM, fname_ch, con_name, con_vec, STAT, spec_hemi, p_value, correct_p, disp_fig);
end
|