Skip to content

Implement NrrdReader for nrrd and seg.nrrd files  #4238

@kbressem

Description

@kbressem

Is your feature request related to a problem? Please describe.
For one project we are working with seg.nrrd files to create pixelwise segmentations. However, when trying to load these files with LoadImaged I get the following error:

TemplateTypeError: itk.Image is not wrapped for input type `itk.Vector[itk.SS,3], int`.

To limit the size of the package, only a limited number of
types are available in ITK Python. To print the supported
types, run the following command in your python environment:

    itk.Image.GetTypes()

Possible solutions:
* If you are an application user:
** Convert your input image into a supported format (see below).
** Contact developer to report the issue.
* If you are an application developer, force input images to be
loaded in a supported pixel type.

    e.g.: instance = itk.Image[itk.RGBPixel[itk.UC], int].New(my_input)

* (Advanced) If you are an application developer, build ITK Python yourself and
turned to `ON` the corresponding CMake option to wrap the pixel type or image
dimension you need. When configuring ITK with CMake, you can set
`ITK_WRAP_${type}` (replace ${type} with appropriate pixel type such as
`double`). If you need to support images with 4 or 5 dimensions, you can add
these dimensions to the list of dimensions in the CMake variable
`ITK_WRAP_IMAGE_DIMS`.

Describe the solution you'd like
When reading seg.nrrd files with pynrrd the files are handled correctly. I would thus propose to implement a NrrdReader based on pynrrd.
I have already written the NrrdReader for private use and would be happy to make a PR.

Describe alternatives you've considered
I have iterated through all supported pixel types, but this either raises an error or leads to incorrect import of the images. For example, some images have format [4, H, W, 1]. When forcing pixel type to itk.Image[itk.RGBPixel[itk.UC], int], the image is read as [3, H, W, 1], thus omitting a layer. This is a problem, as the number of layers in the different seg.nrrd files varies.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions