Patched Nibabel Functions
- class nitransforms.patched.LabeledWrapStruct(binaryblock=None, endianness=None, check=True)[source]
- nitransforms.patched.shape_zoom_affine(shape, zooms, x_flip=True, y_flip=False)[source]
Get affine implied by given shape and zooms.
We get the translations from the center of the image (implied by shape).
- Parameters:
shape ((N,) array-like) – shape of image data.
N
is the number of dimensionszooms ((N,) array-like) – zooms (voxel sizes) of the image
x_flip ({True, False}) – whether to flip the X row of the affine. Corresponds to radiological storage on disk.
y_flip ({False, True}) – whether to flip the Y row of the affine. Corresponds to DICOM storage on disk when x_flip is also True.
- Returns:
aff – affine giving correspondance of voxel coordinates to mm coordinates, taking the center of the image as origin
- Return type:
(4,4) array
Examples
>>> shape = (3, 5, 7) >>> zooms = (3, 2, 1) >>> shape_zoom_affine((3, 5, 7), (3, 2, 1)) array([[-3., 0., 0., 3.], [ 0., 2., 0., -4.], [ 0., 0., 1., -3.], [ 0., 0., 0., 1.]]) >>> shape_zoom_affine((3, 5, 7), (3, 2, 1), False) array([[ 3., 0., 0., -3.], [ 0., 2., 0., -4.], [ 0., 0., 1., -3.], [ 0., 0., 0., 1.]])