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 摘要。