当我在线运行matlab代码时,我得到了一个错误。错误是:
警告:名称不存在或不是目录:......toolbox_misc
为int32类型的输入参数定义函数'relabel'。import_experiment_label中的错误(第22行)run = relabel(run);
我尝试在线下载matlab工具箱misc,但仍然无法修复这个问题。有人能帮我吗?非常感谢!
原始代码如下:
% Load the text experiment-label file to cell
% Kinalizer: /share/Bot/Research/mvpa_data/Haxby_6_subjects
% mac: /Users/kittipat/Downloads/Research/Haxby_7_subjects
% subjID = 2;
inDir = ['/Users/kittipat/Downloads/Research/Haxby_7_subjects/subj',num2str(subjID),'/'];
inFile = 'labels.txt';
outDir = ['/Users/kittipat/Downloads/Research/Haxby_7_subjects/subj',num2str(subjID),'/matlab_format'];
fileID = fopen(fullfile(inDir,inFile));
% !!!!! Must remove "labels chunks" at the top of the txt file first
myCell = textscan(fileID, '%s %d');
fclose(fileID);
category_name = myCell{1};
run = myCell{2};
% Make sure the run numbers are well-ordered from 1 to R
addpath('../../../toolbox_misc/');
runs = relabel(run);
num_run = length(unique(runs));
num_time_stamp = length(runs);
% Make associate labels (needs input from user)
category_name_list = {'rest','face','house','cat','bottle','scissors','shoe','chair','scrambledpix'};
assoc_label_list = [0,1,2,3,4,5,6,7,8];
num_category = length(assoc_label_list); % including 'rest'
assoc_label = zeros(num_time_stamp,1);
regs = zeros(num_category,num_time_stamp);
for i = 1:num_time_stamp
assoc_label(i) = assoc_label_list(strcmp(category_name{i},category_name_list));
regs(assoc_label(i)+1,i) = 1; % 'rest' is column 1
end
regs_with_rest = regs;
regs = regs(2:end,:); % exclude "rest" in the 1-st column
num_category = num_category - 1; % exclude the "rest"
save(fullfile(outDir,'experiment_design'),...
'category_name',...% the category name for each time stamp
'assoc_label',...% the number label for each time stamp
'assoc_label_list',...% the mapping between category_name and assoc_label
'category_name_list',...% list of the category name
'num_category',...% number of categories excluding "rest"
'regs',...% the category matrix excluding "rest"
'num_run',...% number of runs in well-ordered integer
'runs'... % the run# for each time stamp
);
%% plot the figure
h1 = figure;
subplot(4,1,2); plot(assoc_label,'b.-');
xlim([1, num_time_stamp]);
set(gca,'YTick',0:max(assoc_label(:))); set(gca,'YTickLabel',category_name_list);
subplot(4,1,1); plot(runs,'r.-');
title('run number after relabeling --> runs'); xlim([1, num_time_stamp]);
subplot(4,1,3); imagesc(regs_with_rest);
title('original design matrix --> regs_with_rest');
set(gca,'YTick',1:(num_category+1)); set(gca,'YTickLabel',category_name_list);
subplot(4,1,4); imagesc(regs);
title('after "rest" is removed --> regs');
xlabel('time stamps');
set(gca,'YTick',1:num_category); set(gca,'YTickLabel',category_name_list(2:end));
print(h1,'-djpeg',fullfile(outDir,'experiment_design.jpg'));
我修复了重标签问题。然后我将部分代码修改如下。
inDir = ['/D disk/MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8/subj',num2str(subjID),'/'];
inFile = 'labels.txt';
outDir = ['/D disk/MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8/subj',num2str(subjID),'/matlab_format'];
出现另一个错误:
import_experiment_label未定义的函数或变量'subjID'。
import_experiment_label错误(第7行)inDir = ['/D disk/MATLAB/R2014a/subjX/beta_extraction_for_Haxby_matlab_toolbox_v1_8/subj',num2str(subjID),'/'];
如何解决这个问题?我不知道这里出了什么问题。谢谢大家!