Skip to content

Latest commit

 

History

History
156 lines (128 loc) · 6.55 KB

README.md

File metadata and controls

156 lines (128 loc) · 6.55 KB

Tests Coverage Docker Hub

SCAMPI

SCAMPI is a DICOM processing engine that extracts DICOM files from a source (local filesystem or PACS server), reads their metadata, and writes the metadata to a SQL Server database and optionally copies source files to an output directory.

Prerequisites

  • Docker
  • A running SQL Server instance accessible from the container
  • DICOM source: either a local directory of .dcm files or a reachable PACS server

Configuration

Copy processing_engine/sample_config.yml to config.yml and edit it before running.

sources:
  my_source:                      # arbitrary name for this source
    type: filesystem              # "filesystem" or "pacs"
    directory: /my_images         # path inside the container (see volume mounts below)
    file_regex: .*                # optional: filter filenames by regex
    include_archives: True        # optional: also process .7z and .zip archives
  pacs_source:
    type: pacs
    aet: LOCALMACHINE           # your calling AE title
    aec: ORTHANC                # called AE title (the PACS)
    aem: LOCALMACHINE           # move destination AE title
    ip: 192.168.1.10
    port: 4242
    store_port: 11113           # port SCAMPI listens on for incoming C-STORE
    keys:
      - "QueryRetrieveLevel=STUDY"
      - "StudyInstanceUID=1.2.3..."

destination:
  files:
    directory: /output            # path inside the container (see volume mounts below)
    compress: true
    metadata_directory: /my_custom_directory # optional: replacement source path for database file URIs
    archive_name_template: "SCAMPI_%Y%m%d.7z" # optional: strftime template; defaults to "%Y%m%d.7z"
  metadata:
    dbType: MSSQL
    connectionString: mssql+pyodbc://user:pass@host.docker.internal,1433/SCAMPI?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes
    index: some_column

PACS source and query keys

The PACS keys setting is a list of strings in DICOMKeyword=value form, not a YAML mapping. SCAMPI splits each string at the first =, trims whitespace, and sends the resulting DICOM attributes directly in a C-MOVE request; it does not run a separate search first. For example:

keys:
  - "QueryRetrieveLevel=STUDY"
  - "StudyInstanceUID=1.2.3.4.5"

QueryRetrieveLevel selects the level to retrieve (PATIENT, STUDY, SERIES, or IMAGE). Other keys narrow the requested objects; for example, the study UID above requests a specific study. Use keys and matching values supported by your PACS, and quote entries in YAML. Wildcard matching depends on the DICOM attribute and PACS support. For a series-level query, use QueryRetrieveLevel=SERIES with the relevant study and series identifiers. SCAMPI currently uses the Patient Root Query/Retrieve model.

The connection fields identify both ends of the C-MOVE exchange: aet is SCAMPI's calling AE title, aec is the PACS AE title, and ip/port are the PACS address. aem is the destination AE title the PACS sends the retrieved files to; configure the PACS to route C-STORE data for that title to SCAMPI. SCAMPI listens for incoming C-STORE on store_port (default 11113), which must be reachable from the PACS. The optional pdu sets the maximum PDU size. Retrieved files are staged under ./received_dicoms/<source_name>/, separate from the optional destination.files.directory used to copy processed files.

Use host.docker.internal as the hostname to reach SQL Server running on the Docker host machine. When destination.files.compress is enabled, processed files are written to a YYYYMMDD.7z archive in the destination directory. Set destination.files.archive_name_template to a Python strftime template to customize its filename (for example, SCAMPI_%Y%m%d.7z); the default is %Y%m%d.7z. RelativeFileArchiveURI metadata includes the destination path and points to each member using <destination>/YYYYMMDD.7z!member/path. Set destination.files.metadata_directory to replace the configured filesystem source directory in database URIs without changing where files are stored. For example, with a source directory of /my_images, the URI /my_images/subdir/test.dcm becomes /my_custom_directory/subdir/test.dcm. To process metadata without copying files, omit destination.files.directory (or omit destination.files entirely) and the /output mount. You can still set metadata_directory to remap the database URI while leaving the source files in place:

destination:
  files:
    metadata_directory: /my_custom_directory
  metadata:
    dbType: MSSQL
    connectionString: <your connection string>
    index: some_column

In this mode, SCAMPI uses the path relative to the matching filesystem source directory, so /my_images/subdir/test.dcm is stored as /my_custom_directory/subdir/test.dcm.

Building the Docker image

Run from the repository root:

docker build -t scampi -f processing_engine/Dockerfile processing_engine/

Running the container

docker run --rm \
  -v /path/to/your/config.yml:/config.yml \
  -v /path/to/dicoms:/my_images \
  -v /path/to/output:/output \
  -v /path/to/templates:/templates \
  -v /path/to/logs:/SCAMPI/logs \
  scampi
Mount Purpose
config.yml:/config.yml Required. Your configuration file.
dicoms:/my_images Required for filesystem sources. Must match directory in config.
output:/output Optional. Where processed DICOM files are written. Must match destination.files.directory in config when file copying is enabled.
templates:/templates Required. A directory with modality.it config files. See DICOMTypeTranslater
logs:/SCAMPI/logs Optional. Persists log files to the host.

For PACS sources, no filesystem source mount is needed, but the container must have network access to the PACS server on the configured ip and port.

Windows paths

On Windows, use the full path with forward slashes or escape backslashes:

docker run --rm \
  -v C:/Users/you/config.yml:/config.yml \
  -v C:/Users/you/dicoms:/my_images \
  -v C:/Users/you/output:/output \
  scampi

Logs

Log files are written to /SCAMPI/logs/ inside the container (mount this path to retain them). Structured JSON logs are also printed to stdout, so docker logs <container> works for live output.