neuropixels cloud sessions
Tools for accessing data and metadata for behavior and epyhys sessions from the Mindscope Neuropixels team - in the cloud.
Make a conda environment with python>=3.9 and simply pip install the npc_sessions package:
conda create -n npc_sessions python>=3.9
conda activate npc_sessions
pip install npc_sessions
>>> from npc_sessions import DynamicRoutingSession, get_sessions;
# each object is used to get metadata and paths for a session:
>>> session = DynamicRoutingSession('668755_2023-08-31')
>>> session.is_ephys
True
>>> session.stim_paths[0].stem
'DynamicRouting1_668755_20230831_131418'
# data is processed on-demand to generate individual pynwb modules:
>>> session.subject # doctest: +SKIP
subject pynwb.file.Subject at 0x1999418231888
Fields:
age: P205D
age__reference: birth
date_of_birth: 2023-02-06 20:23:02-08:00
genotype: wt/wt
sex: M
species: Mus musculus
strain: C57BL6J(NP)
subject_id: 668755
# a full NWBFile instance can also be generated with all currently-available data:
>>> session.nwb # doctest: +SKIP
root pynwb.file.NWBFile at 0x...
Fields:
acquisition: {
lick spout <class 'ndx_events.events.Events'>
}
devices: {
18005102491 <class 'pynwb.device.Device'>,
18005114452 <class 'pynwb.device.Device'>,
18005123131 <class 'pynwb.device.Device'>,
18194810652 <class 'pynwb.device.Device'>,
19192719021 <class 'pynwb.device.Device'>,
19192719061 <class 'pynwb.device.Device'>
}
...
# loop over all currently-tracked sessions using the session-generator:
>>> all(s.session_start_time.year >= 2022 for s in get_sessions()) # doctest: +SKIP
True
>>> trials_dfs = {}
>>> for session in get_sessions(): # doctest: +SKIP
... trials_dfs[session.id] = session.trials[:]
To install with the intention of contributing to this package:
1) create a conda environment:
conda create -n npc_sessions python>=3.9
conda activate npc_sessions
2) clone npc_sessions from github:
git clone git@github.com:AllenInstitute/npc_sessions.git
3) pip install all dependencies:
cd npc_sessions
pip install -e .
(the following all have a description
field, as well as other type-specific attributes)
DynamicTable
: for general tabular data
nwb.units
nwb.units[:]
, but requires
reading all data in all columns (slow)nwb.units[:].spike_times.iloc[0]
is a 1-D arraynwb.units[:].waveform_mean.iloc[0]
is a 2-D array (time x channels)*_index
is the one that should be used:
nwb.units.spike_times
is a 1-D array of all spike times for all units,
in chronological order (float)nwb.units.spike_times_index
is a list (len = num units) of
arrays (len = num spikes for each unit)/nwb/units/spike_times
is a 1-D array of all spike times for all units,
in chronological order (float)/nwb/units/spike_times_index
is a 1-D array of values corresponding to
the end of each unit's times in /nwb/units/spike_times
:spike_times[: spike_times_index[0]]
spike_times[spike_times_index[0]: spike_times_index[1]]
TimeIntervals
: for tabular data where each row is an interval of time
DynamicTable
which must have a start_time
and stop_time
column, plus any other user-defined columnsTimeSeries
: for general array data
data
(1-D or N-D, with time as first dimension)units
as a stringtimestamps
(same length as data
)starting_time
and rate
(assumed to be constant)ElectricalSeries
: for ephys array data
TimeSeries
with units fixed as voltsEvents
: an NWB extension for discrete event times
TimeSeries
class, but only has timestamps
, without values for data
(think: lick times)session metadata (multiple attributes)
subject (multiple attributes)
devices: DynamicTable
electrode_groups: DynamicTable
electrodes: DynamicTable
units: DynamicTable
electrodes
via peak_channel
epochs: TimeIntervals
TaskControl
subclass name)intervals: Mapping[str, TimeIntervals]
trials: TimeIntervals
intervals[DynamicRouting1]
invalid_times: TimeIntervals
acquisition: Mapping[str, Any]
raw data
Mapping[str, ElectricalSeries]
Mapping[str, ElectricalSeries]
Events
Events
Events
Events
per cameraprocessing: Mapping[str, Any]
processed/filtered data
Mapping[str, Any]
Events
TimeSeries
Mapping[str, Any]
analysis: Mapping[str, Any]
derived data, results
TimeSeries
per probeImageSeries
TimeIntervals
Todo: