Datamint Python API

A comprehensive Python SDK for interacting with the Datamint platform, providing seamless integration for medical imaging workflows, dataset management, and machine learning experiments.
📋 Table of Contents
🚀 Features
- Dataset Management: Download, upload, and manage medical imaging datasets
- Annotation Tools: Create, upload, and manage annotations (segmentations, labels, measurements)
- Experiment Tracking: Integrated MLflow support for experiment management
- PyTorch Lightning Integration: Streamlined ML workflows with Lightning DataModules and callbacks
- DICOM Support: Native handling of DICOM files with anonymization capabilities
- Multi-format Support: PNG, JPEG, NIfTI, and other medical imaging formats
See the full documentation at https://sonanceai.github.io/datamint-python-api/
📦 Installation
[!NOTE]
We recommend using a virtual environment to avoid package conflicts.
From PyPI
pip install -U datamint
Virtual Environment Setup
Click to expand virtual environment setup instructions
We recommend that you install Datamint in a dedicated virtual environment, to avoid conflicting with your system packages.
For instance, create the enviroment once with python3 -m venv datamint-env and then activate it whenever you need it with:
-
Create the environment (one-time setup):
python3 -m venv datamint-env
-
Activate the environment (run whenever you need it):
| Linux/macOS | source datamint-env/bin/activate |
| Windows CMD | datamint-env\Scripts\activate.bat |
| Windows PowerShell | datamint-env\Scripts\Activate.ps1 |
-
Install the package:
pip install datamint
⚙ Setup API key
To use the Datamint API, you need to setup your API key (ask your administrator if you don't have one). Use one of the following methods to setup your API key:
Method 1: Command-line tool (recommended)
Run datamint-config in the terminal and follow the instructions. See command_line_tools for more details.
Method 2: Environment variable
Specify the API key as an environment variable.
Bash:
export DATAMINT_API_KEY="my_api_key"
Python:
import os
os.environ["DATAMINT_API_KEY"] = "my_api_key"
📚 Documentation
🛠️ Command Line Tools
Full documentation at command_line_tools.
Upload Resources
Upload DICOM files with anonymization:
datamint-upload /path/to/dicoms --recursive --channel "training-data" --publish --tag "my_data_tag"
It anonymizes by default.
Configuration Management
datamint-config
datamint-config --api-key "your-key"
🔒 SSL Certificate Troubleshooting
If you encounter SSL certificate verification errors like:
SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Quick Fix
1. Upgrade certifi:
pip install --upgrade certifi
2. Set environment variables:
export SSL_CERT_FILE=$(python -m certifi)
export REQUESTS_CA_BUNDLE=$(python -m certifi)
3. Run your script:
python your_script.py
Alternative Solutions
Option 1: Use Custom CA Bundle
from datamint import Api
api = Api(verify_ssl="/path/to/your/ca-bundle.crt")
Option 2: Disable SSL Verification (Development Only)
from datamint import Api
api = Api(verify_ssl=False)
🆘 Support
Full Documentation
GitHub Issues