Giter VIP home page Giter VIP logo

tcia_processing's Introduction

TCIA_processing: tcia_dicom_to_nifti.py

Conversion script for conversion of TCIA DICOM data to NIfTI format (dataset: FDG-PET-CT-Lesion, doi: ).

Requirements

To run the script you will need a number of python packages. Use the terminal and run sequentially:

pip3 install numpy
pip3 install dicom2nifti
pip3 install nibabel
pip3 install pydicom
pip3 install tqdm
pip3 install nilearn

in case you use a Colab or Jupyter notebook and cannot use the terminal you can perform these installations by adding a "!" in front of the commands, e.g.

!pip3 install numpy
...

Data structure

DICOM data downloaded from TCIA will have the following format:

Directory structure of the original DICOM data within the folder /PATH/TO/DICOM/FDG-PET-CT-Lesions/ :

image

Usage

In order to run this script use the terminal and navigate to the path where the script is stored, then run:

python3 tcia_dicom_to_nifti.py /PATH/TO/DICOM/FDG-PET-CT-Lesions/ /PATH/TO/NIFTI/FDG-PET-CT-Lesions/

where

/PATH/TO/DICOM/FDG-PET-CT-Lesions/ is the directory of the DICOM data downloaded from TCIA (see above: data structure) and /PATH/TO/NIFTI/FDG-PET-CT-Lesions/ is the path you want to store the NIfTI files in.

You can ignore the nilearn warning:

.../nilearn/image/resampling.py:527: UserWarning: Casting data from int16 to float32 warnings.warn("Casting data from %s to %s" % (data.dtype.name, aux))

or suppress warnings by running the script as (after making sure everything works):

python3 -W ignore tcia_dicom_to_nifti.py /PATH/TO/DICOM/FDG-PET-CT-Lesions/ /PATH/TO/NIFTI/FDG-PET-CT-Lesions/

Output

The resulting NIfTI directory will have the following structure:

image

Execution time

Running the script can take multiple hours.

TCIA_processing: tcia_nifti_to_mha.py

Conversion script for conversion of TCIA NIfTI data (created using tcia_dicom_to_nifti.py - see above) to mha files.

Requirements

To run the script you will need a number of python packages. Use the terminal and run sequentially:

pip3 install SimpleITK
pip3 install tqdm

in case you use a Colab or Jupyter notebook and cannot use the terminal you can perform these installations by adding a "!" in front of the commands, e.g.

!pip3 install SimpleITK
...

Usage

In order to run this script use the terminal and navigate to the path where the script is stored, then run:

python3 tcia_nifti_to_mha.py /PATH/TO/NIFTI/FDG-PET-CT-Lesions/ /PATH/TO/MHA/FDG-PET-CT-Lesions/

where

/PATH/TO/NIFTI/FDG-PET-CT-Lesions/ is the directory of the NIfTI data generated using tcia_dicom_to_nifti.py (see above) and /PATH/TO/NIFTI/FDG-PET-CT-Lesions/ is the path you want to store the MHA files in.

You can ignore the nilearn warning:

.WARNING: In /tmp/SimpleITK-build/ITK/Modules/IO/Meta/src/itkMetaImageIO.cxx, line 669 MetaImageIO (0x2d9b300): Unsupported or empty metaData item intent_name of type Ssfound, won't be written to image file

or suppress warnings by running the script as (after making sure everything works):

python3 -W ignore tcia_nifti_to_mha.py /PATH/TO/NIFTI/FDG-PET-CT-Lesions/ /PATH/TO/MHA/FDG-PET-CT-Lesions/

TCIA_processing: tcia_nifti_to_hdf5.py

Conversion script for conversion of TCIA NIfTI data (created using tcia_dicom_to_nifti.py - see above) to a single hdf5 file

Requirements

To run the script you will need a number of python packages. Use the terminal and run sequentially:

pip3 install numpy
pip3 install h5py
pip3 install tqdm
pip3 install nibabel

in case you use a Colab or Jupyter notebook and cannot use the terminal you can perform these installations by adding a "!" in front of the commands, e.g.

!pip3 install numpy
...

Usage

In order to run this script use the terminal and navigate to the path where the script is stored, then run:

python3 tcia_nifti_to_hdf5.py /PATH/TO/NIFTI/FDG-PET-CT-Lesions/ /PATH/TO/HDF5/FDG-PET-CT-Lesions.hdf5

where

/PATH/TO/NIFTI/FDG-PET-CT-Lesions/ is the directory of the NIfTI data generated using tcia_dicom_to_nifti.py (see above) and /PATH/TO/HDF5/FDG-PET-CT-Lesions.hdf5 is the path and filename of the hdf5 file to be created.

Package Versions

All scripts were tested under python 3.9 with the following package versions:

dicom2nifti==2.3.3

nibabel==3.2.2

pydicom==2.3.0

h5py==3.6.0

tqdm==4.64.0

SimpleITK==2.1.1.2

nilearn==0.9.1

numpy==1.22.3

License

MIT

tcia_processing's People

Contributors

sergiosgatidis avatar thomaskuestner avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.