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:
--limitand--offset - Option
--dry-runruns the commands without writing any output data - Option
--meta-onlypermits to download only the DICOM data structure without any bulk data. - Control the verbosity level by using the flag
--verbositymultiple 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)
Metadata
Release files for kheops-client 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kheops-client-0.3.1.tar.gz | 14.7 kB | Without provenance | Details for kheops-client-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kheops_client-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for kheops_client-0.3.1-py3-none-any.whl |
Total release size: 28.8 kB
Release files / kheops-client-0.3.1.tar.gz
| Download URL | kheops-client-0.3.1.tar.gz |
|---|---|
| Size | 14.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d9d0bf6e59aa6b2d32dfa15ea1c3f62c9a888eaa5c60171127801f5865782a1
|
|
BLAKE2b-256 checksum How to use checksums |
4aa59c03d159d9d739de4c208ca5ee48a2632dd0e5bdfb1bfec92fa9ae2dfe82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Release files / kheops_client-0.3.1-py3-none-any.whl
| Download URL | kheops_client-0.3.1-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46afa2659184e99baa7d1bcde6d68254b4673ca31bdf92efcc9f052acd3f4701
|
|
BLAKE2b-256 checksum How to use checksums |
180d64804c2987ebcd56f215373d6cb474f5e492612a04de5290d47ec4bbcf0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.5
|
Security for kheops-client 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.