[Neuroimaging] voxel axes reorientation

Vinit Srivastava vinit.k.srivastava at gmail.com
Fri Oct 13 17:58:22 EDT 2017


Thanks Chris!

On Thu, Oct 12, 2017 at 10:45 AM, Christopher Markiewicz <effigies at bu.edu>
wrote:

> The basics are this:
>
> img = nib.load(fname)
> orig_ornt = nib.orientations.io_orientation(img.affine)
> targ_ornt = nib.orientations.axcodes2ornt('LAS')
> ornt_xfm = nib.orientations.ornt_transform(orig_ornt, targ_ornt)
>
> If you're using the latest master, you can simply do:
>
> img_LAS = img.as_reoriented(ornt_xfm)
>
> Otherwise, you'll need to transform the data and the affine:
>
> data = nib.orientations.apply_orientation(img.dataobj, ornt_xfm)
> affine = img.affine.dot(nib.orientations.inv_ornt_aff(ornt_xfm,
> img.shape))
> img_LAS = img.__class__(data, affine, img.header)
>
> (You should obviously check my work.)
>
> Chris
>
>
> On Wed, Oct 4, 2017 at 6:16 PM, Vinit Srivastava <
> vinit.k.srivastava at gmail.com> wrote:
>
>> Hi,
>>
>> I've been using nib.as_closest_canonical to reorient the voxel axes to
>> RAS+.
>>
>> Is there an optio to reorient images to a chosen format other than
>> canonical RAS format?  For example, I'd like to reorient from LPS to LAS.
>>
>> Thanks,
>>
>> Vinny
>>
>> _______________________________________________
>> Neuroimaging mailing list
>> Neuroimaging at python.org
>> https://mail.python.org/mailman/listinfo/neuroimaging
>>
>>
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20171013/0ebaedf7/attachment.html>


More information about the Neuroimaging mailing list