itk_dreg.itk
¶
ITK implementation of utilities for the itk-dreg
framework.
Includes implementations for dealing with
Streaming reader construction,
Debugging
Module Contents¶
Functions¶
Create an ITK image reader with initialized metadata. |
|
Create a chunked, unbuffered array representing an image buffer. |
|
Write out only the buffered region of an image to disk. |
Data¶
API¶
- itk_dreg.itk.logger¶
‘getLogger(…)’
- itk_dreg.itk.make_reader(filepath: str, imageio: itk.ImageIOBase = None, image_type: type[itk.Image] = FloatImage3DType) itk_dreg.base.itk_typing.ImageReaderType ¶
Create an ITK image reader with initialized metadata.
- Parameters:
filepath – The local or remote file to read. If the file is on the local disk, an absolute path must be provided.
imageio – Explicitly specifies how the image should be read. If
imageio
is not provided then ITK will attempt to determine the correct ImageIO reading procedure via the ITK object factory.image_type – The type of
itk.Image
to read.
- Returns:
An
itk.ImageFileReader
object with initialized metadata.- Raises:
KeyError – If
itk.ImageFileReader
is not defined for the specifiedimage_type
parameter.RuntimeError – If reading image metadata fails.
- itk_dreg.itk.make_dask_array(image_reader: itk_dreg.base.itk_typing.ImageReaderType, chunk_size: List[int] = None) dask.array.Array ¶
Create a chunked, unbuffered array representing an image buffer.
- Parameters:
image_reader – The
itk.ImageFileReader
image source. TODO: Runtime failures observed whenimage_reader
has zero buffered region but nonzero requested region. Investigate relation to NumPy bridge and determine whether this is a necessary requirement or can be worked around.- Chunk_size:
The requested size of each subdivided region in the result array. Default is 128 along each side.
- Returns:
A subdivided
dask.Array
representing the unbuffered input image voxel region. TODO: Verify that iteration over the lazy array does not buffer voxel elements.
- itk_dreg.itk.write_buffered_region(image: itk.Image, filepath: str)¶
Write out only the buffered region of an image to disk.
- Parameters:
image – The image to write.
image.GetBufferedRegion()
may or may not differ fromimage.GetLargestPossibleRegion()
.filepath – The destination for the buffered image write.
- Raises:
RuntimeError – If the image extract or write operation fails.