{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exporting to BIDS Formats\n", "\n", "## What is BIDS and Why Use It?\n", "\n", "The [Brain Imaging Data Structure (BIDS)](https://bids.neuroimaging.io/index.html) is a comprehensive framework designed to systematically organize and share diverse types of data, including behavioral, physiological, and neuroimaging information. Converting datasets into BIDS format is a widely adopted methodology, particularly in the process of curating datasets that adhere to the principles of FAIR (Findable, Accessible, Interoperable, Reusable).\n", "\n", "**Key benefits of using BIDS:**\n", "- **Standardization**: Consistent naming conventions and directory structures across datasets\n", "- **Interoperability**: Enables automated analysis pipelines and data sharing\n", "- **Reproducibility**: Comprehensive metadata ensures experiments can be understood and replicated\n", "- **Community adoption**: Widely accepted format in neuroscience research\n", "\n", "The general framework of BIDS is described in the following publication:\n", "\n", "> Gorgolewski, K., Auer, T., Calhoun, V. et al. The brain imaging data structure, a format for organizing and describing outputs of neuroimaging experiments. Sci Data 3, 160044 (2016). https://doi.org/10.1038/sdata.2016.44\n", "\n", "## BIDS Extensions for Neon Data\n", "\n", "For datasets from Pupil Labs Neon eye-tracker, we utilize two BIDS extensions:\n", "\n", "1. **Motion-BIDS (BEP029)**: Organizes motion data including acceleration, angular velocity (gyroscope), and orientation from the IMU sensor\n", "2. **Eye-Tracking-BIDS (BEP020)**: Organizes gaze position, pupil size/diameter data, and eye-tracking events (fixations, saccades, blinks)\n", "\n", "In this tutorial, we demonstrate how to export Neon recordings to these BIDS formats using PyNeon's `export_motion_bids()` and `export_eye_bids()` methods. These functions handle all file naming, metadata generation, and formatting requirements automatically." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import json\n", "from pathlib import Path\n", "import pandas as pd\n", "from seedir import seedir\n", "from pyneon import Dataset, get_sample_data\n", "\n", "# Load sample data\n", "dataset = Dataset(get_sample_data(\"markers\", format=\"cloud\"))\n", "rec = dataset.recordings[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exporting to Motion-BIDS\n", "\n", "The Motion-BIDS specification provides a standardized way to organize motion sensor data from devices like IMUs (Inertial Measurement Units):\n", "\n", "> Jeung, S., Cockx, H., Appelhoff, S. et al. Motion-BIDS: an extension to the brain imaging data structure to organize motion data for reproducible research. Sci Data 11, 716 (2024). https://doi.org/10.1038/s41597-024-03559-8\n", "\n", "### Understanding the BIDS Prefix\n", "\n", "The `export_motion_bids()` method requires a **prefix** string that specifies the experimental context. The prefix follows this standardized format (fields in brackets are optional):\n", "\n", "```text\n", "sub-