Represent metadata for Miniscope acquisition system.
Project description
ndx-miniscope Extension for NWB
This is a Neurodata Extension (NDX) for Neurodata Without Borders (NWB) 2.0 for Miniscope acquisition data.
The Miniscope acquisition software generally outputs the following files:
- msCam[##].avi
- behavCam[##].avi
- timestamp.dat
- settings_and_notes.dat
This repo provides an extension to the Device
core NWB neurodata_type called Miniscope
which contains fields for the data in settings_and_notes.dat
. The following code demonstrates how to use this extension to properly convert Miniscope acquisition data into NWB by creating external links, which does not require the video data to be copied into the NWB file.
python
Installation
Get most recent release:
pip install ndx-miniscope
Install latest:
git clone https://github.com/catalystneuro/ndx-miniscope.git
cd ndx-miniscope
pip install -e .
Usage
import os
from ndx_miniscope import read_settings, read_notes, read_miniscope_timestamps, get_starting_frames
from pynwb import NWBFile, NWBHDF5IO
from datetime import datetime
from dateutil.tz import tzlocal
from pynwb.image import ImageSeries
from natsort import natsorted
from glob import glob
data_dir = 'path/to/data_dir'
session_start_time = datetime(2017, 4, 15, 12, tzinfo=tzlocal())
nwb = NWBFile('session_description', 'identifier', session_start_time)
miniscope = read_settings(data_dir)
nwb.add_device(miniscope)
annotations = read_notes(data_dir)
if annotations is not None:
nwb.add_acquisition(annotations)
ms_files = natsorted(glob(os.path.join(data_dir, 'msCam*.avi')))
behav_files = natsorted(glob(os.path.join(data_dir, 'behavCam*.avi')))
nwb.add_acquisition(
ImageSeries(
name='OnePhotonSeries',
format='external',
external_file=[os.path.split(x)[1] for x in ms_files],
timestamps=read_miniscope_timestamps(data_dir),
starting_frame=get_starting_frames(ms_files),
)
)
nwb.add_acquisition(
ImageSeries(
name='behaviorCam',
format='external',
external_file=[os.path.split(x)[1] for x in behav_files],
timestamps=read_miniscope_timestamps(data_dir, cam_num=2),
starting_frame=get_starting_frames(behav_files),
)
)
save_path = os.path.join(data_dir, 'test_out.nwb')
with NWBHDF5IO(save_path, 'w') as io:
io.write(nwb)
# test read
with NWBHDF5IO(save_path, 'r') as io:
nwb = io.read()
MATLAB:
Installation
git clone https://github.com/bendichter/ndx-miniscope.git
generateExtension('path/to/ndx-miniscope/spec');
Usage
under construction...
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ndx-miniscope-0.4.0.tar.gz
.
File metadata
- Download URL: ndx-miniscope-0.4.0.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c14261cf5a536af95dd9d396d922cb94b34d473013bb9b07018e169bdbaf0d3 |
|
MD5 | 703edc84995cba67a01ca26bbd7b6d70 |
|
BLAKE2b-256 | 283f95ae59884c1980dc2d53c2d97a1424838d3b99af6e75b20e177d6b347b1e |
File details
Details for the file ndx_miniscope-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: ndx_miniscope-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1448d73efa9def0dcf55809a7b74335388266b16662bf7060bebaaa4596e07e5 |
|
MD5 | 2a18cb5e69e08aa9dcfa8485865fdaef |
|
BLAKE2b-256 | a94c1b7f6f42e2b276c1e9fc8bca8891cf4f7c4219fab5bc306aec3127a5e876 |