moveshelf_api package
Submodules
moveshelf_api.api module
This module provides core components for interacting with Moveshelf, including data types and an API client for managing projects, subjects, sessions, conditions, and clips.
- Dependencies:
Python standard library modules: base64, json, logging, re, struct, os.path
Third-party modules: requests, six, enum (optional), crcmod, mypy_extensions
- class moveshelf_api.api.BearerTokenAuth(token)[source]
Bases:
AuthBase
A custom authentication class for using Bearer tokens with HTTP requests.
- _auth
The formatted Bearer token string.
- Type:
str
- exception moveshelf_api.api.GraphQlException(error_info)[source]
Bases:
Exception
An exception raised when a GraphQL response contains errors.
- error_info
A list of error information returned by the GraphQL API.
- Type:
list
- class moveshelf_api.api.Metadata(*args, **kwargs)
Bases:
dict
A typed dictionary representing metadata for a clip.
- Keys:
title (str): The title of the clip.
description (str): The description of the clip.
previewImageUri (str): The URI for the preview image.
allowDownload (bool): Whether downloading is allowed.
allowUnlistedAccess (bool): Whether unlisted access is allowed.
startTimecode (Timecode): Optional start timecode for the clip.
- allowDownload: bool
- allowUnlistedAccess: bool
- description: str
- previewImageUri: str
- title: str
- class moveshelf_api.api.MoveshelfApi(api_key_file='mvshlf-api-key.json', api_url='https://api.moveshelf.com/graphql')[source]
Bases:
object
Client for interacting with the Moveshelf API.
This class provides methods to manage projects, subjects, sessions, conditions, and clips on the Moveshelf platform.
- api_url
The API endpoint URL.
- Type:
str
- _auth_token
Authentication token for API requests.
- Type:
- _crc32c
CRC32C checksum function for file validation.
- Type:
function
- createClip(project, metadata={})[source]
Create a new clip in the specified project with optional metadata.
- Parameters:
project (str) – The project ID.
metadata (Metadata) – Metadata for the new clip. Defaults to an empty Metadata dictionary.
- Returns:
The ID of the created clip.
- Return type:
str
- createSession(project_id, session_path, subject_id)[source]
Create a session for a specified subject within a project.
- Parameters:
project_id (str) – The ID of the project where the session will be created.
session_path (str) – The path to associate with the session.
subject_id (str) – The ID of the subject for whom the session is created.
- Returns:
A dictionary containing the session’s ID and project path.
- Return type:
dict
- createSubject(project_id, name)[source]
Create a new subject within a project.
- Parameters:
project_id (str) – The ID of the project where the subject will be created.
name (str) – The name of the new subject.
- Returns:
A dictionary containing the id and name of the created subject.
- Return type:
dict
- getAdditionalData(clip_id)[source]
Retrieve additional data associated with a specific clip.
- Parameters:
clip_id (str) – The ID of the clip for which to fetch additional data.
- Returns:
- A list of dictionaries, each containing details about additional data, including:
ID, data type, upload status, original file name, preview data URI, and original data download URI.
- Return type:
list
- getClipData(clip_id)[source]
Retrieve information about a specific clip.
- Parameters:
clip_id (str) – The ID of the clip to retrieve.
- Returns:
A dictionary containing the clip’s ID, title, and description.
- Return type:
dict
- getJobStatus(job_id)[source]
Retrieve the status of a specific job by its ID.
- Parameters:
job_id (str) – The ID of the job to check.
- Returns:
A dictionary containing the job’s ID, status, result, and description.
- Return type:
dict
- getProjectAndClips()[source]
Retrieve a list of all projects and the first 20 clips associated with each project.
- Returns:
- A list of dictionaries, where each dictionary contains project details
(ID and name) and a nested list of clip details (ID and title).
- Return type:
list
- getProjectClips(project_id, limit, include_download_link=False)[source]
Retrieve clips from a specified project.
- Parameters:
project_id (str) – The ID of the project from which to fetch clips.
limit (int) – The maximum number of clips to retrieve.
include_download_link (bool) – Whether to include download link information in the result. Defaults to False.
- Returns:
- A list of dictionaries, each containing clip information such as ID, title, and project path.
If include_download_link is True, includes file name and download URI.
- Return type:
list
- getProjectDatasets(project_id)[source]
Retrieve datasets for a given project.
- Parameters:
project_id (str) – The ID of the project.
- Returns:
A list of datasets, each containing name and downloadUri.
- Return type:
list
- getProjectSubjects(project_id)[source]
Retrieve all subjects (patients) associated with a specific project.
- Parameters:
project_id (str) – The ID of the project to retrieve subjects for.
- Returns:
A list of dictionaries, each containing the subject’s ID and name.
- Return type:
list
- getSessionById(session_id)[source]
Retrieve detailed information about a session by its ID.
- Parameters:
session_id (str) – The ID of the session to retrieve.
- Returns:
- A dictionary containing session details, including:
ID, projectPath, and metadata.
Associated project, clips, norms, and patient information.
- Return type:
dict
- getSubjectContext(subject_id)[source]
Retrieve the context information for a specific subject.
- Parameters:
subject_id (str) – The ID of the subject to retrieve.
- Returns:
- A dictionary containing subject details such as ID, name, metadata,
and associated project information (i.e., project ID, description, canEdit permission, and unlistedAccess permission).
- Return type:
dict
- getSubjectDetails(subject_id)[source]
Retrieve details about a specific subject, including metadata, associated projects, reports, sessions, clips, and norms.
- Parameters:
subject_id (str) – The ID of the subject to retrieve.
- Returns:
- A dictionary containing the subject’s details, including:
ID, name, and metadata.
Associated project details (ID).
List of reports (ID and title).
List of sessions with nested clips and norms details.
- Return type:
dict
- getUserProjects()[source]
Retrieve all projects associated with the current user.
- Returns:
A list of dictionaries, each containing the name and id of a project.
- Return type:
list
- processGaitTool(clip_ids, trial_type)[source]
Submit a Gait Tool processing job for the specified clips and trial type.
- Parameters:
clip_ids (list) – A list of clip IDs to process.
trial_type (str) – The trial type for the processing job.
- Returns:
The job ID of the created processing task.
- Return type:
str
- updateClipMetadata(clip_id, metadata)[source]
Update the metadata for an existing clip.
- Parameters:
clip_id (str) – The ID of the clip to update.
metadata (Metadata) – The updated metadata for the clip.
- Returns:
None
- updateSubjectMetadataInfo(subject_id, info_to_save)[source]
Update the metadata for an existing subject.
- Parameters:
subject_id (str) – The ID of the subject to update.
info_to_save (dict) – The metadata to save for the subject.
- Returns:
Whether the metadata update was successful.
- Return type:
bool
- uploadAdditionalData(file_path, clipId, dataType, filename)[source]
Upload additional data to an existing clip.
- Parameters:
file_path (str) – The local path to the file being uploaded.
clipId (str) – The ID of the clip to associate with the data.
dataType (str) – The type of the additional data (e.g., ‘video’, ‘annotation’).
filename (str) – The name to assign to the uploaded file.
- Returns:
The ID of the uploaded data.
- Return type:
str
- uploadFile(file_path, project, metadata={})[source]
Upload a file to a specified project.
- Parameters:
file_path (str) – The local path to the file being uploaded.
project (str) – The project ID where the file will be uploaded.
metadata (Metadata) – Metadata for the file. Defaults to an empty Metadata dictionary.
- Returns:
The ID of the created clip.
- Return type:
str
- class moveshelf_api.api.Timecode(*args, **kwargs)
Bases:
dict
A typed dictionary representing a timecode.
- Keys:
timecode (str): The timecode string in HH:MM:SS:FF format.
framerate (TimecodeFramerate): The framerate associated with the timecode.
- framerate: TimecodeFramerate
- timecode: str
- class moveshelf_api.api.TimecodeFramerate(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Enum representing supported video framerates for timecodes.
- FPS_24
24 frames per second.
- Type:
str
- FPS_25
25 frames per second.
- Type:
str
- FPS_29_97
29.97 frames per second.
- Type:
str
- FPS_30
30 frames per second.
- Type:
str
- FPS_50
50 frames per second.
- Type:
str
- FPS_59_94
59.94 frames per second.
- Type:
str
- FPS_60
60 frames per second.
- Type:
str
- FPS_1000
1000 frames per second.
- Type:
str
- FPS_1000 = '1000'
- FPS_24 = '24'
- FPS_25 = '25'
- FPS_29_97 = '29.97'
- FPS_30 = '30'
- FPS_50 = '50'
- FPS_59_94 = '59.94'
- FPS_60 = '60'
moveshelf_api.util module
- moveshelf_api.util.addOrGetTrial(api, session, condition, trialName=None)[source]
Add a new trial or retrieve an existing one based on its name.
- Parameters:
api – The API client instance to interact with the server.
session (dict) – A dictionary containing session details, including projectPath and project.
condition (dict) – The condition to associate the trial with, containing path and clips.
trialName (str, optional) – The name of the trial. If not provided, it will be auto-generated. Defaults to None.
- Returns:
The ID of the trial clip.
- Return type:
str
- moveshelf_api.util.getConditionsFromSession(session, conditions=[])[source]
Extract conditions and associated clips/norms from a session.
- Parameters:
session (dict) – A dictionary containing session details, including projectPath, clips, and norms.
conditions (list, optional) – A list to append or match conditions. Defaults to an empty list.
- Returns:
A list of conditions, each containing path, fullPath, norms, and clips.
- Return type:
list