# install cell skipped during CI (deps preinstalled into system Python)
⚠️ Restart runtime after install
The install may upgrade packages already loaded in the kernel. Go to Runtime → Restart session, then Run all cells below (skip this install cell on re-run).
Reach-related Single Unit Activity in the Parkinsonian Macaque Tutorial¶
This tutorial demonstrates how to access an NWB file from the DANDI:000947 dandiset using pynwb and dandi.
This dataset contains recordings of single-unit activity from from multiple cortical areas, including globus pallidus-internus (GPi), ventrolateral nucleus of the thalamus (VLa and VLp) and the arm-related regions of primary motor cortex, including sulcus (M1-S) and gyrus (M1-G) subregions, in monkeys performing a choice reaction time reaching task. Small numbers of recordings were also obtained from supplementary motor area (SMA), external globus pallidus (GPe), the thalamic reticular nucleus (RTN), striatum (STR) and the region between RTN and VL thalamus (R-V). It contains data from two monkeys before and after the administration of MPTP (1-methyl-4-phenyl-1,2,3,6-tetrahydropyridine), which induces Parkinsonism. The neuronal activity was recorded using 16-contact linear probes (0.5–1.0 MΩ, V-probe, Plexon) or glass-insulated tungsten microelectrodes (0.5–1.5 MΩ, Alpha Omega). The neuronal data were amplified (4×, 2 Hz–7.5 kHz) and digitized at 24.414 kHz (approx., 16-bit resolution; Tucker Davis Technologies). The neuronal data were high-pass filtered (Fpass: 200 Hz, Matlab FIRPM) and thresholded, and candidate action potentials were sorted into clusters in principal components space (Off-line Sorter, Plexon).
Contents:
Streaming NWB files ¶
This section demonstrates how to access the files on the DANDI Archive without downloading them.
Based on the Streaming NWB files tutorial from PyNWB.
The dandi.dandiapi.DandiAPIClient can be used to get the S3 URL of the NWB file stored in the DANDI Archive.
from dandi.dandiapi import DandiAPIClient
client = DandiAPIClient.for_dandi_instance("dandi")
dandiset_id = "000947"
file_path = "sub-Isis/sub-Isis_ses-post-MPTP-I-190118-6_ecephys.nwb"
with DandiAPIClient() as client:
asset = client.get_dandiset(dandiset_id, 'draft').get_asset_by_path(file_path)
s3_url = asset.get_content_url(follow_redirects=1, strip_query=True)
We will use remfile for streaming the file. You can read more about remfile at this tutorial section.
import h5py
from pynwb import NWBHDF5IO
import remfile
# We stream the file using remfile and open it with h5py and pynwb
file = remfile.File(s3_url)
h5_file = h5py.File(file, "r")
io = NWBHDF5IO(file=h5_file, load_namespaces=True)
nwbfile = io.read()
nwbfile
root (NWBFile)
session_start_time
2019-01-20 14:51:30-08:00timestamps_reference_time
2019-01-20 14:51:30-08:00file_create_date
0
2024-04-25 17:04:56.027983+02:00experimenter
('Kase, Daisuke', 'Zimnik, Andrew')related_publications
('https://doi.org/10.1101/2023.09.08.556120',)acquisition
ElectricalSeries (ElectricalSeries)
data
| Data type | int16 |
|---|---|
| Shape | (33587200, 12) |
| Array size | 768.75 MiB |
| Chunk shape | (416666, 12) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 806092800 |
| Compressed size (bytes) | 413718193 |
| Compression ratio | 1.948410327703428 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
keywords
| Data type | object |
|---|---|
| Shape | (9,) |
| Array size | 72.00 bytes |
| Chunk shape | None |
| Compression | None |
| Compression opts | None |
| Uncompressed size (bytes) | 72 |
| Compressed size (bytes) | 144 |
| Compression ratio | 0.5 |
['extracellular electrophysiology' 'single-unit activity' 'globus pallidus-internus' 'ventrolateral anterior nucleus' 'primary motor cortex' 'reaching task' "Parkinson's disease" 'macaque' 'MPTP']
processing
ecephys (ProcessingModule)
Processed (FilteredEphys)
ElectricalSeriesProcessedGPe (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 2) |
| Array size | 256.26 MiB |
| Chunk shape | (1250000, 2) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 268706144 |
| Compressed size (bytes) | 249582258 |
| Compression ratio | 1.0766235795494725 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
ElectricalSeriesProcessedGPi (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 4) |
| Array size | 512.52 MiB |
| Chunk shape | (625000, 4) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 537412288 |
| Compressed size (bytes) | 500098920 |
| Compression ratio | 1.074611974766912 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
ElectricalSeriesProcessedVLa (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 6) |
| Array size | 768.77 MiB |
| Chunk shape | (416666, 6) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 806118432 |
| Compressed size (bytes) | 748594139 |
| Compression ratio | 1.0768430982866672 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
electrodes (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
electrode_groups
Group GPe (ElectrodeGroup)
device (Device)
Group GPi (ElectrodeGroup)
device (Device)
Group VLa (ElectrodeGroup)
device (Device)
devices
DeviceEcephys (Device)
intervals
trials (TimeIntervals)
columns
start_time
stop_time
error_onset_time
reward_start_time
reward_stop_time
movement_start_time
movement_stop_time
return_start_time
return_stop_time
cue_onset_time
target
table
| start_time | stop_time | error_onset_time | reward_start_time | reward_stop_time | movement_start_time | movement_stop_time | return_start_time | return_stop_time | cue_onset_time | target | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||
| 0 | 50.992620 | 60.075663 | NaN | 53.932647 | 54.212239 | 53.702328 | 53.919293 | 58.726072 | 60.075663 | 53.478851 | Left |
| 1 | 60.086641 | 70.747259 | NaN | 63.636644 | 63.962071 | 63.347057 | 63.622390 | 69.581988 | 70.747259 | 63.103672 | Right |
| 2 | 70.757294 | 87.668572 | NaN | 75.166679 | 75.442340 | 74.939474 | 75.144356 | 85.597430 | 87.668572 | 74.664960 | Left |
| 3 | 87.680328 | 102.365225 | NaN | 90.649436 | 90.927391 | 90.407362 | 90.637189 | 93.556941 | 102.365225 | 90.165125 | Left |
... and 82 more row(s).
subject (Subject)
date_of_birth
2005-06-14 00:00:00-07:00lab_meta_data
MPTPMetaData (TurnerLabMetaData)
trials (TimeIntervals)
columns
start_time
stop_time
error_onset_time
reward_start_time
reward_stop_time
movement_start_time
movement_stop_time
return_start_time
return_stop_time
cue_onset_time
target
table
| start_time | stop_time | error_onset_time | reward_start_time | reward_stop_time | movement_start_time | movement_stop_time | return_start_time | return_stop_time | cue_onset_time | target | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||
| 0 | 50.992620 | 60.075663 | NaN | 53.932647 | 54.212239 | 53.702328 | 53.919293 | 58.726072 | 60.075663 | 53.478851 | Left |
| 1 | 60.086641 | 70.747259 | NaN | 63.636644 | 63.962071 | 63.347057 | 63.622390 | 69.581988 | 70.747259 | 63.103672 | Right |
| 2 | 70.757294 | 87.668572 | NaN | 75.166679 | 75.442340 | 74.939474 | 75.144356 | 85.597430 | 87.668572 | 74.664960 | Left |
| 3 | 87.680328 | 102.365225 | NaN | 90.649436 | 90.927391 | 90.407362 | 90.637189 | 93.556941 | 102.365225 | 90.165125 | Left |
... and 82 more row(s).
units (Units)
columns
spike_times
unit_name
sort_label
location
channel_ids
unit_quality_post_sorting
table
| spike_times | unit_name | sort_label | location | channel_ids | unit_quality_post_sorting | |
|---|---|---|---|---|---|---|
| id | ||||||
| 0 | [0.03395584, 0.0520192, 0.12259328, 0.16719872, 0.19607552, 0.21151744, 0.36909056, 0.44445696, 0.46055424, 0.47939584, 0.48775168, 0.5031936, 0.78553088, 0.79757312, 0.83361792, 0.89706496, 0.98656256, 0.99344384, 1.07515904, 1.10252032, 1.11804416, 1.2115968, 1.22527744, 1.27184896, 1.28659456, 1.42753792, 1.5904768, 1.62676736, 1.72642304, 1.75443968, 1.93019904, 2.02985472, 2.2228992, 2.4510464, 2.7342848, 2.86711808, 2.89046528, 2.96071168, 3.12057856, 3.2503808, 3.53796096, 3.60906752, 3.65293568, 3.77167872, 3.796992, 3.81042688, 3.92081408, 3.95710464, 4.02116608, 4.13827072, 4.20352, 4.25009152, 4.27429888, 4.4945408, 4.5316096, 4.548608, 4.59091968, 4.7407104, 4.88955904, 4.99183616, 5.04446976, 5.06875904, 5.08706816, 5.10345216, 5.1546112, 5.26483456, 5.35212032, 5.43256576, 5.57236224, 5.61278976, 5.7071616, 5.71592704, 5.87923456, 6.14813696, 6.27634176, 6.660096, 6.77240832, 6.82733568, 6.88144384, 6.94411264, 7.04090112, 7.06527232, 7.28875008, 7.48212224, 7.64379136, 7.70658304, 7.79976704, 8.17238016, 8.18610176, 8.19703808, 8.23238656, 8.26540032, 8.29820928, 8.76212224, 8.91154432, 8.99690496, 9.0750976, 9.71460608, 9.75147008, 10.30488064, ...] | 0 | 1.0 | VLa | 1 | excellent |
| 1 | [1.32456448, 5.83467008, 5.99814144, 6.02116096, 15.63148288, 16.39100416, 16.41283584, 16.46559232, 16.49328128, 16.57708544, 16.768, 16.98430976, 19.10030336, 20.29195264, 21.95042304, 26.56559104, 27.19920128, 27.4956288, 29.77763328, 29.86262528, 32.86622208, 32.93057024, 32.9586688, 33.02817792, 33.05426944, 33.17383168, 33.27492096, 33.30183168, 33.37101312, 34.98360832, 42.9602816, 43.01000704, 43.22230272, 43.92722432, 43.96404736, 43.99071232, 44.86832128, 46.98796032, 47.09302272, 49.16609024, 49.24596224, 51.69487872, 52.31542272, 53.00736, 53.09816832, 56.83044352, 57.51701504, 58.42190336, 61.02679552, 61.08434432, 61.18670336, 61.28615424, 61.32785152, 61.40145664, 61.4969344, 61.86897408, 62.05079552, 62.17977856, 62.50524672, 62.53776896, 64.51310592, 64.6074368, 65.12910336, 69.98552576, 70.00055808, 70.0700672, 70.10062336, 70.17680896, 70.281216, 70.38824448, 70.49183232, 70.66529792, 76.27505664, 76.34714624, 76.41739264, 76.490752, 76.51639296, 76.55026688, 76.62862336, 76.6826496, 76.7985664, 77.99177216, 85.37202688, 85.4822912, 88.73467904, 94.46719488, 95.07278848, 95.0933504, 95.12046592, 95.1631872, 95.8234624, 95.8558208, 95.9168512, 95.98943232, 96.02183168, 96.05414912, 96.0796672, 96.2822144, 97.45874944, 98.34668032, ...] | 1 | 1.0 | VLa | 5 | excellent |
| 2 | [0.00217088, 0.10825728, 0.1626112, 0.23588864, 0.25718784, 0.32731136, 0.33878016, 0.42225664, 0.57561088, 0.61906944, 0.72536064, 0.86720512, 0.88600576, 0.9095168, 0.93646848, 1.05345024, 1.09727744, 1.12254976, 1.17059584, 1.22994688, 1.32608, 1.34754304, 1.37744384, 1.47009536, 1.51760896, 1.5826944, 1.61251328, 1.63893248, 1.70614784, 2.08207872, 2.10497536, 2.16113152, 2.17481216, 2.19734016, 2.24182272, 2.25800192, 2.31329792, 2.32706048, 2.3422976, 2.3783424, 2.38911488, 2.397184, 2.40406528, 2.41119232, 2.47902208, 2.5061376, 2.51895808, 2.63970816, 2.71835136, 2.74251776, 2.77295104, 2.81071616, 2.81649152, 2.86662656, 2.88694272, 2.9437952, 2.96648704, 3.01375488, 3.08146176, 3.10525952, 3.12705024, 3.18631936, 3.216384, 3.25402624, 3.2772096, 3.3314816, 3.38571264, 3.41327872, 3.44182784, 3.45526272, 3.4955264, 3.5719168, 3.59763968, 3.66096384, 3.80076032, 3.88112384, 3.93793536, 4.0071168, 4.04529152, 4.06368256, 4.12409856, 4.135936, 4.18787328, 4.20192256, 4.21773312, 4.32320512, 4.34454528, 4.39853056, 4.41348096, 4.42355712, 4.43695104, 4.47696896, 4.49220608, 4.5666304, 4.72363008, 4.77032448, 4.78629888, 4.83520512, 7.6396544, 7.65456384, ...] | 2 | 2.0 | VLa | 5 | excellent |
| 3 | [0.8450048, 1.18214656, 4.81329152, 6.4045056, 6.88902144, 14.77070848, 15.03469568, 16.40460288, 16.6404096, 17.9027968, 20.76770304, 20.86875136, 21.528576, 24.46430208, 26.62887424, 27.620352, 27.94758144, 28.82420736, 32.07344128, 35.23567616, 38.63687168, 42.9334528, 48.71999488, 57.26445568, 57.69117696, 60.53122048, 65.47550208, 69.2355072, 69.32226048, 86.80718336, 86.87230976, 89.06375168, 91.63358208, 111.40050944, 113.17383168, 129.0668032, 129.25403136, 133.05331712, 133.111808, 134.119424, 138.52418048, 149.84736768, 150.75373056, 156.43283456, 163.57081088, 172.46830592, 175.8111744, 176.93904896, 178.23481856, 181.43096832, 189.31818496, 196.29600768, 199.11081984, 199.5220992, 202.27018752, 203.3983488, 203.95024384, 205.3746688, 205.81228544, 213.09988864, 213.27429632, 214.46377472, 215.56494336, 221.08823552, 233.19158784, 239.9827968, 241.12099328, 241.81825536, 244.18983936, 249.94287616, 250.08717824, 250.3870464, 251.6434944, 253.19796736, 254.05513728, 266.18310656, 267.80983296, 269.43811584, 270.2864384, 276.42318848, 286.30728704, 286.37728768, 300.37479424, 300.5018112, 303.80158976, 311.92567808, 320.44531712, 320.61005824, 322.33193472, 327.83781888, 328.9356288, 338.1700608, 338.87801344, 340.72670208, 344.551424, 345.44173056, 346.63038976, 347.0450688, 348.81175552, 359.39926016, ...] | 3 | 1.0 | VLa | 7 | good |
... and 13 more row(s).
nwbfile.subject
subject (Subject)
date_of_birth
2005-06-14 00:00:00-07:00The MPTP status is stored in a TurnerLabMetaData container which extends pynwb.file.LabMetaData, and can be accessed as nwbfile.lab_meta_data["MPTPMetaData"].
nwbfile.lab_meta_data["MPTPMetaData"]
MPTPMetaData (TurnerLabMetaData)
Access trials ¶
Behavior trials are stored in nwbfile.trials. The start_time denotes the start time of each trial in seconds relative to the global session start time.
The stop_time denotes the end time of each trial in seconds relative to the global session start time.
nwbfile.trials can be converted to a pandas DataFrame for convenient analysis using nwbfile.trials.to_dataframe().
trials = nwbfile.trials.to_dataframe()
trials.head(10)
| start_time | stop_time | error_onset_time | reward_start_time | reward_stop_time | movement_start_time | movement_stop_time | return_start_time | return_stop_time | cue_onset_time | target | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||
| 0 | 50.992620 | 60.075663 | NaN | 53.932647 | 54.212239 | 53.702328 | 53.919293 | 58.726072 | 60.075663 | 53.478851 | Left |
| 1 | 60.086641 | 70.747259 | NaN | 63.636644 | 63.962071 | 63.347057 | 63.622390 | 69.581988 | 70.747259 | 63.103672 | Right |
| 2 | 70.757294 | 87.668572 | NaN | 75.166679 | 75.442340 | 74.939474 | 75.144356 | 85.597430 | 87.668572 | 74.664960 | Left |
| 3 | 87.680328 | 102.365225 | NaN | 90.649436 | 90.927391 | 90.407362 | 90.637189 | 93.556941 | 102.365225 | 90.165125 | Left |
| 4 | 102.381896 | 118.222643 | NaN | 105.212150 | 105.524838 | 104.894423 | 105.200640 | 115.487580 | 118.222643 | 104.665498 | Right |
| 5 | 118.241034 | 133.235917 | NaN | 121.586442 | 121.857434 | 121.264620 | 121.573253 | 126.400512 | 133.235917 | 121.009603 | Right |
| 6 | 133.241979 | 148.448256 | NaN | 136.416051 | 136.696095 | 136.139940 | 136.393155 | 146.674319 | 148.448256 | 135.913800 | Left |
| 7 | 148.459520 | 165.340938 | NaN | 152.901140 | 153.242665 | 152.581325 | 152.887132 | 162.919014 | 165.340938 | 152.366694 | Right |
| 8 | 165.350031 | 180.914258 | NaN | 169.070920 | 169.386926 | 168.770929 | 169.049989 | 173.979689 | 180.914258 | 168.523612 | Left |
| 9 | 180.927775 | 197.386732 | NaN | 184.650588 | 184.983347 | 184.306893 | 184.624456 | 194.873057 | 197.386732 | 184.101397 | Right |
Access Recording ¶
This section demonstrates how to access the raw ElectricalSeries data.
NWB organizes data into different groups depending on the type of data. Groups can be thought of as folders within the file. Here are some of the groups within an NWBFile and the types of data they are intended to store:
acquisition: raw, acquired data that should never changeprocessing: processed data, typically the results of preprocessing algorithms and could change
Raw ElectricalSeries¶
The raw ElectricalSeries data is stored in an pynwb.ecephys.ElectricalSeries object which is added to nwbfile.acquisition. The data can be accessed as nwbfile.acquisition["ElectricalSeries"].
The data in ElectricalSeries is stored as a two dimensional array: the first dimension is time, the second dimension represents electrodes/channels.
electrical_series = nwbfile.acquisition["ElectricalSeries"]
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
# Prepare data for plotting
data = electrical_series.data[:1000, :10]
timestamps = electrical_series.get_timestamps()[:1000]
df = pd.DataFrame(data)
df["Time (s)"] = timestamps
df.set_index("Time (s)", inplace=True)
df.columns.name = "electrodes"
channel_name_mapper = dict(zip(df.columns, electrical_series.electrodes["channel_name"][:]))
df.rename(channel_name_mapper, axis=1, inplace=True)
fig, axes = plt.subplots(nrows=len(df.columns), sharex=True, sharey=True, dpi=200)
lines = df.plot(subplots=True, ax=axes, legend=False, linewidth=0.8)
# Hide y-axis labels
for ax in axes:
ax.yaxis.set_visible(False)
# Remove box around the plots
for ax in axes:
ax.set_frame_on(False)
# Get handles and labels for all lines
handles, labels = [], []
for line in lines:
h, l = line.get_legend_handles_labels()
handles.extend(h)
labels.extend(l)
# Create a single legend box
fig.legend(handles, labels, loc='upper right', bbox_to_anchor=(1.2, 0.8), frameon=False)
plt.xlabel('Time (s)')
plt.tight_layout()
plt.show()
The electrodes table describe the electrodes that generated this data. Extracellular electrodes are stored in an "electrodes" table, which is a DynamicTable and can be can be converted to a pandas DataFrame for convenient analysis using nwbfile.electrodes.to_dataframe().
nwbfile.electrodes.to_dataframe().head()
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x14... | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x14... | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x14... | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x14... | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
| 4 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x14... | Group VLa | Conx 12 | 1.0 | 0.0 | 12 | vp16 | Sagittal | 4.0 | 2.0 | 41.90 | -3.954138 | -5.019382 | 4.834319 |
Filtered ElectricalSeries¶
The processed ecephys data is stored in "processing/ecephys" which can be accessed as nwbfile.processing["ecephys"].
Within this processing module we can access the container of filtered traces as nwbfile.processing["ecephys"]["Processed"] which can hold multiple processed ElectricalSeries objects.
nwbfile.processing["ecephys"]
ecephys (ProcessingModule)
Processed (FilteredEphys)
ElectricalSeriesProcessedGPe (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 2) |
| Array size | 256.26 MiB |
| Chunk shape | (1250000, 2) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 268706144 |
| Compressed size (bytes) | 249582258 |
| Compression ratio | 1.0766235795494725 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
ElectricalSeriesProcessedGPi (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 4) |
| Array size | 512.52 MiB |
| Chunk shape | (625000, 4) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 537412288 |
| Compressed size (bytes) | 500098920 |
| Compression ratio | 1.074611974766912 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
ElectricalSeriesProcessedVLa (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 6) |
| Array size | 768.77 MiB |
| Chunk shape | (416666, 6) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 806118432 |
| Compressed size (bytes) | 748594139 |
| Compression ratio | 1.0768430982866672 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
processed_ecephys = nwbfile.processing["ecephys"]["Processed"]
filtered_electrical_series = processed_ecephys["ElectricalSeriesProcessedGPi"]
filtered_electrical_series
ElectricalSeriesProcessedGPi (ElectricalSeries)
data
| Data type | float32 |
|---|---|
| Shape | (33588268, 4) |
| Array size | 512.52 MiB |
| Chunk shape | (625000, 4) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 537412288 |
| Compressed size (bytes) | 500098920 |
| Compression ratio | 1.074611974766912 |
electrodes (DynamicTableRegion)
table (ElectrodesTable)
columns
location
group
group_name
channel_name
gain_to_uV
offset_to_uV
channel_ids
electrode_type
chamber_type
chamber_x
chamber_y
chamber_z
acx_x
acx_y
acx_z
table
| location | group | group_name | channel_name | gain_to_uV | offset_to_uV | channel_ids | electrode_type | chamber_type | chamber_x | chamber_y | chamber_z | acx_x | acx_y | acx_z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| id | |||||||||||||||
| 0 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 1 | 1.0 | 0.0 | 1 | vp16 | Sagittal | 4.0 | 2.0 | 42.50 | -3.920903 | -5.335591 | 4.325490 |
| 1 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 5 | 1.0 | 0.0 | 5 | vp16 | Sagittal | 4.0 | 2.0 | 43.10 | -3.887668 | -5.651801 | 3.816661 |
| 2 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 7 | 1.0 | 0.0 | 7 | vp16 | Sagittal | 4.0 | 2.0 | 43.40 | -3.871051 | -5.809906 | 3.562247 |
| 3 | VLa | Group VLa pynwb.ecephys.ElectrodeGroup at 0x140185594470288\nFields:\n description: Group vp16 electrodes.\n device: DeviceEcephys pynwb.device.Device at 0x140185593143248\nFields:\n description: TDT recording\n manufacturer: Tucker-Davis Technologies (TDT)\n\n location: VLa\n | Group VLa | Conx 11 | 1.0 | 0.0 | 11 | vp16 | Sagittal | 4.0 | 2.0 | 42.05 | -3.945830 | -5.098434 | 4.707112 |
... and 8 more row(s).
Access Units ¶
Spike times are stored in the Units table, which is a DynamicTable and can be can be converted to a pandas DataFrame for convenient analysis using nwbfile.units.to_dataframe().
nwbfile.units[:]
| spike_times | unit_name | sort_label | location | channel_ids | unit_quality_post_sorting | |
|---|---|---|---|---|---|---|
| id | ||||||
| 0 | [0.03395584, 0.0520192, 0.12259328, 0.16719872... | 0 | 1.0 | VLa | 1 | excellent |
| 1 | [1.32456448, 5.83467008, 5.99814144, 6.0211609... | 1 | 1.0 | VLa | 5 | excellent |
| 2 | [0.00217088, 0.10825728, 0.1626112, 0.23588864... | 2 | 2.0 | VLa | 5 | excellent |
| 3 | [0.8450048, 1.18214656, 4.81329152, 6.4045056,... | 3 | 1.0 | VLa | 7 | good |
| 4 | [0.09691136, 0.1282048, 0.15757312, 0.25923584... | 4 | 1.0 | VLa | 11 | good |
| 5 | [0.04907008, 0.116736, 0.15835136, 0.18751488,... | 5 | 1.0 | VLa | 12 | excellent |
| 6 | [0.01056768, 0.08716288, 0.09531392, 0.1458585... | 6 | 1.0 | VLa | 15 | excellent |
| 7 | [2.70639104, 9.90437376, 10.7485184, 25.959055... | 7 | 1.0 | GPi | 20 | F |
| 8 | [0.02125824, 0.09744384, 0.17870848, 0.2081587... | 8 | 1.0 | GPi | 22 | excellent |
| 9 | [0.01036288, 0.055296, 0.09613312, 0.1349632, ... | 9 | 2.0 | GPi | 22 | good |
| 10 | [0.10190848, 0.13770752, 0.1859584, 0.26558464... | 10 | 3.0 | GPi | 22 | good |
| 11 | [0.063488, 0.0784384, 0.72880128, 1.0031104, 1... | 11 | 4.0 | GPi | 22 | good |
| 12 | [0.1062912, 0.19480576, 0.33542144, 0.34828288... | 12 | 1.0 | GPi | 23 | excellent |
| 13 | [0.00405504, 0.00933888, 0.0514048, 0.06397952... | 13 | 2.0 | GPi | 23 | good |
| 14 | [0.00131072, 0.00364544, 0.0063488, 0.00970752... | 14 | 1.0 | GPi | 26 | excellent |
| 15 | [0.34803712, 1.18255616, 1.44543744, 1.4502707... | 15 | 1.0 | GPe | 28 | excellent |
| 16 | [0.03166208, 0.05963776, 0.0618496, 0.07155712... | 16 | 1.0 | GPe | 31 | excellent |
from matplotlib import pyplot as plt
import pynapple as nap
movement_onset_ts = nap.Ts(nwbfile.trials["movement_start_time"][:], time_units="s")
spike_times_group = nap.TsGroup({unit_ind: nap.Ts(spikes) for unit_ind, spikes in enumerate(nwbfile.units["spike_times"])})
perievent_histogram = nap.compute_perievent(
data=spike_times_group,
tref=movement_onset_ts,
minmax=(-0.5, 1),
time_unit="s",
)
fig, ax = plt.subplots(nrows=2, ncols=1, figsize=(8, 6), dpi=200, sharex=True, sharey=True)
ax[0].plot(
perievent_histogram[0].to_tsd(),
"|",
color="black",
markersize=2,
)
ax[0].set_title(nwbfile.units[0]["location"].values[0])
ax[0].axvline(0.0)
ax[1].plot(
perievent_histogram[11].to_tsd(),
"|",
color="black",
markersize=2,
)
ax[1].set_title(nwbfile.units[11]["location"].values[0])
ax[1].axvline(0.0)
plt.xlabel("Time from Movement onset (s)")
plt.ylabel("Trials")
plt.xlim(-0.5, 1)
plt.show()
We can also use Neurosift for this visualization:

