[pymvpa] How to create bold.nii.gz?

Michael Hanke michael.hanke at gmail.com
Fri Dec 26 20:16:06 UTC 2008


On Fri, Dec 26, 2008 at 12:34:40PM -0500, Yaroslav Halchenko wrote:
> 
> On Fri, 26 Dec 2008, Yune Lee wrote:
> 
> >    many thanks always for your help, Michael
> 
> >    I have already preprocessed image files in analyze format. Should I
> >    just convert them into 4D nifti in SPM5 and use it in the pyMVPA
> 
> >    or can I also load the individual .img/.hdr (total 925files) in the
> >    python given it also supports analyze format?
> if you are running released version (0.4.0), then you would need either to load
> them manually in the loop and concatenate to provide into Dataset.
Right, PyNIfTI would load a 4D ANALYZE file, but not 925 individual at once.

> If you are running master branch then since
> 1947ecad0f3c6181ac8678ea36af2d5900545611 from 15th of Dec,
> there is a support to provide as samples a list with filenames, where
> each file is a volume)..
> 
> smth like
> nds2 = NiftiDataset(samples=['file1.nii.gz', 'file2.nii.gz'],
> 		mask=maskfile, chunks=1, labels=1)
Another non-Python approach would be to simply merge them into a single
file using fsl:

  fslmerge -t singlefile.nii.gz *.hdr


You can do the same using plain PyNIfTI, by loading all files, use
Numpy's `vstack` or similar to concatenate the data arrays and write them
back into a NIfTI file using the header of one of the input files.
PyNIfTI will automatically figure out the pieces that have to be changed
in the header for the new 4D file and will write an appropriate one into the
file.

Either way is fine.

Michael



-- 
GPG key:  1024D/3144BE0F Michael Hanke
http://apsy.gse.uni-magdeburg.de/hanke
ICQ: 48230050



More information about the Pkg-ExpPsy-PyMVPA mailing list