-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Describe the bug
When running the preprocessing pipeline for a single patient using AtlasCentricPreprocessor, everything completes successfully.
However, when wrapping the same code in a for loop — even with a single-element list — the run fails during the defacing step with the following error:
Traceback (most recent call last): File "brainles.py", line 44, in <module> preprocessor.run() File ".../preprocessor/atlas_centric_preprocessor.py", line 165, in run self.run_defacing( File ".../preprocessor/atlas_centric_preprocessor.py", line 323, in run_defacing atlas_mask = self.center_modality.deface( File ".../modality.py", line 704, in deface defacer.deface( File ".../defacing/quickshear/quickshear.py", line 68, in deface mask = run_quickshear(bet_img=bet_img, buffer=self.buffer) File ".../defacing/quickshear/nipy_quickshear.py", line 158, in run_quickshear xdiffs, ydiffs = np.diff(low) ValueError: not enough values to unpack (expected 2, got 0)
To Reproduce
Steps to reproduce the behavior:
1.Install and import brainles_preprocessing
2. Run the following minimal code:
from pathlib import Path
from brainles_preprocessing.normalization.windowing_normalizer import WindowingNormalizer
from brainles_preprocessing.modality import CenterModality
from brainles_preprocessing.preprocessor import AtlasCentricPreprocessor
import os
windowing_normalizer = WindowingNormalizer(150, 150)
for patient in ["Patient01"]:
patient_folder = Path(f"/path/to/data/{patient}")
output_folder = patient_folder / "output"
os.makedirs(output_folder, exist_ok=True)
center = CenterModality(
modality_name="ncct",
input_path=patient_folder / f"{patient}_1_BaseCTtrans.nii.gz",
normalizer=windowing_normalizer,
raw_skull_output_path=output_folder / "ncct_raw.nii.gz",
normalized_skull_output_path=output_folder / "ncct_norm.nii.gz",
raw_defaced_output_path=output_folder / "ncct_defaced_raw.nii.gz",
normalized_defaced_output_path=output_folder / "ncct_defaced_norm.nii.gz",
defacing_mask_output_path=output_folder / "ncct_deface_mask.nii.gz",
)
preprocessor = AtlasCentricPreprocessor(
center_modality=center,
moving_modalities=[],
atlas_image_path="/path/to/template_1mm.nii"
)
preprocessor.run()- Observe the error during deface() only when inside a loop.
Expected behavior
Each loop iteration should initialize and run a new AtlasCentricPreprocessor cleanly, producing the same result as a single-patient run, without any ValueError during defacing.
Environment
- OS: Rocky Linux 8.8 (Green Obsidian)
- Platform ID: platform:el8
NVIDIA drivers and GPUs
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 580.95.05 Driver Version: 580.95.05 CUDA Version: 13.0 |
+-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 2080 Ti On | 00000000:B2:00.0 Off | N/A |
| 0% 27C P8 9W / 250W | 1MiB / 11264MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
Python environment and version?
Miniconda3 environment with Python 3.12.0
version of brainles_preprocessing ?
brainles_preprocessing==0.6.5