Get a demo

Get in touch

Prefer using email? Write us at hello@moveshelf.com

Developer – Deleting data

    Search Knowledge Base
Getting started
  • Setting up the environment
  • Setting up a GitHub repository
  • Setting up the Moveshelf API
  • Recording - Intro to Moveshelf API
  • Using the API
  • Moveshelf API documentation
  • Configuration and authentication
  • Use built-in functions
  • Examples provided by Moveshelf
  • Importing data
  • Create subject
  • Import subject metadata
  • Create session
  • Import session metadata
  • Create trial
  • Upload data files
  • Create interactive reports
  • Querying data
  • Retrieve a filtered subset of subjects
  • Retrieve a filtered subset of sessions
  • Retrieve a subject
  • Retrieve subject metadata
  • Retrieve session
  • Retrieve session metadata
  • Export metadata to Excel
  • Retrieve trials
  • Retrieve data files
  • Deleting data
  • Delete a subject
  • Delete multiple subjects
  • Delete a session
  • Delete a trial
  • Delete all trials within a condition
  • Delete a data file
  • Example scripts
  • Public repository
  • Download data
  • Download large data sets
  • Batch upload data
  • Pre vs post intervention data export
  • Extending the Moveshelf API
  • Extending the Moveshelf API
  • Delete subjects, sessions, conditions, trials and data through the API.



    Delete a subject
    This section explains how to delete a subject from Moveshelf using the Moveshelf API, based on the subject's ID.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete an existing subject, add the following lines of code to your processing script:
    ## README: this example shows how we can delete a subject from Moveshelf 
    # using the Moveshelf API.
    
    # Delete a subject by ID
    subject_id = "<subjectId>" # subject["id"]
    result = api.deleteSubject(subject_id)
    
    if result:
        print(f"Subject {subject_id} deleted successfully")
    else:
        print(f"Failed to delete subject {subject_id}")


     

    Delete multiple subjects
    This section explains how to delete multiple subjects from Moveshelf using the Moveshelf API, based on the subjects' ID.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete multiple subjects, add the following lines of code to your processing script:
    ## README: this example shows how we can delete multiple subjects from Moveshelf 
    # using the Moveshelf API.
    
    # Delete multiple subjects at once
    subject_ids = [
        "<subjectId_1>",
        "<subjectId_2>",
        "<subjectId_3>"
    ]
    
    results = api.deleteSubjects(subject_ids)
    
    # Check results
    for subject_id, success in results.items():
        status = "SUCCESS" if success else "FAILED"
        print(f"Subject {subject_id}: {status}")
    
    # Count successes and failures
    successful = sum(results.values())
    total = len(subject_ids)
    print(f"Deleted {successful}/{total} subjects successfully")


     

    Delete a session
    This section explains how to delete a session from Moveshelf using the Moveshelf API, based on the session's ID.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete an existing session, add the following lines of code to your processing script:
    ## README: this example shows how we can delete a session from Moveshelf 
    # using the Moveshelf API.
    
    # Delete a session by ID
    session_id = "<sessionId>" # session["id"]
    result = api.deleteSession(session_id)
    
    if result:
        print(f"Session {session_id} deleted successfully")
    else:
        print(f"Failed to delete session {session_id}")


     

    Delete a trial
    This section explains how to delete a trial from Moveshelf using the Moveshelf API, based on the trial's ID.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete an existing trial, add the following lines of code to your processing script:
    ## README: this example shows how we can delete a trial from Moveshelf 
    # using the Moveshelf API.
    
    # Delete a trial (clip) by ID
    clip_id = "<clipId>" # clip["id"]
    result = api.deleteClip(clip_id)
    
    if result:
        print(f"Trial {clip_id} deleted successfully")
    else:
        print(f"Failed to delete trial {clip_id}")


     

    Delete all trials within a condition
    This section explains how to delete all trials within a specified condition from Moveshelf using the Moveshelf API, based on the session's ID and the condition name.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete all trials within an existing condition, add the following lines of code to your processing script:
    ## README: this example shows how we can delete all trials/clips within
    # a condition from Moveshelf using the Moveshelf API.
    
    # Delete all trials within a condition
    session_id = "<sessionId>" # session["id"]
    condition_name = "<conditionName>" # e.g., "Barefoot"
    
    result = api.deleteClipByCondition(session_id, condition_name)
    
    print(f"Deletion Results:")
    print(f"  Successfully deleted: {result['deleted_count']} trials")
    print(f"  Failed to delete: {result['failed_count']} trials")
    
    # Show detailed results
    for detail in result['details']:
        status = "✓" if detail['deleted'] else "✗"
        print(f"  {status} {detail['title']} ({detail['clip_id']})")


     

    Delete a data file
    This section explains how to delete a specific data file from Moveshelf using the Moveshelf API, based on the data's ID.
    Prerequisites
    Before implementing this example, ensure that your processing script includes all necessary setup steps. In particular, you should have:
    Implementation
    To delete an existing data file, add the following lines of code to your processing script:
    ## README: this example shows how we can delete a specific data
    # file from Moveshelf using the Moveshelf API.
    
    # Delete additional data by ID
    additional_data_id = "<additionalDataId>" # additional_data["id"]
    result = api.deleteAdditionalData(additional_data_id)
    
    if result:
        print(f"File {additional_data_id} deleted successfully")
    else:
        print(f"Failed to delete file {additional_data_id}")