NeurodataWithoutBorders / nwbwidgets

Explore the hierarchical structure of NWB 2.0 files and visualize data with Jupyter widgets.
https://nwb-widgets.readthedocs.io/en/latest/
Other
47 stars 22 forks source link

AIBS behavior_ophys: stimulus_templates are shaped (k, m, n) #3

Closed nicain closed 5 years ago

nicain commented 5 years ago

In the current Allen Institute behavior ophys files, there are 3-d numpy arrays for stimulus presentations:

/stimulus/templates/Natural_Images_Lum_Matched_set_training_2017.07.14/data

When browsed, it appears that the framework is expecting a 2-D (m, n) array.

Bug fix/enhancement is to provide a selector to choose the k-th image, and plot the slice (i.e. data[k,:,:]).

nwb.stimulus['Natural_Images_Lum_Matched_set_training_2017.07.14'].data[:]
nicain commented 5 years ago
conda create -n allensdk python=3.6 jupyter
conda activate allensdk
pip install --extra-index-url=https://aibs.jfrog.io/aibs/api/pypi/ni-pypi-local/simple allensdk==1.0.0.dev7
from nwbwidgets import nwb2widget
from pynwb import load_namespaces
import pynwb

from allensdk.brain_observatory.nwb.metadata import load_LabMetaData_extension
from allensdk.brain_observatory.behavior.schemas import OphysBehaviorMetaDataSchema, OphysBehaviorTaskParametersSchema

load_LabMetaData_extension(OphysBehaviorMetaDataSchema, 'AIBS_ophys_behavior')
load_LabMetaData_extension(OphysBehaviorTaskParametersSchema, 'AIBS_ophys_behavior')

path = '/Users/nicholasc/Documents/behavior_ophys_session_775614751.nwb'
io = pynwb.NWBHDF5IO(path, 'r')
nwb = io.read()