DOI:10.1117/1.JMI.10.6.061404 PyPI version Documentation Status codecov

Consolidated Breast Cancer Analysis DataBase

What is cobra_db?

cobra_db is a python package that allows you to extract DICOM metadata and store it in a MongoDB database. Allowing you to index, transform, and export your medical imaging metadata.

With cobra_db, you will have more visibility of your data enabling you to get more value from your medical imaging studies.

Once the metadata is in the database, you can import other text-based information (csv or json) into a custom collection and then run queries. This allows you to mix and match data extracted from different sources in different formats.

For example, let’s say you have 1 million mammography DICOM files and you would like to obtain the path of the files that belong to women scanned at an age of between 40 and 50 years old.

If you had cobra_db, you could run the following query in just a few seconds directly in the mongo shell.

  // filter the data
  {patient_age:{$gt:40, $lte:50}},
  // project it into a flat structure
    patient_id: "$dicom_tags.PatientID.Value"
    drive_name: "$file_source.drive_name",

This would return the patient id, the drive name and the relative path (to the drive) for all the files that match the selection criteria.


If you already have a working instance of the database, you only need to install the python package.

$ pip install cobra_db

If you would like to create a database from scratch, go ahead and follow the tutorial.


If you have an ImageMetadata instance id that you would like to access from python.

from cobra_db import Connector, ImageMetadataDao

# the _id of the ImageMetadata instance that you want to access
im_id = '62de8e38dc2414586e4ddb25'

# prompt user for password
connector = Connector.get_pass(
# connect to the ImageMetadata collection
im_dao = ImageMetadataDao(connector)
im = im_dao.get_by_id(im_id)

# this will return
... rel/path/to/my_file.dcm


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.


cobra_db was created by Fernando Cossio, Apostolia Tsirikoglou, Annika Gregoorian, Haiko Schurz, Hui Li, and Fredrik Strand. It is licensed under the terms of the Apache License 2.0 license.


This project has been funded by research grants Regional Cancer Centers in Collaboration 21/00060, and Vinnova 2021-0261.