Skip to main content

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.

PyPI version

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

ndx-miniscope-0.4.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

ndx_miniscope-0.4.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

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

Hashes for ndx-miniscope-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3c14261cf5a536af95dd9d396d922cb94b34d473013bb9b07018e169bdbaf0d3
MD5 703edc84995cba67a01ca26bbd7b6d70
BLAKE2b-256 283f95ae59884c1980dc2d53c2d97a1424838d3b99af6e75b20e177d6b347b1e

See more details on using hashes here.

File details

Details for the file ndx_miniscope-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ndx_miniscope-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1448d73efa9def0dcf55809a7b74335388266b16662bf7060bebaaa4596e07e5
MD5 2a18cb5e69e08aa9dcfa8485865fdaef
BLAKE2b-256 a94c1b7f6f42e2b276c1e9fc8bca8891cf4f7c4219fab5bc306aec3127a5e876

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page