'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 CenterFile Exchange에서 Neuroimaging에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by