Brilliant! I would have never found that doing spm_<tabt><tab> :). Is
this now used throughout SPM5? spm_vol_nifti uses it, but spm_read_vols
etc don't???
I tried this:
warning off; % disable those flipping warnings
N1=nifti('fmri_TR2.nii');
N2=N1;
N2.dat=N1.dat;
N2.dat.fname='thatotherimage.nii'
N2.dat(:,:,:,:)=N1.dat(:,:,:,:);
create(N2);
warning on; % OK you may complain again
Would that be the right way to copy N1 to N2 and write it? Just copying
the dat field didn't seem to work for copying the voxel data.
Thanks
AM
John Ashburner wrote:
> Try this:
>
> N = nifti('fmri_TR2.nii');
> X = N.dat;
> subplot(2,1,1); imagesc(X(:,:,10,4)');
> subplot(2,1,2); plot(squeeze(X(20,20,10,:)))
>
> but be careful of writing to the file. If you type the following, then you
> get a few more examples that show the other stuff that can be done...
>
> help nifti/Contents
>
> All the best,
> -John
>
>
> On Tuesday 08 April 2008 16:45, Alle Meije Wink wrote:
>> Dear all,
>>
>> Is it possible, with spm command line functions, to read and write 4D
>> NifTI files?
>>
>> After
>> V=spm_vol('fmri_TR2.nii');
>> with fmri_TR2.nii a 4D NifTI data set, I get an array V of records about
>> the individual volumes in the 4D data set.
>>
>> The fastest way that I know to read data is spm_read_vols, but due to
>> the NifTI record of my file being split into N separate records (???),
>> spm_read_vols only load one volume at a time.
>>
>> For fast reading and writing of 4D data, is there a way to not do this
>> splitting of NifTI records, and load/save the data as a 4D array?
>>
>> Many thanks
>> Alle Meije
|