IO
- auxiliary.io.read_image(input_path: str, force_dtype: int | None = None) ndarray[tuple[int, ...], dtype[_ScalarType_co]]
Read an image file using SimpleITK and return its data as a NumPy array. Supports e.g. NIfTI and other formats. More details: https://simpleitk.readthedocs.io/en/master/IO.html
- Parameters:
input_path (str) – Path to the input file.
force_dtype – Optional[int]: If provided, cast the image to the given sitk data type, e.g. sitk.sitkFloat32.
- Returns:
Image data as a NumPy array.
- Return type:
numpy.ndarray
- auxiliary.io.write_image(input_array: str | ndarray[tuple[int, ...], dtype[_ScalarType_co]], output_path: str, reference_path: str | None = None, create_parent_directory: bool = False) None
Write an image file from a NumPy array or file using SimpleITK. Supports e.g. NIfTI and other formats. More details: https://simpleitk.readthedocs.io/en/master/IO.html
- Parameters:
input_array (numpy.ndarray or str) – The NumPy array containing the data to be written or the path to it. Note: boolean arrays will be converted to uint8.
output_path (str) – The path where the output file will be saved.
reference_path (str, optional) – Path to a reference file for spatial metadata.
create_parent_directory (bool) – If True, create parent directories if they don’t exist.
- Returns:
None