NWB conversion scripts for IBL-mesoscope data to the Neurodata Without Borders data format.
You can install the latest release of the package with pip:
pip install IBL-mesoscope-to-nwb
We recommend that you install the package inside a [virtual environment](https://docs.python.org/3/tutorial/venv.
html). A simple way of doing this is to use a [conda environment](https://docs.conda.
io/projects/conda/en/latest/user-guide/concepts/environments.html) from the conda package manager (installation
instructions). Detailed instructions on how to use conda
environments can be found in their documentation.
Once you have installed the package with pip, you can run any of the conversion scripts in a notebook or a python file:
Copy or download this file run the script with the following command:
python convert_session.py
Another option is to install the package directly from Github. This option has the advantage that the source code can be modified if you need to amend some of the code we originally provided to adapt to future experimental differences. To install the conversion from GitHub you will need to use git (installation instructions). We also recommend the installation of conda (installation instructions) as it contains all the required machinery in a single and simple install.
From a terminal (note that conda should install one in your system) you can do the following:
git clone https://github.com/catalystneuro/IBL-mesoscope-to-nwb
cd IBL-mesoscope-to-nwb
conda env create --file make_env.yml
conda activate ibl-mesoscope-to-nwb-envThis creates a conda environment which isolates the conversion code from your system libraries. We recommend that you run all your conversion related tasks and analysis from the created environment in order to minimize issues related to package dependencies.
If you fork this repository and are running code from that fork, instead use
git clone https://github.com/your_github_username/IBL-mesoscope-to-nwbThen you can run
cd IBL-mesoscope-to-nwb
conda env create --file make_env.yml
conda activate IBL-mesoscope-to-nwb_envAlternatively, if you want to avoid conda altogether (for example if you use another virtual environment tool) you can install the repository with the following commands using only pip:
git clone https://github.com/catalystneuro/IBL-mesoscope-to-nwb
cd IBL-mesoscope-to-nwb
pip install --editable .Note:
both of the methods above install the repository in editable mode.
The dependencies for this environment are stored in the dependencies section of the pyproject.toml file.
If the project has more than one conversion, you can install the requirements for a specific conversion with the following command:
pip install --editable .[mesoscope2025]
You can run a specific conversion with the following command:
python src/ibl_mesoscope_to_nwb/mesoscope2025/convert_session.py
This conversion project is comprised primarily by DataInterfaces, NWBConverters, and conversion scripts.
In neuroconv, a DataInterface is a class that specifies the procedure to convert a single data modality to NWB.
This is usually accomplished with a single read operation from a distinct set of files.
For example, in this conversion, the Mesoscope2025BehaviorInterface contains the code that converts all of the behavioral data to NWB from raw <FILE_TYPE> files.
In neuroconv, a NWBConverter is a class that combines many data interfaces and specifies the relationships between them, such as temporal alignment. This allows users to combine multiple modalities into a single NWB file in an efficient and modular way.
In this conversion project, the conversion scripts determine which sessions to convert, instantiate the appropriate NWBConverter object, and convert all of the specified sessions, saving them to an output directory of .nwb files.
Each conversion is organized in a directory of its own in the src directory:
IBL-mesoscope-to-nwb/
├── LICENSE
├── make_env.yml
├── pyproject.toml
├── README.md
└── src
├── ibl_mesoscope_to_nwb
│ └── mesoscope2025
│ ├── conversion_notes.md
│ ├── behaviorinterface.py
│ ├── convert_session.py
│ ├── metadata.yml
│ ├── nwbconverter.py
│ └── __init__.py
│ ├── conversion_directory_b
└── __init__.py
For example, for the conversion mesoscope2025 you can find a directory located in src/IBL-mesoscope-to-nwb/mesoscope2025.
Inside each conversion directory you can find the following files:
convert_sesion.py: this script defines the function to convert one full session of the conversion.metadata.yml: metadata in yaml format for this specific conversion.behaviorinterface.py: the behavior interface. Usually ad-hoc for each conversion.nwbconverter.py: the place where theNWBConverterclass is defined.conversion_notes.md: notes and comments concerning this specific conversion.
The directory might contain other files that are necessary for the conversion but those are the central ones.
This project implements a comprehensive pipeline for converting electrophysiology and behavioral data to NWB format:
Source Data → Data Interfaces → NWB Files
To create a new conversion:
- Create a new dataset directory following the naming convention
{experimenter}_{year} - Implement dataset-specific interfaces inheriting from existing interfaces as appropriate
- Create an NWBConverter class that combines all interfaces for your dataset
- Write conversion scripts for single sessions and batch processing
- Create metadata files with dataset-specific experimental parameters Each conversion should be self-contained within its directory and follow the established patterns for consistency and maintainability.