Skip to main content

A python package to query the National Biomedical Imaging Archive (NBIA) database.

Project description

NBIA Toolkit

A python package that provides programmatic access to query and download images from the National Biomedical Imaging Archive (NBIA) and The Cancer Imaging Archive (TCIA) databases.

PyTests Documentation Status codecov pre-commit Python version CodeFactor

GitHub release (latest by date) PyPI version Downloads PyPI - Downloads GitHub repo size Docker Pulls

GitHub milestone detailsGitHub milestone details GitHub issues GitHub last commit

Features

[!TIP] For a thorough description of the package and its available features, please refer to the Documentation at NBIA-Toolkit Read The Docs

  • Programmatic access to the National Biomedical Imaging Archive (NBIA) and The Cancer Imaging Archive (TCIA) databases

    • Use NBIA Guest account to access public data OR authenticate using OAuth with user credentials for limited access data (requires approved data access).
    • Custom OAuth2 class for NBIA, TCIA, including special handling for dedicated server for the NLST collection.
  • Query NBIA database for metadata on collections, patients, studies, series, and images

  • Download images from NBIA

    • Validate doownloads with MD5 checksums for downloaded images
    • Auto-sort DICOM files using a user-defined pattern of DICOM tags with specialized DICOMSorter class

Installation

[!WARNING] nbiatoolkit is currently under development and is not guaranteed to be stable.

It is made available via PyPI and can be installed using pip:


pip install nbiatoolkit

Python Usage

Using a context manager, you can easily access the NBIA database and query for metadata on collections, patients, studies, and series.

from nbiatoolkit import NBIAClient

with NBIAClient() as client:
    # Get a list of collections
    collections = client.getCollections()
    print(collections)

    # Get a list of patients in a collection
    patients = client.getPatients(Collection="TCGA-KIRC")
    print(patients)

    # Get a list of studies for a patient
    studies = client.getStudies(PatientID="TCGA-BP-4989")
    print(studies)

    # Get a list of series for a study
    series = client.getSeries(StudyInstanceUID=studies[0]["StudyInstanceUID"])
    print(series[0:5])

CLI Usage

For quick access to the NBIA, the toolkit also provides a command line interface (CLI)

> NBIAToolkit --version

        _   ______  _______  ______            ____   _ __
       / | / / __ )/  _/   |/_  __/___  ____  / / /__(_) /_
      /  |/ / __  |/ // /| | / / / __ \/ __ \/ / //_/ / __/
     / /|  / /_/ // // ___ |/ / / /_/ / /_/ / / ,< / / /_
    /_/ |_/_____/___/_/  |_/_/  \____/\____/_/_/|_/_/\__/
    
Version: 0.33.0

Available CLI tools: 

getCollections [-h] [-u USERNAME] [-pw PASSWORD] [-p PREFIX]
               [-o OUTPUTFILE] [--version]

getBodyPartCounts [-h] [-u USERNAME] [-pw PASSWORD] [-c COLLECTION]
                  [-o OUTPUTFILE] [--version]

getPatients [-h] [-u USERNAME] [-pw PASSWORD] -c COLLECTION
            [-o OUTPUTFILE] [--version]

getNewPatients [-h] [-u USERNAME] [-pw PASSWORD] -c COLLECTION -d DATE
               [-o OUTPUTFILE] [--version]

getStudies [-h] [-u USERNAME] [-pw PASSWORD] -c COLLECTION
           [-p PATIENTID] [-s STUDYINSTANCEUID] [-o OUTPUTFILE]
           [--version]

getSeries [-h] [-u USERNAME] [-pw PASSWORD] [-c COLLECTION]
          [-p PATIENTID] [-m MODALITY] [-study STUDYINSTANCEUID]
          [--seriesInstanceUID SERIESINSTANCEUID]
          [--bodyPartExamined BODYPARTEXAMINED]
          [--manufacturerModelName MANUFACTURERMODELNAME]
          [--manufacturer MANUFACTURER] [-o OUTPUTFILE] [--version]

getNewSeries [-h] [-u USERNAME] [-pw PASSWORD] -d DATE [-o OUTPUTFILE]
             [--version]

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

nbiatoolkit was created by Jermiah Joseph. It is licensed under the terms of the MIT license.

User Agreements and Disclaimers

[!IMPORTANT] The NBIA-toolkit is NOT a product of the National Cancer Institute (NCI) and is not endorsed by the NCI. Users of the NBIA-toolkit are required to abide by the NBIA REST API Terms of Service and the NBIA Data Usage Policies and Restrictions The NBIA-toolkit is provided as an open-source tool based on the NBIA REST API and is provided "AS IS" without warranty of any kind. In no event shall the authors or contributors be liable for any claim, damages or other liability, arising from, out of or in connection with the NBIA-toolkit or the use or other dealings in the NBIA-toolkit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbiatoolkit-0.34.0.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

nbiatoolkit-0.34.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file nbiatoolkit-0.34.0.tar.gz.

File metadata

  • Download URL: nbiatoolkit-0.34.0.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nbiatoolkit-0.34.0.tar.gz
Algorithm Hash digest
SHA256 0ed4b4f4f56067ab9179f495cc1619d18e90d5b961584c7b279de684b965e3ac
MD5 194ad4dbb139f4dcfe22d802602f6ebd
BLAKE2b-256 aabb215af82fd9edf11f0e1ffededfe6c63f2246061278d7a40c6ec3c504e4d9

See more details on using hashes here.

File details

Details for the file nbiatoolkit-0.34.0-py3-none-any.whl.

File metadata

  • Download URL: nbiatoolkit-0.34.0-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for nbiatoolkit-0.34.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c99abc6e05b5f3b9bb06c94922d2bd4f2daa196d604fa121377172ff1d45f39
MD5 4dd7b3854052378d0f6fb3f5e93146d0
BLAKE2b-256 ee60903b9a3633b41096cc0ad749f2dc6e4ec237b1ccc9931cabb7c1dbf23008

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page