Project-MONAI / Project-MONAI/MONAI

NRRD Reader for 4D images

Abierto
#8,653 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
8.7k
Forks
1.6k
Merge medio
5 d 1 h
PR fusionados (30 d)
20

Descripción

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.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con los puntos de entrada NRRDReader.get_data y _get_affine utilizados por la transformación LoadImage y, después, reproduce el fallo con el archivo NRRD 4D enlazado. Se considera completado cuando el lector carga archivos 4D cuya dimensión de canales está descrita por el encabezado kinds y conserva la información de espaciado correcta sin el error de transposición de affine.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
data
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
58/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.