Skip to content

An NWB Extension Catalog record for the extension ndx-whisk.

Notifications You must be signed in to change notification settings

nwb-extensions/ndx-whisk-record

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

ndx-whisk Extension for NWB

ndx-whisk is an NWB extension to store whisker tracking measurements. It is intended to convert .whiskers and .measurements files generated by whisk (Janelia Whisker Tracker), or saved to hdf5 with WhiskiWrap, but can be used with other whisker tracking methods.

Installation

pip install ndx-whisk

Usage

See test script test_whiskermeasurement.py in src/pynwb/tests.

from pynwb import NWBHDF5IO, NWBFile
from ndx_whisk import WhiskerMeasurementTable
import numpy as np

# Load your data
whisker_data = read_whisker_measurement_table('tracked_data.whiskers')

# Create a WhiskerMeasurementTable
whisker_meas = WhiskerMeasurementTable(
    name='name',
    description='description'
)

# Add data to the WhiskerMeasurementTable
for i in range(np.shape(whisker_data['frame_id'])[0]):
    whisker_meas.add_row({k: whisker_data[k][i] for k in whisker_data.keys()})
    
# Set up a NWB file
nwbfile = set_up_nwbfile()
path = 'tracked_data.nwb'

# Add a ProcessingModule for behavioral data
behavior_module = nwbfile.create_processing_module(
    name="behavior", description="Processed behavioral data"
)

# Add the WhiskerMeasurementTable
nwbfile.processing['behavior'].add(whisker_meas)

# Save to NWB file
with NWBHDF5IO(path, mode='w') as io:
    io.write(nwbfile)

This extension was created using ndx-template.

About

An NWB Extension Catalog record for the extension ndx-whisk.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published