Hi Mark,
I wrote the attached helper script to add images to a saved "empty"
paired design job, to avoid having to enter images a pair at a time.
Hopefully you can use a similar idea to replace filenames as you need.
Best of luck,
Ged.
Mark Edmondson-Jones wrote:
> Hi,
>
> Apologies in advance if this is a very basic question... I'm fairly new
> to both SPM and Matlab!
>
> I am using SPM5 (on unix) and have created a job (.mat) file to perform
> the preprocessing of my first subject. I now want to edit this .mat
> file (or a copy of it) to perform equivalent preprocessing of my other
> subjects' data.
>
> What I think I want to do is simply substitute one subject's identifier
> with another's in all paths and file names. However, when I try to open
> the .mat file with a text editor the paths / file names appear with
> 'special' characters between each individual character.
>
> I have tried to use edit() in Matlab but this presents the same problem.
> I can view the components of the jobs structure in Matlab, but this
> seems to be quite long-winded.
>
> Could anyone suggest how I could do a sort of 'global find/replace'?
>
> Many thanks in advance.
>
> Regards,
> Mark Edmondson-Jones
>
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses, which could damage your computer
> system:
> you are advised to perform your own checks. Email communications with the
> University of Nottingham may be monitored as permitted by UK legislation.
>
function spm_paired_t_helper (dotmat)
% Modify a saved model .mat file for paired t-test
% to have chosen sets of images.
% structure:
% jobs{1}.stats{1}.factorial_design.des.pt.pair(1).scans{1} = filename1a
% jobs{1}.stats{1}.factorial_design.des.pt.pair(1).scans{2} = filename1b
% jobs{1}.stats{1}.factorial_design.des.pt.pair(2).scans{1} = filename2a
% etc.
if ( ~exist('dotmat', 'var') || isempty(dotmat) )
dotmat = spm_select(1, 'mat', 'Select saved paired t-test batch.mat file');
end
load(dotmat);
[filesA fAstat] = spm_select(inf, 'image', 'Select group1 images');
if (~fAstat); error('failed to select images'); end
filesA = cellstr(filesA);
N = length(filesA);
[filesB fBstat] = spm_select(inf, 'image', 'Select group2 images (in same order!)');
if (~fBstat); error('failed to select images'); end
filesB = cellstr(filesB);
if ( length(filesB) ~= N )
error('Must have same number of files (in same order!)');
end
for n=1:N
fileA = filesA{n};
fileB = filesB{n};
jobs{1}.stats{1}.factorial_design.des.pt.pair(n).scans = {fileA; fileB};
end
save(dotmat, 'jobs');
|