Skip to content

MIRTK image reader returns empty image (only zeros) for large NIfTI files #790

Description

@northh-jeremy

When loading a large NIfTI file using the MIRTK image reader (via RealImage::Read), the resulting image is silently returned as an empty volume filled with zeros, even though the NIfTI file contains valid intensity values.

Test Example:

InitializeIOLibrary();

RealImage image;
image.Read("large_image.nii.gz");

double min, max;
image.GetMinMaxAsDouble(&min, &max);
cout << "Min: " << min << ", Max: " << max << endl;

image.Write("output.nii.gz");

→ Min and max both return 0
→ Written output file is empty volume (only zeros)

Test File:

The attached file (large_image.nii.gz) is a valid NIfTI image (binary mask) with the following properties:

  • Image dimensions: 585 × 795 × 630
  • Voxel spacing: 0.4 × 0.4 × 0.4 mm
  • Verified to contain correct nonzero intensity values using Python/NiBabel:
python3 -c "import nibabel as nib; d=nib.load('large_image.nii.gz').get_fdata(); print(d.min(), d.max())"
# Output: 0.0 1.0

large_image.nii.gz

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions