Thanks a lot for your help! Now I understood. Best, Chao-Gan On Tue, Oct 4, 2011 at 10:43 AM, Jose Vicente Manjon Herrera < [log in to unmask]> wrote: > this should work ... > > load your 3D data files: > > % load your a set of n 3D volumes: > V=spm_vol('filename1.img'); > vol1=spm_read_vols(V); > V=spm_vol('filename2.img'); > vol2=spm_read_vols(V); > .... > V=spm_vol('filenamen.img'); > voln=spm_read_vols(V); > > % put them in a 4D variable > > data(:,:,:,1)=vol1; > data(:,:,:,2)=vol2; > .... > data(:,:,:,n)=voln; > > % write the 4D nifty file > > for ii=1:n > V(ii).dim=size(data); > V(ii).fname=['filename.nii']; > spm_write_vol(V(ii),data(:,:,:,ii)); > end > > > hope this helps > > Jose > > > > > Mensaje citado por YAN Chao-Gan <[log in to unmask]>: > > > Hi! Thanks for the discussion! > > I know SPM can write 3D .nii files, could SPM write 4D .nii files, and > if, > > in what kind of way? Thanks! > > > > Best, > > > > Chao-Gan > > > > On Tue, Oct 4, 2011 at 7:43 AM, John Ashburner <[log in to unmask]> > wrote: > > > > > Or also this way.... > > > > > > P='filename.img'; > > > Nii=nifti(P); > > > Nio=Nii; > > > Nio.dat.fname = 'filename.nii'; > > > Nio.dat.offset = 352; > > > Nio.dat(:,:,:,:,:) = Nii.dat(:,:,:,:,:); > > > > > > Best regards, > > > -John > > > > > > On 3 October 2011 20:47, Jose Vicente Manjon Herrera < > [log in to unmask]> > > > wrote: > > > > You can use MATLAB and SPM: > > > > > > > > V=spm_vol('filename.img'); > > > > ima=spm_read_vols(V); > > > > V.fname='filename.nii'; > > > > spm_write_vol(V,ima); > > > > > > > > hope this helps > > > > > > > > Jose > > > > > > > > Mensaje citado por Clifford Workman <[log in to unmask]>: > > > > > > > >> Or you could use MRIcroN. Open the file and go to "Save as NIfTI", > and > > > then > > > >> select "NIfTI (.nii)" from the "Save as type" drop down. > > > >> > > > >> Clifford Workman > > > >> Senior Research Program Coordinator > > > >> Division of Geriatric Psychiatry and Neuropsychiatry > > > >> Johns Hopkins University School of Medicine > > > >> Johns Hopkins Bayview Medical Center > > > >> 5300 Alpha Commons Drive, Fourth Floor > > > >> Baltimore, MD 21224 > > > >> (410) 550-9052 > > > >> > > > >> This e-mail contains information that is confidential and > privileged. > > > The > > > >> information is intended to be for the exclusive use of the > individual(s) > > > >> named above. If you are not the intended recipient, be advised that > any > > > >> disclosure, copying, distribution or other use of this information > is > > > >> strictly prohibited. If you have received this message in error, > please > > > >> notify me immediately and destroy the e-mail. > > > >> > > > >> From: SPM (Statistical Parametric Mapping) [mailto: > [log in to unmask]] > > > On > > > >> Behalf Of Jordan Constance > > > >> Sent: Monday, October 03, 2011 2:46 PM > > > >> To: [log in to unmask] > > > >> Subject: [SPM] .hdr/.img to .nii > > > >> > > > >> Hello SPMers, > > > >> > > > >> I have a very basic question. Is there a simple way to convert an > .hdr > > > and an > > > >> .img file into a single .nii file for use in Matlab/SPM8? > > > >> > > > >> Thanks for you help (and patience!) > > > >> > > > >> Jordan Constance > > > >> Graduate Research Assistant > > > >> Southern Illinois University - Carbondale > > > >> > > > > > > > > > > > > -- > > > > > > > > > > > > -- > >