catalystneuro / brunton-lab-to-nwb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

brunton-lab-to-nwb

Package for converting data in the Brunton Lab to NWB.

Installation

pip install git+https://github.com/catalystneuro/brunton-lab-to-nwb.git

Usage

from brunton_lab_to_nwb import run_conversion

run_conversion('in/path', 'out/path')

Example uses:

Load nwb file:

from pynwb import NWBHDF5IO
io = NWBHDF5IO(r'C:\Users\micha\Desktop\Brunton Lab Data\H5\subj_01_day_3.nwb', mode='r')
nwb = io.read()

See accessible fields in nwb file object:

nwb_file.fields

Get electrode series:

nwb_file.electrodes

Align events

# Get reach events
events = nwb_file.processing["behavior"].data_interfaces["ReachEvents"]
# Get reach position
reach_arm_pos = nwb_file.processing["behavior"].data_interfaces["Position"]["L_Wrist"]
# Set window around event alignment
before = 1.5 # in seconds
after = 1.5 # in seconds
starts = self.events - before
stops = self.events + after
# Get trials aligned by events
trials = align_by_times(reach_arm_pos, starts, stops)

About

License:MIT License


Languages

Language:Python 66.8%Language:Jupyter Notebook 31.9%Language:Shell 1.3%