How aces/loris-mri works
1. What this repository is
- This is the imaging-ingestion companion to the main LORIS platform, not the core web app itself.
- Its job is to move imaging and related acquisition data from raw files into a structured archive and a relational database, then trigger downstream validation, conversion, and insertion steps.
2. Primary runtime split: legacy Perl + newer Python
- The repo is intentionally hybrid.
- Perl still drives much of the historical pipeline and operational tooling: uploadNeuroDB/, DTIPrep/, dicom-archive/, and tools/.
- Python 3.11 hosts newer pipeline code, database models/queries, BIDS importers, and helper scripts under python/.
- This split is important architecturally because the Python side largely wraps or modernizes behaviors that already exist in the Perl stack.
3. Core storage boundary: relational database
- The main stateful boundary is the LORIS imaging database.
- Python has a substantial ORM-style layer in python/lib/db/models and python/lib/db/queries, while Perl uses object-broker modules in uploadNeuroDB/NeuroDB/objectBroker.
- The schema includes imaging uploads, DICOM archive records, MRI protocol/violation tracking, candidate/session/project metadata, physiological files, and notification spool tables.
- Test SQL in test/RB_SQL/ mirrors those tables, showing the database is a first-class integration point.
4. Filesystem and archive boundary
- Raw and derived imaging data are managed on disk, typically under /data/$projectname and /opt/$projectname.
- The installer configures these paths and permissions, and the pipeline assumes shared filesystem access between LORIS and the imaging worker host.
- Many scripts operate by reading from archive directories, writing converted outputs, and updating DB records to reflect file locations and processing status.
5. DICOM archive and study import subsystem
- dicom-archive/ and python/loris_dicom_importer/ handle DICOM-centric ingestion and summarization.
- These components extract metadata, summarize studies, tar/archive data, and support updating MRI upload records.
- The flow is: raw DICOM arrives, metadata is summarized and validated, archive records are created/updated, and the database becomes the source of truth for what was ingested.
6. Imaging pipeline orchestration
- python/lib/dcm2bids_imaging_pipeline_lib/ contains the newer pipeline framework.
- It exposes distinct pipeline stages such as:
- DICOM archive loading
- DICOM validation
- NIfTI insertion
- pushing imaging files to S3
- The corresponding entrypoint scripts in python/scripts/ are thin wrappers that launch those stages operationally.
- This subsystem is where the architecture most clearly separates orchestration from domain logic.
7. BIDS import and export support
- python/loris_bids_reader/ parses BIDS datasets and their sidecars, scans, participants, and events files.
- python/lib/import_bids_dataset/ uses that reader to validate subjects/sessions, copy files, and map BIDS content into LORIS concepts.
- This is a distinct ingestion path from DICOM: instead of converting raw scanner output first, it accepts an already-BIDS-shaped dataset and maps it into the database and archive.
8. Electrophysiology and physiological data
- The repo is not MRI-only.
- python/loris_ephys_chunker/ and python/lib/physio/ manage electrophysiology chunking and physiological event/file structures.
- python/lib/database_lib/physiological_* and matching DB models/queries show a parallel ingestion model for physio/ephys data with archives, channels, events, parameters, and output types.
- This is a separate domain boundary, but it reuses the same DB-centric and filesystem-centric architecture.
9. MNI/MINC and image-processing utilities
- The MNI/ Perl modules and many scripts under tools/ and uploadNeuroDB/bin/ depend on the MINC toolkit and DICOM utilities.
- These utilities support format conversion, concatenation, defacing, header updates, and other image-processing steps used by the insertion pipeline.
- The README’s installation steps make clear that external toolchains like MINC and dcmtk are required system dependencies, not optional libraries.
10. DTI/DTIPrep and legacy processing path
- DTIPrep/ contains scripts and modules for diffusion MRI quality control and registration-related processing.
- This indicates a legacy but still operational branch for DTI-specific preprocessing before or alongside database insertion.
- It sits beside the broader imaging pipeline rather than inside the newer Python orchestration layer.
11. Operational entrypoints and batch jobs
- The repository includes many executable scripts for batch operations: uploads, validation, cleanup, header updates, tarchive management, defacing, and conversions.
- These are designed for cron, manual ops, or pipeline automation on shared infrastructure.
- In architecture terms, they are the “edges” that connect raw data arrival, scheduled maintenance, and DB/filehousekeeping.
12. Infrastructure and deployment model
- Deployment is VM/fileserver oriented, not container-first.
- The install scripts in install/ configure directories, environment variables, CPAN dependencies, Python virtual environments, and database connectivity.
- The repo assumes integration with the main LORIS environment, the MySQL database, local filesystem permissions, and sometimes S3 for file distribution.
13. Validation and test boundaries
- GitHub Actions workflows and the Python test suite cover integration and ORM/SQL synchronization.
- Docker-based test assets under test/ suggest the database layer and scripts are validated in isolation from the full production environment.
- This reinforces that the architecture’s critical contract is consistency between file processing and database state.
14. How to draw the main architecture
- A good diagram would show multiple ingestion sources on the left: DICOM studies, BIDS datasets, NIfTI/MINC files, and physio/ephys data.
- In the center, show pipeline workers in Perl and Python performing validation, conversion, chunking, and archiving.
- On the right, show the shared LORIS imaging database plus filesystem archive storage, with optional S3 as an external distribution target.
- Around that, place the MINC/DCMTK/DTIPrep toolchain as external processing dependencies and the main LORIS platform as the consuming system for metadata and upload status.
Main entry points: dcm2bids_imaging_pipeline_lib Pipeline lib · uploadNeuroDB UploadNeuroDB · dicom-archive DICOM archive · tools Ops tools
Components 20
Perl stack
Legacy ingestion, archive handling, and operational scripts.
- UploadNeuroDB · Core legacy MRI ingestion and insertion runtime.
uploadNeuroDB - Object broker · Perl-side database access and record mappers for imaging entities.
uploadNeuroDB/NeuroDB/objectBroker - DICOM archive · Summarizes, tars, and updates DICOM study archive records.
dicom-archive - Ops tools · Batch scripts for uploads, cleanup, conversion, and maintenance.
tools - DTIPrep · Legacy diffusion MRI preprocessing and quality-control path.
DTIPrep - MNI utils · Shared MINC-oriented utilities and helpers used by image processing scripts.
MNI
Python stack
Modern pipeline code, readers, importers, and ORM/query layers.
- Pipeline lib · Modern DICOM archive, validation, insertion, and S3 pipeline framework.
python/lib/dcm2bids_imaging_pipeline_lib - Entrypoints · Thin operational scripts that launch pipeline stages and batch jobs.
python/scripts - DB models · Python model layer for MRI, candidate, session, physio, and archive records.
python/lib/db/models - DB queries · Query helpers that read and update imaging and physio state.
python/lib/db/queries - DICOM importer · Study summarization and database import for raw DICOM datasets.
python/loris_dicom_importer - BIDS reader · Parses BIDS datasets, sidecars, scans, participants, and events.
python/loris_bids_reader - BIDS import · Validates and maps BIDS datasets into LORIS imaging concepts.
python/lib/import_bids_dataset - Ephys chunker · Chunks electrophysiology data for ingestion and archival.
python/loris_ephys_chunker - Physio libs · Physiological file, event, parameter, and chunking support.
python/lib/physio
State boundaries
Shared database and filesystem/archive targets.
- LORIS DB · Shared imaging database for uploads, archive records, protocol checks, physio, and notifications.
- Archive FS · Shared project directories for raw, derived, and inserted imaging data.
- S3 bucket · Optional external distribution target for imaging files.
External tools
System toolchains and downstream platforms used by the pipelines.
- LORIS platform · Main platform that consumes imaging metadata, upload status, and validated records.
- MINC/DCMTK · External conversion, archive, and header-editing toolchains required by ingestion scripts.
Connections 22
- DICOM archive → LORIS DB: update archive · Creates and updates DICOM archive and MRI upload records.
- UploadNeuroDB → LORIS DB: insert/update · Writes imaging, candidate, protocol, and notification state.
- Object broker → LORIS DB: ORM access · Perl database access layer for imaging entities.
- DB models → LORIS DB: map schema · Python ORM models mirror the imaging database tables.
- DB queries → LORIS DB: query state · Python query layer reads and mutates persistent imaging state.
- DICOM importer → LORIS DB: import studies · Summarizes DICOM studies and records import results.
- BIDS import → LORIS DB: map BIDS · Validates BIDS content and stores mapped subjects, sessions, and files.
- Ephys chunker → LORIS DB: track chunks · Persists electrophysiology and associated archive metadata.
- Physio libs → LORIS DB: physio records · Handles physiological files, events, parameters, and archive objects.
- Entrypoints → Pipeline lib: launch · Operational wrappers invoke pipeline stages.
- Pipeline lib → Archive FS: read/write · Loads archive data, validates inputs, inserts outputs, and stages files.
- UploadNeuroDB → Archive FS: process files · Legacy insertion scripts read and write shared imaging directories.
- DICOM archive → Archive FS: tar/summarize · Builds study archives and stores file-location metadata.
- BIDS reader → BIDS import: parse inputs · Provides structured BIDS metadata to the importer.
- DICOM importer → Pipeline lib: feeds validation · DICOM study summaries feed the newer pipeline flow.
- Ops tools → MINC/DCMTK: shell out · Batch utilities depend on MINC and DICOM command-line tools.
- MNI utils → MINC/DCMTK: wrap tools · Perl utilities provide MINC-oriented helper functions.
- DTIPrep → MINC/DCMTK: QC pipeline · DTI preprocessing depends on external imaging utilities.
- Pipeline lib → S3 bucket: push files · Optional stage publishes imaging files to object storage.
- LORIS DB → LORIS platform: share state · Downstream platform consumes validated imaging metadata and status.
- Ops tools → LORIS DB: ops maintenance · Batch scripts manage uploads, cleanup, and record reconciliation.
- Entrypoints → LORIS DB: batch jobs · Entry scripts perform ingestion and maintenance jobs against the database.