'cname' error - sPM contrasts

8 ビュー (過去 30 日間)
Alexandra Antonesei
Alexandra Antonesei 2017 年 8 月 21 日
回答済み: Walter Roberson 2017 年 8 月 21 日
Hi everyone,
Im trying to run a script to do some contrasts (1-st level analyses) for fmri data.
I get this error, 'Undefined function or variable, cname' and I dont know how to fix it.
This is the script I use
clear
addpath(genpath('C:\Users\nh852914\Documents\SPM\spm8\')) %SPM directory
directory = 'E:\Reshma\Task_horizontal\HC\'; % directory of the participant folders
onsets_dir = 'E:\Reshma\Beh data\HC\'; % directory wherethe files with the onsets are
output_dir = 'E:\Reshma\Analysis\Contrasts\HC\'; %directory where the contrasts should be saved
error_dir = 'E:\Reshma\Analysis\Contrasts\errors\'; %directory where the errors should be saved
hard_drive_basepath = 'E:/'; % directory before /RL_MDD/Analysis/Contrasts/
scan_group = 'HC'; % folder in the /RL_MDD/Analysis/Contrasts/ folder (HC or MDD)
cd(directory);
Folders = dir;
spm_get_defaults
global defaults
for ppt = [4]
try
clearvars -except ppt directory error_dir Folders onsets_dir output_dir hard_drive_basepath scan_group
cd(directory);
Folder = Folders(ppt).name;
input_dir = [directory Folder '/'];
pptID = Folder;
output_dir2 = [output_dir pptID '/'];
cd(output_dir2)
load('SPM.mat')
if length(SPM.xCon) == 0
SPM.xCon = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
else
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
end
%1 Hit_b1 ------------------------------------------------------------------
c = [1 0 zeros(1,29)];
cname = 'Hit_b1';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
%2 Hit_b2 ------------------------------------------------------------------
c = [zeros(1,2) 1 0 zeros(1,27)];
cname = 'Hit_b2';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
%3 Hit_b3 ------------------------------------------------------------------
c = [zeros(1,4) 1 0 zeros(1,25)];
cname = 'Hit_b3';
SPM.xCon(end + 1) = spm_FcUtil('Set',cname,'T','c',c(:),SPM.xX.xKXs);
cd(output_dir2)
participant_number = pptID;
copyfile('con_001.img',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b1.img'));
copyfile('con_001.hdr',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b1.hdr'));
copyfile('con_002.img',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b2.img'));
copyfile('con_002.hdr',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b2.hdr'));
copyfile('con_003.img',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b3.img'));
copyfile('con_003.hdr',strcat(hard_drive_basepath, '/Reshma/Analysis/Contrasts/', scan_group, '/', participant_number, '_Hit_b3.hdr'));
catch ME
save([error_dir pptID '_error_first_level_analysis'], 'ME')
disp(['error for subject ' pptID ]);
continue
end
disp(['successfully ran analysis for subject ' pptID]);
end
Any idea on how to sort it?
Thanks a lot!
alexandra

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 8 月 21 日
You have
load('SPM.mat')
That SPM.mat file is expected to contain a variable named cname . Looking in other places, it appears that cname is expected to be either a cell array of character vectors of contrast names, or else possibly a single character vector containing a contrast name. The contrast names are possibly file names; I am not certain.

カテゴリ

Help Center および File ExchangeNeuroimaging についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by