Skip to main content

Data Import

Import an OpenCap session into Model Health for reprocessing and automated analysis. The import API handles the full workflow: session creation, subject association, video transfer and processing — reporting progress at each stage via a callback.

Full working example

See examples/python for a complete end-to-end script (opencap_import.py) that covers fetching trial data from OpenCap, subject selection, session configuration, per-trial activity type assignment and polling for analysis results.

What you're importing

The input to import_session is the raw trial JSON exported from an OpenCap session. This includes the calibration and neutral trials alongside any dynamic trials — all three are required. The SDK uploads the videos to Model Health and triggers reprocessing under your chosen configuration.

Importing Activities

let session = try await service.importSession(
activitiesJson,
subject: subject
) { status in
switch status {
case .creatingSession:
print("Creating session...")

case .createdSession(let sessionId):
print("Session created:", sessionId)

case .uploadingVideo(let trial, let uploaded, let total):
print("[\(trial)] Uploading: \(uploaded)/\(total)")

case .processing:
print("Processing...")
}
}

print("Import complete — session:", session.id)

With Session Configuration

Pass a SessionConfig to configure the session created during import. See Session Configuration for all available settings.

let session = try await service.importSession(
activitiesJson,
subject: subject,
config: SessionConfig(coreEngine: .v1_0)
) { status in
print(status)
}

Import Status Reference

The callback receives these values in order:

StatusDescription
creatingSessionA new session is being created on the server.
createdSessionThe session was created. Provides the new session ID.
uploadingVideoA video is being transferred. trial names the current activity; uploaded/total track progress within that activity.
processingAll videos uploaded; the server is processing the activity.

The callback fires once per activity for uploadingVideo and processing, so you will see multiple rounds if the import contains several activities.