Optimize DICOM processing and enhance logging and testing framework#14
Merged
Conversation
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.
…sage for DICOM files
- 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.
…I preprocessing pipeline
…gress function for scan alignment
…andling and user prompts
…diate CSV files and improve output existence check
…re progress function; update Dockerfile to clone specific NiftyReg version with CUDA support
…nt management and improve logging
…integration and unit tests for DICOM processing
…action; add review documentation for clarity on implementation and test coverage
… selection and percentile calculation
…xtraction; improve logging for file removal process
…h stop method for better resource handling
…file handling, removing magic byte checks and simplifying fallback mechanisms.
…cmread for improved performance and accuracy
…ble thread pool size
…er pydicom versions
…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
…partial pipeline runs
… correct typo in Singularity hint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
.github/workflows/tests.ymlruns the test suite on Python 3.10–3.12 for pushes and pull requests..github/workflows/docker-test.ymltriggers Docker builds when relevant files change, ensuring container integrity.Documentation and Usability:
README.mdfor clarity:Pipeline Orchestration and Flexibility:
00_preprocess.shto support flexible execution:Performance and Robustness:
Testing Improvements:
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]