Skip to content

ITKReader silently changes the affine matrix to RAS without informing the users #3914

@Can-Zhao

Description

@Can-Zhao

Describe the bug
The function _get_affine(self, img) of ITKReader() in monai/data/image_reader.py
silently flips the affine matrix to match with the format of nibabel.
See line 307: flip_diag = [[-1, 1], [-1, -1, 1], [-1, -1, 1, 1]][sr - 1] # itk to nibabel affine

However, the user is not aware of this operation unless they check the source code of ITKReader().
If they thought the affine was the raw affine, it would cause mistakes.

Additional context
Three possible solutions:

  1. let the operation of flipping affine matrix be a separate transform
  2. set a bool input for ITKReader() to indicate whether to flip the affine.
  3. add a key in image_mata_dict to indicate that the image affine has been flipped.

There might be other solutions, but users need to know this operation has been done.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions