Hi Donald,
Thank you very much.... I am going over the codes you sent.
Meanwhile, someone proposed to just modify the header v.pinfo values (since I am using one single vector to multiply the timecourses, it ends up multiplying each volume by the same number). And with a little bit of tweaking of renaming, it worked perfectly.
One bit of caution: My array included a few 0s, in that case something went wrong. When I opened the header files of those volumes (with MRIcro), the 'slope' of the 'image intensity' under window>information was not set to 0 as it should. So I had to use a very small number for those volumes to get close to a value of 0:
Here is the script. I'd appreciate if you can give me a feedback for any potential errors.
v = spm_vol(spm_select([1 Inf],'image'));
mywindow= sin(1:numel(v));
nameprefix='windowed_';
for i=1:numel(v)
v(i).pinfo(1:2,:)=v(i).pinfo(1:2,:) * max(mywindow(i),0.000001);
[PATHSTR,NAME,EXT]=fileparts(v(i).fname);
NEWNAME=strcat(nameprefix,NAME,EXT)
copyfile(v(i).fname,fullfile(PATHSTR,NEWNAME));
v(i).fname=fullfile(PATHSTR,NEWNAME);
end
spm_create_vol(v);
|