Project-MONAI / Project-MONAI/MONAI

NRRD Reader for 4D images

未关闭
#8,653 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.7k
派生
1.6k
平均合并
5 天 1 小时
30 天内合并 PR
20

描述

Describe the bug
I have created some 4D NRRD files, in which the first dimension represents channels (different MRI scans). In my current use case, the 4D volumes are slices, meaning that the final dimension is 1, but the same issues would happen for larger volumes.

I created the NRRD files myself using pynrrd, and try to load them into tensors with the NRRDReader. pynrrd automatically sets the 'sizes' key in the header, to the total array size. As such, the check to find channels in NRRDReader.get_data does not actually work on these files. In addition, it is not possible to save the 'space_directions' key in the header without a direction for the channel dimension too, otherwise 3DSlicer cannot load the file. Note that in my example, the kinds key is the following: ['list', 'domain', 'domain', 'domain']

A file can be found here. (The link expires after 10 days, please let me know if I need to make a new one)

I have implemented some fixes, mainly by using the 'kinds' key, I'll make a PR soon.

To Reproduce
Steps to reproduce the behavior:

  1. Use the LoadImage transform to load the image linked above.
  2. An error will happen in the _get_affine method, when transposing the affine matrix, because it's not symmetric.

Expected behavior
The NRRD file should be loaded correctly with the correct spacing information.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

Ensuring you use the relevant python executable, please paste the output of:

Workspace environment set for:
   /storage/workspaces/artorg_aimi/ws_00000
Activate existing virtual environment at /storage/homefs/dn25y590/projects/visual-models/ignition/.venv
To deactivate, hit Ctrl + D
SLURM_JOB_ID: 38784913
UV_ENV_FILE: 
================================
Printing MONAI config...
================================
MONAI version: 0+untagged.3276.g06c74ab.dirty
Numpy version: 2.3.2
Pytorch version: 2.6.0+cu124
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 06c74ab9080ec3bddbf9099d667e57ab726b5cce
MONAI __file__: /storage/homefs/<username>/projects/visual-models/monai/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
ITK version: 5.4.4
Nibabel version: 5.3.2
scikit-image version: NOT INSTALLED or UNKNOWN VERSION.
scipy version: 1.16.1
Pillow version: 11.3.0
Tensorboard version: 2.20.0
gdown version: 5.2.0
TorchVision version: 0.21.0+cu124
tqdm version: 4.67.1
lmdb version: 1.7.3
psutil version: 7.0.0
pandas version: 2.3.1
einops version: 0.8.1
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: 3.2.0
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.
clearml version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies


================================
Printing system config...
================================
System: Linux
Linux version: Rocky Linux 9.6 (Blue Onyx)
Platform: Linux-5.14.0-570.58.1.el9_6.x86_64-x86_64-with-glibc2.34
Processor: x86_64
Machine: x86_64
Python version: 3.12.11
Process name: python
Command: ['python', '-c', 'import monai; monai.config.print_debug_info()']
Open files: [popenfile(path='/storage/homefs/dn25y590/projects/visual-models/ignition/slurm_output/slurm-38784913.out', fd=1, position=1503, mode='a', flags=33793), popenfile(path='/storage/homefs/dn25y590/projects/visual-models/ignition/slurm_output/slurm-38784913.out', fd=2, position=75, mode='a', flags=33793)]
Num physical CPUs: 128
Num logical CPUs: 128
Num usable CPUs: 20
CPU usage (%): [8.8, 0.1, 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0, 0.0, 0.1, 0.1, 0.1, 53.3, 78.3, 47.1, 67.8, 57.5, 76.5, 53.3, 71.7, 44.1, 63.9, 75.1, 65.3, 78.5, 85.6, 65.5, 35.5, 0.2, 0.9, 0.0, 0.0, 0.3, 1.7, 0.0, 0.1, 0.5, 0.3, 1.6, 7.3, 0.7, 53.7, 47.2, 0.5, 0.5, 0.1, 0.3, 0.1, 0.1, 0.3, 0.3, 0.0, 1.5, 2.6, 0.5, 0.1, 1.6, 0.0, 0.5, 0.5, 0.1, 0.2, 0.0, 0.1, 0.1, 0.2, 0.1, 0.0, 0.1, 0.9, 0.0, 0.1, 0.1, 0.1, 1.0, 1.1, 0.1, 0.0, 0.2, 0.1, 0.0, 0.1, 0.0, 0.1, 0.3, 0.9, 0.1, 0.6, 0.4, 0.5, 0.2, 0.0, 0.2, 0.1, 0.3, 0.1, 0.5, 0.1, 0.1, 0.0, 0.1, 0.1, 0.0, 0.1, 0.2, 0.2, 0.1, 2.0, 100.0, 1.8, 0.9, 0.3, 0.6, 2.2, 0.0, 0.1, 32.6, 1.7, 0.1, 1.2, 0.1, 0.1, 0.1, 0.0]
CPU freq. (MHz): 2503
Load avg. in last 1, 5, 15 mins (%): [10.8, 11.6, 11.6]
Disk usage (%): 78.7
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 503.2
Available memory (GB): 398.9
Used memory (GB): 61.7

================================
Printing GPU config...
================================
Num GPUs: 1
Has CUDA: True
CUDA version: 12.4
cuDNN enabled: True
NVIDIA_TF32_OVERRIDE: None
TORCH_ALLOW_TF32_CUBLAS_OVERRIDE: None
cuDNN version: 90100
Current device: 0
Library compiled for CUDA architectures: ['sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_90']
GPU 0 Name: NVIDIA A100 80GB PCIe
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 108
GPU 0 Total memory (GB): 79.1
GPU 0 CUDA capability (maj.min): 8.0

Additional context
Add any other context about the problem here.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 LoadImage 变换使用的 NRRDReader.get_data 和 _get_affine 入口开始,然后使用链接的 4D NRRD 文件重现该故障。完成标准是 reader 能够加载通道维度由 kinds header 描述的 4D 文件,并在不出现 affine 转置错误的情况下保留正确的 spacing 信息。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
58/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。