How bhklab/med-imagetools works
• CLI/Entry Point:
– Represent the command-line interface (“imgtools”) located under src/imgtools/cli with its __main__ module.
– This is where users initiate the autopipeline using flags (e.g., --dry_run, --continue_processing, --nnunet).
• Autopipeline Module:
– The core “pipeline” function (src/imgtools/pipeline.py) coordinates the overall processing workflow.
– It takes the user inputs and triggers the subsequent processing modules.
• DICOM Processing Modules:
– Highlight the dedicated DICOM module (src/imgtools/dicom) that includes reading, querying, sorting, and metadata extraction functionalities.
– Include the “modality_utils” sub-module that contains modality-specific processing routines (e.g., rtplan, rtstruct, seg_utils, etc.).
– The “dicom_find.py”, “dicom_reader.py”, and “read_tags.py” files are key for ingesting and parsing the raw DICOM data.
• Graph and Query System:
– Indicate that one of the design goals is to “crawl” the dataset and form a network that links various DICOMs based on interdependencies.
– Although not explicitly a separate module, this graph creation (or network formation) can be illustrated as part of the autopipeline workflow.
• Core Types and ROI Handling:
• IO Layer (Writers and Loaders):
– The input/output handling modules, found under src/imgtools/io, manage the reading and writing of processed data.
– Include the various writers such as the nifti_writer, numpy_writer, and hdf5_writer that convert processed images to deep learning–compatible formats.
• Logging and Exception Handling:
– The logging components (src/imgtools/loggers) and the exceptions module help with process tracking and error management.
• Utility and Pattern Parsing:
– The “pattern_parser” and “utils” modules include helper functions for data sanitization, filename processing, and timing/logging utilities.
• Configuration/Deployment:
– With Dockerfile, pixi.toml, and various config files (myppy.ini, pytest.ini, etc.), these may be shown as supporting elements that facilitate development, testing, and production deployments.
Relationships and Interactions
• From the autopipeline, branch out to the DICOM processing module, which further interacts with modality utilities and core types (building the graph of interdependencies).
• A side line for logging and error handling that intersects with all primary components to indicate cross-cutting concerns.
• Optionally, show that configuration elements (e.g., Dockerfile, config files) underlie all modules by supporting environment setup and deployment.
Architectural Patterns and Design Principles
• The use of a pipeline architecture is central: raw DICOM data becomes a graph-based model of modalities, then is processed and transformed into output formats suitable for ML.
• That the design supports reproducibility (with flags like random_state and dry_run) and extensibility (via clear module boundaries with coretypes, pattern parsing, and modality-specific utilities).
Final Guidance
• Remind the engineer that detail is key—each module from src/imgtools (CLI, coretypes, dicom, io, loggers, pattern_parser, etc.) should be represented as its own component.
• Integrate relationships and dependencies as identified from both the file structure and README; for example, illustrate how the raw datasets flow through a series of processing steps to result in a ML-ready dataloader.