Python tools for Interoperable Neuromorphometry Reporting
Project description
Python tools for Interoperable Neuromorphometry Reporting
Python tools for Interoperable Neuromorphometry Reporting (pinr
) allows for the creation of DICOM Structured Reporting Documents and FHIR Diagnostic Report resources from a T1w image processed by the FreeSurfer neuroimaging software suite.
Currently, only aseg.mgz
and aseg.stats
are supported and documented. Future versions may support other FreeSurfer segmentations and parcellations (such as thickness and volumes of different cortical regions).
DICOM conversion uses the highdicom package, and FHIR JSON files are created with fhir.resources.
For each label in the segmentation, a DICOM TID 300 "Measurement" object is created, and each Measurement is contained in a TID 1411 "Volumetric ROI Measurements and Qualitative Evaluations" object. The set of all labels are contained in a "Imaging Measurement Report" object.
FHIR output is in the form of a DiagnosticReport
Resource, consisting of Observation
Resources for each measurement. Specifically, each DICOM TID 300 object is mapped to a "Imaging Measurement" Observation
, and each "Imaging Measurement" is contained within a "Imaging Measurement Group" Observation
(analogous to a TID 1411 DICOM object). The "Imaging Measurement Groups" are contained within the DiagnosticReport
.
The mapping of DICOM SR to FHIR Resource follows the work of the HL7 Imaging Interegration Work Group. Details are provided here, with architecture information provided within this Implementation Guide.
DICOM Segmentation images created by pinr
are vieweable within 3D Slicer with the QuantitativeReporting Extension installed:
Installation
pinr
has no external dependencies apart from Python >= 3.8.
Run the following command for installation:
pip install pinr
Usage
pinr
provides both a Python and Command Line Interface (CLI)
CLI
An example command to produce all output is shown here:
pinr \
-i /path/to/file.dcm \
-s /path/to/mri/aseg.mgz \
-m /path/to/aseg.stats \
--dcm-seg /path/to/aseg.seg.dcm \
--dcm-sr /path/to/aseg.sr.dcm \
--fhir /path/to/aseg.fhir.json \
Run pinr --help
for more options and information!
Python Library
pinr
exposes a class called FreeSurferSeg
, which stores volumetric data and measurements.
To initiate:
t1w_dicom_file = "/path/to/file.dcm"
aseg_file = "/path/to/mri/aseg.mgz"
aseg_stats_file = "/path/to/aseg.stats"
# Choose where to save output files
dicom_seg_output_file = "/path/to/aseg.seg.dcm"
dicom_sr_output_file = "/path/to/aseg.sr.dcm"
fhir_output_file = "/path/to/aseg.fhir.json"
aseg = FreeSurferSeg(
t1w_dicom_file=t1w_dicom_file,
aseg_file=aseg_file,
aseg_stats_file=aseg_stats_file,
dicom_seg_output_file=dicom_seg_output_file,
dicom_sr_output_file=dicom_sr_output_file,
fhir_output_file=fhir_output_file,
)
Data is stored as properties of the object, and is written to the given file name if one is provided.
seg = aseg.seg
sr = aseg.sr
fhir = aseg.fhir
Testing
Example data is provided. After installation, clone the repo and cd into it. The following command will produce outputs using the provided input files. These can be compared against the existing output files
pinr \
-i ./tests/data/input/dicom/MR.1.3.12.2.1107.5.2.0.45074.2016081016110642184700287 \
-s ./tests/data/input/aseg.mgz \
-m ./tests/data/input/aseg.stats \
--dcm-seg ./tests/data/output/aseg_new.seg.dcm \
--dcm-sr ./tests/data/output/aseg_new.sr.dcm \
--fhir ./tests/data/output/aseg_new.fhir.json
Roadmap
- Improve testing and add CI (in progress)
- Incorporate feedback regarding architecture decisions of DICOM and FHIR outputs
- Formal validation of outputs
Work here was supported by the National Institute Of Biomedical Imaging And Bioengineering of the National Institutes of Health under Award Number R43EB030910.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pinr-0.1.1.tar.gz
.
File metadata
- Download URL: pinr-0.1.1.tar.gz
- Upload date:
- Size: 17.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.4.0-137-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33842e855b4e2f233200f2189720ca65d87fab5cfc07ed9a975e4d24862d764c |
|
MD5 | 9975c75bc3ea45fc09e6d00a64510998 |
|
BLAKE2b-256 | f372e3aac5f9d66d8b62d07fc4e1282a06c70c01f395c0d74adda2dd1bb1bdd1 |
File details
Details for the file pinr-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pinr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.2 CPython/3.10.6 Linux/5.4.0-137-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d369562cdde412f8e882f5eec3a8d8e3fbc4fe628cd2c29b8b36b8addf63f068 |
|
MD5 | e635140fcf62cfc76721ee89d76bafc6 |
|
BLAKE2b-256 | 9a53a54cf7b99aad09272513d28dfec9a31ba105074493aa1885be9adfcdffce |