未定义的功能' relabel'对于类型' int32'的输入参数。 import_experiment_label出错(第22行)runs = relabel(run);

时间:2014-06-23 06:51:26

标签: matlab

我在线运行matlab代码时遇到错误。错误是:

警告:名称不存在或不是目录:...... \ toolbox_misc

未定义的功能' relabel'对于类型' int32'的输入参数。 import_experiment_label出错(第22行) runs = 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'));

1 个答案:

答案 0 :(得分:0)

我修复了重新标记问题。然后我按如下方式更改部分代码。

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),' /'];

如何解决这个问题?我不知道这里有什么不对。谢谢你们!