allensdk.core.sitk_utilities module

allensdk.core.sitk_utilities.fix_array_dimensions(array, ncomponents=1)[source]

Convenience function that reorders ndarray dimensions for io with SimpleITK

Parameters:
array : np.ndarray

The array to be reordered

ncomponents : int, optional

Number of components per pixel, default 1.

Returns:
np.ndarray :

Reordered array

allensdk.core.sitk_utilities.get_sitk_image_information(image)[source]

Extract information about a SimpleITK image

Parameters:
image : sitk.Image

Extract information about this image.

Returns:
dict :

Extracted information. Includes spacing, origin, size, direction, and number of components per pixel

allensdk.core.sitk_utilities.read_ndarray_with_sitk(path)[source]

Read a numpy array from a file using SimpleITK

Parameters:
path : str

Read from this path

Returns:
image : np.ndarray

Obtained array

information : dict

Additional information about the array

allensdk.core.sitk_utilities.set_sitk_image_information(image, information)[source]

Set information on a SimpleITK image

Parameters:
image : sitk.Image

Set information on this image.

information : dict

Stores information to be set. Supports spacing, origin, direction. Also checks (but cannot set) size and number of components per pixel

allensdk.core.sitk_utilities.write_ndarray_with_sitk(array, path, **information)[source]

Write a numpy array to a file using SimpleITK

Parameters:
array : np.ndarray

Array to be written.

path : str

Write to here

**information : dict

Contains additional information to be stored in the image file. See set_sitk_image_information for more information.