> thanks a lot. That works great. Although it does not rescale the images to
> a scaling factor of 1 but apparently to the max value, it uniformizes the
> scaling across a time series which was what I was looking for.
> Three brief question:
> 1) So putting these rescaled images into the stats should give exactly the
> same results as submitting the original images, shouldn't it?
It should give almost exactly the same answers. There will be some small
rounding errors, just as there are with:
a = [1 2 3 4 5 6]
b = round(round(a*0.7)/0.7)
> 2) The 4D output of your script ends up in the directory where the scrpt
> was called upon. What would I have to change to have the 4D written into
> the dir of the images selected for rescaling?
Replace:
VO.fname = '4D.img';
with:
[pth,nam,ext] = fileparts(P(1,:));
VO.fname = fullfile(pth,'4D.img');
> 3) Can I do spatial & temporal preprocessing on 4D analyze images with
> spm2b? Can I submit 4D's to the stats? (If not yet, never mind this final
> one.)
Start spm, then type the following in Matlab:
global defaults
defaults.analyze.multivol=1;
Then try the various functions in SPM. I can't guarantee that it will work
(as the 4D stuff is largely untested), but I would be interested to hear
about any problems you encounter. See:
http://www.jiscmail.ac.uk/cgi-bin/wa.exe?A2=ind0303&L=spm&T=0&O=A&P=12186
Best regards,
-John
> > this is like a continuous thread of an issue I have been struggling with:
> > In order to put the images produced by spm2b's DICOM conversion toolbox
> > or any of its preprocessing into a 4D analyze file, I would love to have
> > all images rescaled to an intensity scaling of 1. By rescaling I mean to
> > read the intensity scale factor out from all the image headers and
> > multiply these scalings with the respective images of the time series. I
> > think that spm covaries out the (relative) overall global intensity for a
> > volume but with other supplementary tools this may be a problem. In the
> > past, you had helped me to modify spm99's spm_reslice.m to get a constant
> > scaling for all the images (see below) and later adviced me to use
> > spm_create_vol, spm_write_plane and spm_close_vol in a separate matlab
> > tool (instead of imcalc because the latter performs an automatic
> > rescaling to the maximum).
> >
> > However, given my limited matlab abilities and understanding of spm2b's
> > format, would you be able to provide a matlab code for rescaling the
> > respective intensities of a set of N 3D images to 1? If your time allows
> > to look into this at any point of your convenience, I would be very
> > grateful for it. If not, however, just let me know.
>
> Try:
>
> P = spm_get(Inf,'*.IMAGE','Select images');
> V = spm_vol(P);
>
> % Collect max and min values.
> mx = -Inf;
> %mn = Inf;
> for i=1:length(V),
> for p=1:V(i).dim(3),
> tmp = spm_slice_vol(V(i),spm_matrix([0 0 p]),V(i).dim(1:2),0);
> mx = max(mx,max(tmp(:)));
> %mn = min(mn,min(tmp(:)));
> end;
> end;
>
> % Write everything into a single 4D file.
> VO = V(1);
> VO.fname = '4D.img';
> VO.dim(4) = spm_type('int16');
> VO.pinfo = [mx/32767 0 0]';
> for i=1:length(V),
> VO.n = i;
> VO.mat = V(i).mat;
> VO = spm_create_vol(VO);
> for p = 1:VO.dim(3),
> tmp = spm_slice_vol(V(i),spm_matrix([0 0 p]),V(i).dim(1:2),0);
> spm_write_plane(VO,tmp,p);
> end;
> VO = spm_close_vol(VO);
> end;
--
Dr John Ashburner.
Functional Imaging Lab., 12 Queen Square, London WC1N 3BG, UK.
tel: +44 (0)20 78337491 or +44 (0)20 78373611 x4381
fax: +44 (0)20 78131420 http://www.fil.ion.ucl.ac.uk/~john
|