InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

Write to NRRD writes the wrong data type to the file

Open
#5,462 4 comments 0 reactions 0 assignees View on GitHub
type:Bug
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

### Description

Writing images at NRRD files outputs the wrong type to the NRRD header.

### Steps to Reproduce

```py
import SimpleITK as sitk

image = ... # Create sitk image
print(img.GetPixelIDTypeAsString()) # '16-bit signed integer'
sitk.WriteImage(image, "test.nrrd")
```

### Expected behavior

```none
NRRD0004
...
type: int16
```

### Actual behavior

```none
NRRD0004
...
type: short
```

### Reproducibility

This happens 100% of the time for int16 data type, but likely happens with other data types as well.

### Versions

I am using [the latest Python SimpleITK wrapper](https://pypi.org/project/simpleitk/2.5.2/).

### Environment

Python 3.13 on RHEL 9.5

### Additional Information

I use `sed -e '/./!Q' /path/to/nrrd/file.nrrd` to read the NRRD header easily.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.