Utility for querying and downloading data from a Kheops DICOM database
Project description
kheops-client
Utility for querying data from a Kheops DICOM database via the DICOMWeb API.
Setup
Install the Python package and command line utility using pip:
python -m pip install kheops-client
Alternatively, the package can be built and installed from source:
git clone https://github.com/hirsch-lab/kheops-client.git
cd kheops-client
python setup.py sdist
python -m pip install dist/kheops-client*.tar.gz
Usage
To access a Kheops database, one requires a URL to the DICOMWeb API and an access token. The examples below make use of the following variables:
URL="https://demo.kheops.online/api"
ACCESS_TOKEN="B18jTXCzTrQzj1ZednqHUY"
OUT_DIR="./downloads"
The tool offers two commands: list
and download
.
kheops-client --help
kheops-client list --help
kheops-client download --help
Query available studies and series
Query a list of available DICOM studies. A table with some information about the studies will be saved in the output directory.
kheops-client list studies \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR"
Query a list of available DICOM series. Again, a table with some information about the series will be saved in the output directory.
kheops-client list series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR"
List the available series for a particular study by providing the --study-uid
argument.
kheops-client list series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--study-uid "2.16.840.1.113669.632.20.1211.10000098591"
It is possible to constrain the query by specifying search filters. The following query requests a list of all available series with modality CT.
kheops-client list series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--search-filter "Modality" "CT" \
--out-dir "$OUT_DIR"
Note that the search filters can be combined.
kheops-client list series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--search-filter "Modality" "CT" \
--search-filter "PatientID" "FrxHK8" \
--out-dir "$OUT_DIR"
On some DICOMWeb servers, the retrieved lists may be truncated due to resource limitations (a warning will be issued in that case). In that case, arguments --limit
and --offset
can be of help.
kheops-client list series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--limit 5 \
--offset 10
Download DICOM data
It is possible to download single or multiple studies/series by using the download command.
For example, download a specific series by providing the arguments --study-uid
and --series-uid
. Use option --forced
to override the data if it already exists in the output folder.
kheops-client download series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--study-uid "2.16.840.1.113669.632.20.1211.10000098591" \
--series-uid "1.2.840.113704.1.111.5692.1127829280.6" \
--forced
To download all series in a study, just omit the argument --series-uid
.
kheops-client download series \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--study-uid "2.16.840.1.113669.632.20.1211.10000098591" \
--forced
Detail: This is pretty much equivalent to
kheops-client download studies \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--study-uid "2.16.840.1.113669.632.20.1211.10000098591" \
--forced
It is possible to download a list of previously selected studies/series by passing a .csv file. The table must contain a named column "StudyInstanceUID" for the "studies" mode, and additionally a column "SeriesInstanceUID" for the "series" mode.
kheops-client download studies \
--url "$URL" \
--token "$ACCESS_TOKEN" \
--out-dir "$OUT_DIR" \
--in-file "path/to/file/patients_oldest_cta.csv"
Further arguments/options
- For testing, it may be useful to limit the maximum number of studies and to specify an offset:
--limit
and--offset
- Option
--dry-run
runs the commands without writing any output data - Option
--meta-only
permits to download only the DICOM data structure without any bulk data. - Control the verbosity level by using the flag
--verbosity
multiple times. Or by using the short form:-v
,-vv
,-vvv
.
Python API
The above functionality is implemented in KheopsClient.
from kheops_client import KheopsClient
client = KheopsClient(url="URL", access_token="ACCESS_TOKEN")
client.list_studies(...)
client.list_series(...)
client.download_study(...)
client.download_series(...)
client.search_and_download_studies(...)
client.search_and_download_series(...)
Further reading
DICOM standard
DICOM dictionary browser
DICOMWeb standard
Pydicom (docs, api docs, github)
DICOMWeb client for python (github)
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
Built Distribution
File details
Details for the file kheops-client-0.3.1.tar.gz
.
File metadata
- Download URL: kheops-client-0.3.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d9d0bf6e59aa6b2d32dfa15ea1c3f62c9a888eaa5c60171127801f5865782a1 |
|
MD5 | f53c816ee538388e161450835793a7c4 |
|
BLAKE2b-256 | 4aa59c03d159d9d739de4c208ca5ee48a2632dd0e5bdfb1bfec92fa9ae2dfe82 |
File details
Details for the file kheops_client-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: kheops_client-0.3.1-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46afa2659184e99baa7d1bcde6d68254b4673ca31bdf92efcc9f052acd3f4701 |
|
MD5 | cf001fc5ad4b9f575fdcc24e7361acd2 |
|
BLAKE2b-256 | 180d64804c2987ebcd56f215373d6cb474f5e492612a04de5290d47ec4bbcf0b |