Search Shortcut cmd + k | ctrl + k

DuckDB integration with medical imaging data (DICOM - Digital Imaging and Communication in Medicine).

Maintainer(s): nmontesg

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL dicom FROM community;
LOAD dicom;

Example

INSTALL dicom FROM community;
LOAD dicom;
FROM read_dicom('path/to/dicom_file.dcm');

About dicom

The dicom extension for DuckDB provides functionality to import medical imaging data (DICOM, Digital Imaging and Communication in Medicine) directly into DuckDB. It uses the powerful DCMTK C++ library to read DICOM files and convert them into JSON format.

For full documentation and examples, see the project documentation.

Key functionality:

  • read_dicom() - Table function to import DICOM files directly into DuckDB, including support for local and remote files.
  • DICOM_TAG - Custom type to work with DICOM tags, including conversion to and from VARCHAR.
  • tag_group(), tag_element(), tag_name() - Scalar functions to work with DICOM tags.
  • dicom secret type - Store credentials to establish connection with remote DICOM modalities, such as PACS systems.
  • query_dicom() and retrieve_dicom() - Table functions to query and retrieve DICOM datasets from a remote modalities directly into DuckDB using C-FIND and C-MOVE commands.

Added Functions

function_name function_type description comment examples
query_dicom table Query remote DICOM nodes using C-FIND commands NULL [FROM query_dicom(host='localhost', port=4242, match_keys=MAP {'Modality': 'MR'}, retrieve_keys=['StudyInstanceUID']);, FROM query_dicom(secret='my_dicom_conn_secret', qr_level='series', match_keys=MAP {'SeriesDate': '20070101'});]
read_dicom table Load DICOM files into DuckDB. The contents of each file are loaded into a row in JSON format. NULL [SELECT * FROM read_dicom('/path/to/dicom_files/');, SELECT * FROM read_dicom('/path/to/dicom_files/', load_pixel_data = true);]
retrieve_dicom table Retrieve DICOM data from remote modalities using C-MOVE commands NULL [FROM retrieve_dicom('1.3.54.24.5…', host='localhost', port=4242, incoming_port=11112, qr_level='study');, FROM retrieve_dicom('1.95.3…', '1.56.7…', …, secret='my_dicom_conn_secret', qr_level='series');]
tag_element scalar Extracts the element of a DICOM tag, as a VARCHAR containing the element in hexadecimal representation. NULL [SELECT tag_element('0008,01DA')]
tag_group scalar Extracts the group of a DICOM tag, as a VARCHAR containing the group in hexadecimal representation. NULL [SELECT tag_group('0008,01DA')]
tag_name scalar Extracts the name of the DICOM tag. If it can't be found, a VARCHAR with format GGGG,EEEE is returned. NULL [SELECT tag_name('0008,0008')]

Overloaded Functions

This extension does not add any function overloads.

Added Types

type_name type_size logical_type type_category internal
DICOM_TAG 0 STRUCT COMPOSITE true

Added Settings

name description input_type scope aliases typed_value
read_dicom_batch_size Number of files to read in each batch of read_dicom. UINTEGER GLOBAL [] 64
read_dicom_internal_buffer_size The size of the internal buffer (in kB) used to cache remote read when calling read_dicom over remote storage. UINTEGER GLOBAL [] 128
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp