/PACSMAN_data

Repository that contains Python scripts to generate dummy DICOM and Nifti files for testing the PACSMAN tool. The generated files are also shared.

Primary LanguagePythonApache License 2.0Apache-2.0

PACSMAN_data

GitHub release (latest by date) GitHub Release Date Zenodo DOI

This repository contains Python scripts to generate dummy DICOM and Nifti files for testing the PACSMAN tool. The generated files are also shared.

Orthogonal cut view of the generated PACSMAN image

License

This repository contains code and data with different licenses:

Please see the respective LICENSE files in the root and the data subdirectory for more details.

Dependencies

The project requires Python >=3.10 and depends on the following Python packages:

  • dicom-parser==1.2.3
  • pydicom==2.3.1
  • nilearn==0.10.2
  • nibabel==5.2.0
  • matplotlib==3.8.2

For convenience, a Conda / Micromamba environment.yml file is provided in the conda/ folder to install them, which consists of running in a terminal:

conda env create -f https://raw.githubusercontent.com/TranslationalML/PACSMAN_data/main/conda/environment.yml

or alternatively

micromamba env create -f https://raw.githubusercontent.com/TranslationalML/PACSMAN_data/main/conda/environment.yml

The environment is also containing dcm2niix for conversion of a Nifti/JSON pair of files compliant to BIDS.

Installation

A setup.py file is provided such that you can easily install this package with pip without cloning the repository with the following command:

pip install git+https://github.com/TranslationalML/PACSMAN_data.git#egg=pacsman_data

How to use the script

Once installed, you can run the command-line executable generate_dummy_images.

Usage

usage: generate_dummy_images [-h] [--head_radius HEAD_RADIUS] [--eye_radius EYE_RADIUS]
                             [--image_size IMAGE_SIZE] -o OUTPUT_DIR [--force] [--save_nifti_png]

Script to generate dummy 3D PACMAN image files in Nifti and DICOM formats for testing purposes. The
generated image files are originally aimed to be used for testing PACSMAN commands, but they can be used
for testing any other DICOM / Nifti related tools.

options:
  -h, --help            show this help message and exit
  --head_radius HEAD_RADIUS
                        Radius of the PACSMAN head
  --eye_radius EYE_RADIUS
                        Radius of the PACSMAN eyes
  --image_size IMAGE_SIZE
                        Size of the generated image
  -o OUTPUT_DIR, --output_dir OUTPUT_DIR
                        Directory to store the generated DICOM files
  --force               For overwriting the nifti, dicomseries, bids and png subdirectories in the output
                        directory if they already exist.
  --save_nifti_png      Save a PNG image of the generated Nifti image

Example

Data provided in the repository have been generated by the following command:

generate_dummy_images -o ./pacsman_data/data --force --save_nifti_png

How to use the generated data

The generated data provided in this repository is automatically installed while installing the pacsman_data package so that it can be easily accessed in your python script.

Example to retrieve DICOM files

from importlib_resources import files
from glob import glob

dicom_files = glob(
    str(  # Convert PosixPath to str
        files(
            'pacsman_data.data'
        ).joinpath(
            'dicomseries'
        ).joinpath('*.dcm')
    )
)

Example to retrieve the Nifti file

from importlib_resources import files
from glob import glob

dicom_files = glob(
    str(  # Convert PosixPath to str
        files(
            'pacsman_data.data'
        ).joinpath(
            'nifti'
        ).joinpath('*.nii.gz')
    )
)

Example to retrieve the Nifti/JSON file pair compliant to BIDS

from importlib_resources import files
from glob import glob

bids_files = glob(
    str(  # Convert PosixPath to str
        files(
            'pacsman_data.data'
        ).joinpath(
            'bids'
        ).joinpath('*')
    )
)

How to cite

If you are using code or data from this project, please acknowledge it in your work with the following citation:

S. Tourbier and J. Richiardi, “TranslationalML/PACSMAN_data: PACSMAN_data 1.0”. Zenodo, Jan. 23, 2024. doi: 10.5281/zenodo.10554781.

If you are using Latex, this corresponds to the following bibtex entry:

@software{tourbier_2024_10554781,
  author       = {Tourbier, Sebastien and
                  Richiardi, Jonas},
  title        = {TranslationalML/PACSMAN\_data: PACSMAN\_data 1.0},
  month        = jan,
  year         = 2024,
  publisher    = {Zenodo},
  version      = {1.0},
  doi          = {10.5281/zenodo.10554781},
  url          = {https://doi.org/10.5281/zenodo.10554781}
}