DICOM splitter based on unique tags, or localizers
Project description
DICOM Splitter
Overview
Summary
DICOM Splitter is a Flywheel Gear that splits DICOM archives by default into separate archives based on localizers and unique SeriesInstanceUIDs, with optional splits by geometry, orientation, or varying field values.
The main use cases for this gear are if
- There are one or more localizers (scouts, etc.) mixed in with primary images
- There are multiple Series in one archive.
- The archive is multiphasic with respect to slice location (geometry split)
- The archive has non uniform image orientations (geometry split)
- Some field varies across the archive and you have reason to the archive based on that field (group_by split)
The gear is set to do the first two above by default, i.e. it will extract a localizer(s) from the archive, and it will extract each unique SeriesInstanceUID into its own archive.
Version 2.0.0 Breaking Change
Note that versions of this gear prior to version 2.0.0 are named splitter. On the
release of version 2.0.0, the gear was renamed to dicom-splitter and all package
names, import statements, and other references were modified to reflect this rename.
Any software that depends on dicom-splitter should be updated with this breaking
change in mind.
License
License: MIT
Classification
Category: Utility
Gear Level:
- Project
- Subject
- Session
- Acquisition
- Analysis
[[TOC]]
Inputs
- dicom
- Name: dicom
- Type: DICOM file
- Optional: false
- Description: DICOM file to be checked
Configuration
-
debug
- Name: debug
- Type: boolean
- Default:
False - Description: Include debug output.
-
delete_input
- Name: delete_input
- Type: boolean
- Default:
True - Description: Delete input on successful split. Default True.
-
extract_localizer
- Name: extract_localizer
- Type: boolean
- Default:
True - Description: If true and DICOM archive contains embedded localizer images (ImageType = Localizer), the embedded images will be saved as their own DICOM archive.
- Note: Localizer extraction is not attempted if archive is successfully split by geometry.
-
filter_archive
- Name: filter_archive
- Type: boolean
- Default:
True - Description: Whether to filter out invalid DICOM files from an input DICOM zip archive. DICOM files must have all required file meta tags to be considered valid.
-
group_by
- Name: group_by
- Type: string
- Default: "SeriesInstanceUID"
- Description: Comma-separated tags to group DICOM frames by.
- Note: To skip group_by split, set value to empty string.
-
max_geometric_splits
- Name: max_geometric_splits
- Type: integer
- Default: -1
- Description: Maximum number of splits to perform by image orientation and/or position. -1 skips geometric split; set to value greater than 0 to attempt split by geometry.
- Note: As of version 2.1.0, group_by split is attempted before
geometric split, and if group_by split is successful, the geometric
split will not be attempted. To enforce splitting by geometry instead
of by tag, set
group_byto""andmax_geometric_splitsto a value greater than 1 (suggested value4, previous default).
-
tag
- Name: tag
- Type: string
- Default: "dicom-splitter"
- Description: The tag to be added to files upon run completion.
- Note: Previous versions (<2.0.0) had "splitter" as default.
-
tag-single-output
- Name: tag-single-output
- Type: string
- Default: ""
- Description: In addition to the tag applied to all files above, apply a second tag to a single output so that a downstream gear rule can run on the acquisition once splitter finishes. Default empty, no tag will be applied.
-
zip-single-dicom
- Name: zip-single-dicom
- Type: string
- Default: "match"
- Description: Zip single dicom outputs.
Outputs
Files
The gear will output nothing if no splitting action was taken. Otherwise it will output a variable number of archives depending on the input and configuration named with the following pattern:
series-<SeriesNumber>_<Modality>_<SeriesDescription>_<GroupByTags>[_localizer], where
SeriesNumberis the value of theSeriesNumbertag across the archive. By default the largest sized archive (by number of slices) will retain the originalSeriesNumberand additional archives will be incremented by1000 + i, whereiis the index of the archive in a list of total archives.SeriesDescriptionis the value of theSeriesDescriptiontag across the archiveGroupByTagsis an underscore separated list of all tags appearing in thegroup_bylist, and their corresponding value in that archive. Tags "SeriesInstanceUID" and "SeriesNumber" are not included even if they appear in thegroup_bylist.Modalityis the value of theModalitytag across the archive- If the series is a localizer,
_localizerwill be appended.
As of version 2.1.0, if the input DICOM file is a zip archive that contains non-DICOM
files, if the gear is configured with filter_archive as True, the gear will attempt
to filter out the non-DICOM files and output a corrected archive even if the DICOM
archive is not otherwise split.
Pre-requisites
No prerequisites gear runs are required before running dicom-splitter.
Usage
Workflow
flowchart LR
A[DICOM input file]:::input --> G((DICOM Splitter)):::gear
G --> C[Splits archives by localizers and SeriesInstanceUIDs,
with optional geometry, orientation, or field-based grouping]:::split
C --> D[If no split occurs, no output is generated.
Otherwise, archives follow this naming pattern:
series-SeriesNumber_Modality_SeriesDescription_GroupByTags_localizer.
SeriesNumber is incremented by 1000 + i for additional archives.]:::output
classDef input fill:#222b45,stroke:#4a5568,stroke-width:2px,color:#ffffff;
classDef gear fill:#1d4ed8,stroke:#1e3a8a,stroke-width:2px,color:#ffffff;
classDef split fill:#4ade80,stroke:#15803d,stroke-width:2px,color:#000000;
classDef output fill:#facc15,stroke:#b45309,stroke-width:2px,color:#000000;
Synergy with Other Gears
The dicom-splitter gear is primarily designed to be used when the DICOM file first gets ingested to Flywheel.
The dicom-splitter gear is a good candidate to be run as one of a series of gear rules (more here).
Contributing
For more information about how to get started contributing to that gear, check out CONTRIBUTING.md.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fw_gear_dicom_splitter-2.1.2-py3-none-any.whl.
File metadata
- Download URL: fw_gear_dicom_splitter-2.1.2-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e50cf21382b94e5375b9e69940daf02b7e3f3160f999ca04bcbd0d8977da875a
|
|
| MD5 |
6586bfa4b68c1a7f5138393659f25cd2
|
|
| BLAKE2b-256 |
31c769c9656243eb923f40f7bb4577eeed0a4497d11743a043550487b620dbc0
|