Skip to content

Optimize DICOM processing and enhance logging and testing framework#14

Merged
NicholasLeotta99 merged 89 commits into
mainfrom
feature/hpc-singularity
Jun 11, 2026
Merged

Optimize DICOM processing and enhance logging and testing framework#14
NicholasLeotta99 merged 89 commits into
mainfrom
feature/hpc-singularity

Conversation

@NicholasLeotta99

Copy link
Copy Markdown
Member

This pull request introduces several major improvements to the MRI preprocessing pipeline, focusing on automation, usability, performance, and testing. The changes include new GitHub Actions CI workflows, a significant overhaul of the documentation for clarity and accuracy, improvements to the main preprocessing orchestrator script, performance optimizations in DICOM metadata extraction, and enhancements to the scan alignment step.

Continuous Integration and Automation:

  • Added GitHub Actions workflows for automated testing and Docker builds:
    • .github/workflows/tests.yml runs the test suite on Python 3.10–3.12 for pushes and pull requests.
    • .github/workflows/docker-test.yml triggers Docker builds when relevant files change, ensuring container integrity.

Documentation and Usability:

  • Completely rewrote and reorganized README.md for clarity:
    • Improved feature descriptions, updated project structure, and provided detailed installation, usage, and testing instructions.
    • Added step-by-step guides for both containerized and CLI workflows, and clarified outputs for each pipeline stage. [1] [2]
  • Minor improvements to CLI access script messages for better user guidance. [1] [2]

Pipeline Orchestration and Flexibility:

  • Enhanced 00_preprocess.sh to support flexible execution:
    • Added command-line arguments for running specific steps, custom input/output directories, and partial pipeline runs.
    • Improved error handling and output status messages for each step.

Performance and Robustness:

  • Optimized DICOM metadata extraction:
    • Now loads only specific tags during DICOM initialization, greatly reducing parsing time for large datasets. [1] [2]
  • Updated scan alignment script to use the correct base path, log the NiftyReg version, and improve parallel execution logic. [1] [2] [3] [4]

Testing Improvements:

  • Documented comprehensive test coverage in the README and provided clear instructions for running different test suites, ensuring reliability and reproducibility.

These updates collectively make the pipeline easier to use, more maintainable, and better suited for automated environments.

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

google-labs-jules Bot and others added 30 commits March 16, 2026 19:44
The loop responsible for identifying and logging completely removed
session IDs performed terribly due to two O(N) operations inside
the iteration:

1. It repeatedly checked `if ID not in Iden_uniq_after` causing
   an O(N) array lookup.
2. It performed `pd.concat` on every match inside the loop,
   which forces O(N^2) total DataFrame reallocations and copies.

This fix mitigates both bottlenecks:
1. `Iden_uniq_after` is converted to a set prior to the loop,
   resulting in instantaneous O(1) membership checks.
2. Matches are accumulated in a Python list and concatenated a
   single time at the end via `pd.concat(fully_removed_list)`,
   reducing the complexity to O(N).

Co-authored-by: NicholasLeotta99 <32443489+NicholasLeotta99@users.noreply.github.com>
…2338934965225293055

Optimize Removed_fully.csv generation in 02_parseDicom.py
…Data_table boolean flag normalization. Allowing supplemental scanning to skip when results saved
…ing. Added checks for existing split and ordered tables, enhancing logging for relocation processes.
- Added integration tests for the end-to-end workflow of 01_scanDicom.py, ensuring the pipeline produces valid DataFrames with expected schemas.
- Improved unit tests for 01_scanDicom.py, verifying core functionalities in isolation with synthetic DICOM files.
- Introduced known-result tests for 01_scanDicom.py and 02_parseDicom.py, independently computing expected values to validate filtering logic against DICOMfilter.
- Enhanced documentation within test files for clarity on test purposes and expected outcomes.
…diate CSV files and improve output existence check
…re progress function; update Dockerfile to clone specific NiftyReg version with CUDA support
…integration and unit tests for DICOM processing
…action; add review documentation for clarity on implementation and test coverage
…xtraction; improve logging for file removal process
NicholasLeotta99 and others added 23 commits June 3, 2026 11:55
…file handling, removing magic byte checks and simplifying fallback mechanisms.
…cmread for improved performance and accuracy
…nDicom.py

* Removes `logger` from worker function arguments to prevent lock-pickling deadlocks when using `run_function` in multiprocess mode.
* Replaces the serial `os.walk` in `_scan_subdir` with a BFS approach to yield disjoint branch directories for parallel worker consumption, drastically speeding up initial file discovery in deep hierarchies.
* Fixes failing unit tests referencing the updated function signatures.

Co-authored-by: NicholasLeotta99 <32443489+NicholasLeotta99@users.noreply.github.com>
This commit resolves GitHub CI Check Suite Failures by updating the `test_scanDicom_full.py` tests. The function signatures for `_find_dicom_worker` and `_extractDicom_impl` had their `logger` arguments removed in a previous commit to resolve a lock-pickling deadlock during multiprocessing. However, the full test suite had not been updated to reflect these signature changes.

This commit updates those function calls across the full suite, allowing all 32 tests to correctly pass.

Co-authored-by: NicholasLeotta99 <32443489+NicholasLeotta99@users.noreply.github.com>
…adlock-18142721776499537583

Fix multiprocessing deadlock and parallelize directory walk in 01_scanDicom.py
…sure root logger captures errors from worker threads
…ction details, and address dead code cleanup
- start_control.sh: auto-detect container runtime (Docker → Singularity → Apptainer)
- Add mri_preprocessing.singularity.def matching existing Dockerfile layers
- Exclude .sif images from git
- start_control.sh: detect Docker → Singularity/Apptainer → conda/mamba → error
- environment.yml: conda env spec (dcm2niix + Python + test deps)
- run_pipeline_conda.sh: standalone conda pipeline runner
- code/scripts/install_niftyreg.sh: source build helper for reg_f3d
@NicholasLeotta99 NicholasLeotta99 merged commit 21bb596 into main Jun 11, 2026
1 of 7 checks passed
@NicholasLeotta99 NicholasLeotta99 deleted the feature/hpc-singularity branch June 11, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants