npc_sessions
neuropixels cloud sessions
Tools for accessing data and metadata for behavior and epyhys sessions from the Mindscope Neuropixels team - in the cloud.
quickstart
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 develop with conda
To install with the intention of contributing to this package:
- create a conda environment:
conda create -n npc_sessions python>=3.9
conda activate npc_sessions
- clone npc_sessions from github:
git clone git@github.com:AllenInstitute/npc_sessions.git
- pip install all dependencies:
cd npc_sessions
pip install -e .
Hierarchy of required packages
Current NWB components
key data types
(the following all have a description field, as well as other type-specific attributes)
-
DynamicTable: for general tabular data- e.g.
nwb.units - each column in the table is stored as a vector, which can be accessed individually (fast)
- can be accessed as a pandas dataframe with
nwb.units[:], but requires reading all data in all columns (slow) - as well as individual values, cells in the table can contain multidimensional
arrays. These are represented differently depending on location:
- in the pandas dataframe, these are represented as one would expect:
nwb.units[:].spike_times.iloc[0]is a 1-D arraynwb.units[:].waveform_mean.iloc[0]is a 2-D array (time x channels)
- in the non-dataframe memory representation, there are sometimes two
components, where the
*_indexis the one that should be used:nwb.units.spike_timesis a 1-D array of all spike times for all units, in chronological order (float)nwb.units.spike_times_indexis a list (len = num units) of arrays (len = num spikes for each unit)
- on disk, these columns separated columns are different again, for example:
/nwb/units/spike_timesis a 1-D array of all spike times for all units, in chronological order (float)/nwb/units/spike_times_indexis a 1-D array of values corresponding to the end of each unit's times in/nwb/units/spike_times:- the first unit's spike times are in
spike_times[: spike_times_index[0]] - the second unit's are in
spike_times[spike_times_index[0]: spike_times_index[1]]
- the first unit's spike times are in
- in the pandas dataframe, these are represented as one would expect:
- e.g.
-
TimeIntervals: for tabular data where each row is an interval of time- a subclass of
DynamicTablewhich must have astart_timeandstop_timecolumn, plus any other user-defined columns
- a subclass of
-
TimeSeries: for general array data- has an array of
data(1-D or N-D, with time as first dimension) - has
unitsas a string - has either:
timestamps(same length asdata)starting_timeandrate(assumed to be constant)
- has an array of
-
ElectricalSeries: for ephys array data- a subclass of
TimeSerieswith units fixed as volts
- a subclass of
-
Events: an NWB extension for discrete event times- like the
TimeSeriesclass, but only hastimestamps, without values fordata(think: lick times)
- like the
-
session metadata (multiple attributes)
-
subject (multiple attributes)
-
devices:
DynamicTable- physical probes (model, serial number)
- currently only neuropixels probes
-
electrode_groups:
DynamicTable- represents the group of channels on one probe inserted in the brain
- has session-specific info, like position relative to other probes or stereotactic coords
-
electrodes:
DynamicTable- individual channels on a probe
- has CCF coords
-
units:
DynamicTable- metrics, links to
electrodesviapeak_channel
- metrics, links to
-
epochs:
TimeIntervals- start/stop time of each stim block
- has a list of tags (includes
TaskControlsubclass name)
-
intervals:
Mapping[str, TimeIntervals]- 1x table per stim epoch with trials
- behavior performance table (each block an interval)
-
trials:
TimeIntervals- same as
intervals[DynamicRouting1]
- same as
-
invalid_times:
TimeIntervals -
acquisition:
Mapping[str, Any]raw data- if is_ephys:
- raw AP:
Mapping[str, ElectricalSeries] - raw LFP:
Mapping[str, ElectricalSeries]
- raw AP:
- if is_sync:
- lick_sensor_rising_edges:
Events - lick_sensor_falling_edges:
Events
- lick_sensor_rising_edges:
- if is_task:
- rewards:
Events
- rewards:
- if is_video:
- video frame times: 1x
Eventsper camera
- video frame times: 1x
- if is_ephys:
-
processing:
Mapping[str, Any]processed/filtered data- behavior:
Mapping[str, Any]- licks:
Events- from sync or stim file
- running_speed:
TimeSeries- from stim file, enhanced with sync info if available
- licks:
- ecephys:
Mapping[str, Any]
- behavior:
-
analysis:
Mapping[str, Any]derived data, results- if is_ephys:
- all_spike_histograms: 1x
TimeSeriesper probe - drift_maps:
ImageSeries
- all_spike_histograms: 1x
- if is_task:
- performance:
TimeIntervals
- performance:
- if is_ephys:
Todo:
- filtered LFP
- stimulus templates (vis, aud, opto)
- OptogeneticStimulusSite
- analysis -> RFMaps
- per-unit response metric for each stim modality
Metadata
Release files for npc_sessions 0.0.300
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| npc_sessions-0.0.300.tar.gz | 139.1 kB | Without provenance | Details for npc_sessions-0.0.300.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| npc_sessions-0.0.300-py3-none-any.whl | Python 3 | none | any | Details for npc_sessions-0.0.300-py3-none-any.whl |
Total release size: 270.3 kB
Release files / npc_sessions-0.0.300.tar.gz
| Download URL | npc_sessions-0.0.300.tar.gz |
|---|---|
| Size | 139.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0d7bfaa0b652dbbdf8c6baceffb05f187023aa38b17be0988f658cd4e404a37
|
|
BLAKE2b-256 checksum How to use checksums |
97f3c3d5d24f471611c06be789850e284e788a830569a9fc364f409d5409262f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / npc_sessions-0.0.300-py3-none-any.whl
| Download URL | npc_sessions-0.0.300-py3-none-any.whl |
|---|---|
| Size | 131.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7e3af3f66985be5b92c6343fabb136a9fd47512bd960820e32c16e4efd853f38
|
|
BLAKE2b-256 checksum How to use checksums |
ed31bc632c7ab340b5467f878e0e9cc2343a269bd320ab1d4d87b7f60ac9c31b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for npc_sessions 0.0.300
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.