Dear Phillipe,
> Thanks for your reply. Unfortunately, I had no backup at this point and I had to restart generating contrasts from the beginning. By the way, is there any way to enter contrasts names and rows of 1 0 -1 .... in batch mode? Especially when preparing files for a second level random analysis of for conjunction between individual results, which means a lot of contrasts to enter manually, it will be very helpful to be able to load a file with all contrasts predefined.
Yes, good idea. That is a nice application of the batch-mode implemented
in SPM99. I wrote something like this last week, so here is the
program...
It consists of two files attached to this email. Its only purpose is to
compute and write the t-images and con_*-images for a 2nd-level analysis
when you have many subjects and need to enter the same contrasts for
each subject and zero-filling the others. So this program might save a
bit of your time...
You call it by
spm_bch('analyses_bch');
Of course, you first have to modify both programs to use it for your
data:
Changes in analyses_bch.m:
1. Change working directory to your directory, where the analysis is in
Changes in model_bch.m:
2. Modify the single subject contrasts
3. Modify the number of subjects
4. Modify the names of the single subject contrasts
Hope this helps, Stefan
--
Stefan Kiebel
Functional Imaging Laboratory
Wellcome Dept. of Cognitive Neurology
12 Queen Square
WC1N 3BG London, UK
Tel.: +44-171-833-7478
FAX : -813-1420
email: [log in to unmask]
%---------------------------------------------------------------
% user variables defined here
%---------------------------------------------------------------
wd = '/home/skiebel/data/motor/';
wdc = num2cell(wd, 2)';
%---------------------------------------------------------------
% batch variables defined here for analyses
%---------------------------------------------------------------
analyses = struct( ...
'type', [2], ...
'index', [1], ...
'work_dir', [1], ...
'mfile', [1] ...
);
%-------------------------------------------
type = {'model','contrasts','defaults_edit','headers',...
'means','realignment','normalisation','smooth'};
%-------------------------------------------
work_dir = wdc;
%-------------------------------------------
mfile = { ...
'model_bch.m',...
};
%-------------------------------------------
%---------------------------------------------------------------
% user variables defined here
%---------------------------------------------------------------
% single subject contrasts
ss = [1 -1 0 0;...
0 -1 1 0;...
0 -1 0 1;...
1 0 -1 0;...
1 0 0 -1;...
0 0 1 -1;...
-1 0 1 0;...
0 0 -1 1;...
-1 0 0 1;...
1 -3 1 1;...
1 -2 1 0;...
1 -2 0 1;...
0 -2 1 1;...
];
% nr of subjects
Ns = 9;
% nr of single subject contrasts
Nc = size(ss, 1);
% nr of basis functions
Nb = size(ss, 2);
c = zeros(Nc*Ns, (Nb+1)*Ns);
k = 1;
% contrasts + session effect
for i = 1:Ns
for j = 1:Nc
c(k, :) = [zeros(1, (i-1)*Nb) ss(j,:) zeros(1, (Ns-i)*Nb) zeros(1, Ns)];
k = k+1;
end
end
% contrast names
ss_names = strvcat('C-F',...
'T-F',...
'V-F',...
'C-T',...
'C-V',...
'T-V',...
'T-C',...
'V-T',...
'V-C',...
'CS ',...
'CT-F',...
'CV-F',...
'TV-F');
% concatenate contrast names with subject names
SN = [];
for i = 1 : Ns
for j = 1:Nc
SN = strvcat(SN, sprintf(' Subject %d', i));
end
end
Names = repmat(ss_names, Ns, 1);
Names = strcat(Names, SN);
ctypes = [];
for i = 1:Ns*Nc
ctypes = strcat(ctypes, 'T');
end
ctypes = num2cell(ctypes);
%---------------------------------------------------------------
% batch variables defined here for analysis 'contrasts'
%---------------------------------------------------------------
contrasts(1) = struct( ...
'names', {num2cell(Names, 2)'}, ...
'types', {ctypes}, ...
'values', {num2cell(c,2)'} ...
);
|