[Neuroimaging] Convert Atlas from 1mm to 2mm

Matthew Brett matthew.brett at gmail.com
Mon Mar 14 18:41:05 EDT 2016


On Mon, Mar 14, 2016 at 1:35 PM, Ariel Rokem <arokem at gmail.com> wrote:
> A few more ways to do this are tallied in this previous thread:
> https://mail.python.org/pipermail/neuroimaging/2015-December/000656.html

The way I would myself do this (because I usually have nipy installed)
is to use nipy image slicing:

In [1]: import nipy
In [2]: img = nipy.load_image('/Users/mb312/data/mni_icbm152_nlin_asym_09a/mni_icbm152_t1_tal_nlin_asym_09a.nii')
In [3]: img.shape
Out[3]: (197, 233, 189)
In [4]: img.affine
Out[4]:
array([[   1.,    0.,    0.,  -98.],
       [   0.,    1.,    0., -134.],
       [   0.,    0.,    1.,  -72.],
       [   0.,    0.,    0.,    1.]])
In [5]: subsampled = img[::2, ::2, ::2]
In [6]: subsampled.shape
Out[6]: (99, 117, 95)
In [7]: subsampled.affine
Out[7]:
array([[   2.,    0.,    0.,  -98.],
       [   0.,    2.,    0., -134.],
       [   0.,    0.,    2.,  -72.],
       [   0.,    0.,    0.,    1.]])
In [8]: nipy.save_image(subsampled, 'smaller.nii')

Cheers,

Matthew


More information about the Neuroimaging mailing list