Datamint

Documentation

Version: 2.22.0

A comprehensive Python SDK for interacting with the Datamint platform, providing seamless integration for medical imaging workflows, dataset management, and machine learning experiments.

From inception to completion, Datamint is your reliable partner. It assists from the very first day when you make your data available to your team, right up to the moment you’re set to launch your model.

Datamint

For Developers

Quick Start

Beginner

Install the package, configure your API key, and make your first calls.

Quick Start
Command-line tools

Beginner

Run the unified datamint <command> CLI for uploads, config, training, and inference.

Command-line tools
Client Python API

Intermediate

Use the Api class directly for full control over resources, projects, and annotations.

Client Python API
PyTorch & Lightning Integration

Intermediate

Plug Datamint datasets into PyTorch and Lightning training loops.

PyTorch & Lightning Integration
Training your Model

Intermediate

Train models with built-in one-line trainers – no training loop to write.

Training your Model
Tutorials

Browse runnable example notebooks, from getting started through full end-to-end pipelines.

Tutorials
Datamint vs Raw PyTorch

Advanced

Side-by-side comparison of raw PyTorch/Lightning code vs the Datamint equivalent.

Datamint vs Raw PyTorch
SSL Troubleshooting

Fix SSLCertVerificationError issues when connecting to the API.

SSL Certificate Troubleshooting

For Non-Developers

Just need to upload images and segmentations, no coding? Start here.

Upload Images & Segmentations

Beginner

No coding required. Set up your computer, get an API key, and upload your files from a terminal, step by step.

Upload Images & Segmentations (No Coding Required)

Quick Start

pip install datamint
datamint config
from datamint import Api

api = Api()
all_projects = api.projects.get_all()

See the full Quick Start guide for installing in a virtual environment, configuring your API key, and scaffolding a project with datamint init.

Architecture Overview

The Datamint Python API is organized into several key modules:

Module

Purpose

Key Classes

datamint.api

HTTP client and endpoint handlers for the API

Api, ResourcesApi ProjectsApi, etc.

datamint.entities

Pydantic data models representing platform objects

Resource, Project Annotation, etc.

datamint.dataset

PyTorch dataset classes for medical imaging

ImageDataset, VolumeDataset, etc.

datamint.lightning

PyTorch Lightning integration for training workflows

DatamintDataModule, UNetPPTrainer, etc.

datamint.mlflow

MLflow integration for experiment tracking and model registration

DatamintMLflowDataset, DatamintModel, etc.

Key Concepts

The SDK is built around a few core concepts that make data ingestion, annotation, training, and deployment work together smoothly.

Resources

Manage source data.

Upload medical images, videos, and other files. Organize resources into channels and projects, then tag and annotate them.

datamint.entities.resource.Resource
Annotations

Capture labels and geometry.

Add segmentations, bounding boxes, classifications, and other geometry to resources, with support for both 2D images and 3D volumes.

datamint.entities.annotations.annotation.Annotation
Projects

Group data for workflows.

Collect resources for annotation and ML training. Projects support split assignments (train/val/test) to keep experiments reproducible.

datamint.entities.project.Project
Datasets

Train with PyTorch-ready data.

Use dataset classes that load data from Datamint projects and automatically handle DICOM, NIfTI, image, and video formats.

datamint.dataset.base.DatamintBaseDataset
Trainers

Accelerate common training loops.

Rely on high-level trainers to streamline dataset setup, model configuration, MLflow logging, and checkpointing.

datamint.lightning.trainers.BaseTrainer
Models

Package models for deployment.

Register ML models for inference on the Datamint platform, including segmentation, classification, and other custom use cases.

datamint.mlflow.flavors.model.DatamintModel

Common Workflows

Uploading Data

from datamint import Api

api = Api()

# Upload a single file
resource = api.resources.upload_resource("/path/to/image.dcm")

# Upload with options
api.resources.upload_resource(
    "/path/to/image.dcm",
    channel="CT Scans",
    tags=["baseline", "ct"],
    anonymize=True,
)

# Upload multiple files
api.resources.upload_resources(["/path/to/a.dcm", "/path/to/b.dcm"])

Creating a Training Project

from datamint import Api
from datamint.dataset import ImageDataset

api = Api()

# Create project
project = api.projects.create(
    name="Liver Segmentation",
    description="CT liver segmentation dataset",
)

# Add resources
resources = api.resources.get_list(channel="CT Scans")
api.projects.add_resources(resources, project)

# Load dataset
dataset = ImageDataset(project="Liver Segmentation")

Training a Model

from datamint.lightning import UNetPPTrainer

trainer = UNetPPTrainer(
    project="Liver Segmentation",
    image_size=256,
    batch_size=16,
    max_epochs=50,
    accelerator="gpu",
)

results = trainer.fit()
print(results["test_results"])

Deploying a Model

from datamint import Api

api = Api()

# Deploy a registered model
deploy_job = api.deploy.start(
    model_name="liver-segmentation-model",
    model_alias="latest",
)
print(deploy_job.status)

Community & Support

GitHub Issues

Indices and Tables