In [1]:
# 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).
Optogenetics Example Session¶
In [2]:
from stream_nwbfile import stream_nwbfile
import numpy as np
import matplotlib.pyplot as plt
This notebook showcases one example session from the 000971 dataset containing operant behavior and concurrent excitatory optogenetic stimulation.
In [3]:
DANDISET_ID = '000971'
file_path = 'sub-119-416/sub-119-416_ses-Opto-DMS-Excitatory-ChR2-2020-10-20T13-00-57_ogen.nwb'
nwbfile, io = stream_nwbfile(DANDISET_ID, file_path)
display(nwbfile)
/opt/hostedtoolcache/Python/3.13.15/x64/lib/python3.13/site-packages/hdmf/spec/namespace.py:484: UserWarning: Schema conflict(s) detected in namespace 'ndx-fiber-photometry': ndx-fiber-photometry defines OpticalFiber.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. ndx-fiber-photometry defines ExcitationSource.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. ndx-fiber-photometry defines Photodetector.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. ndx-fiber-photometry defines DichroicMirror.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. ndx-fiber-photometry defines BandOpticalFilter.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. ndx-fiber-photometry defines EdgeOpticalFilter.model as an attribute (dtype: text) while the core schema defines it as a link to DeviceModel. This may cause compatibility issues. Please update the extension version if possible or install an older version of the core schema that is compatible. self._check_namespace_conflicts(extension_ns_name=ns_name,
root (NWBFile)
session_description: FR1 Training with optogenetic stimulation, rewards delivered on both left and right nose pokes, optogenetic stimulation delivered on all rewarded nose pokes
identifier: 9e37d1f2-7a6e-4a82-88db-a4b2edec6a49
session_start_time
2020-10-20 13:00:57-05:51timestamps_reference_time
2020-10-20 13:00:57-05:51file_create_date
0
2024-07-17 10:24:13.924271-07:00experimenter
('Seiler, Jillian L.', 'Cosme, Caitlin V.', 'Sherathiya, Venus N.', 'Schaid, Michael D.', 'Bianco, Joseph M.', 'Bridgemohan, Abigael S.', 'Lerner, Talia N.')related_publications
('https://doi.org/10.1016/j.cub.2022.01.055',)stimulus
OptogeneticSeries (OptogeneticSeries)
resolution: -1.0
comments: no comments
description: During operant training (beginning with FR1), each rewarded nosepoke was paired with a train of blue light (460nm, 1 s, 20 Hz, 15 mW) generated by an LED light source and pulse generator (Prizmatix). A subset of mice ("ChR2 Scrambled") received the same train of light but paired with random nosepokes on a separate RI60 schedule.
conversion: 1.0
offset: 0.0
unit: watts
data
HDF5 dataset
| Data type | float64 |
|---|---|
| Shape | (241,) |
| Array size | 1.88 KiB |
| Chunk shape | (241,) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 1928 |
| Compressed size (bytes) | 37 |
| Compression ratio | 52.108108108108105 |
timestamps
HDF5 dataset
| Data type | float64 |
|---|---|
| Shape | (241,) |
| Array size | 1.88 KiB |
| Chunk shape | (241,) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 1928 |
| Compressed size (bytes) | 623 |
| Compression ratio | 3.0947030497592296 |
timestamps_unit: seconds
interval: 1
site (OptogeneticStimulusSite)
device (Device)
description: Optogenetic stimulus pulses were generated from the Optogenetics-LED-Dual (Prizmatix) driven by the Optogenetics PulserPlus (Prizmatix). Engineered for scaling Optogenetics experiments, the Optogenetics-LED-Dual light source features two independent fiber-coupled LED channels each equipped with independent power and switching control. Optogenetics Pulser / PulserPlus are programmable TTL pulse train generators for pulsing LEDs, lasers and shutters used in Optogenetics activation in neurophysiology and behavioral research.
manufacturer: Prizmatix
description: Mice for DMS excitatory optogenetics experiments received 1 ml of AAV5-EF1a-DIO-hChR2(H134R)-EYFP (3.3e13 GC/mL, Addgene, lot v17652) or the control fluorophore-only virus AAV5-EF1a-DIO-EYFP (3.5e12 virus molecules/mL, UNC Vector Core, lot AV4310K) in medial (AP -3.1, ML 0.8, DV -4.7) and a single fiber optic implant (Prizmatix; 250mm core, 0.66 NA) over ipsilateral DMS (AP 0.8, ML 1.5, DV -2.8). Hemispheres were counterbalanced between mice.
excitation_lambda: 460.0
location: Injection location: medial SNc (AP -3.1, ML 0.8, DV -4.7)
Stimulation location: DMS (AP 0.8, ML 1.5, DV -2.8)
keywords
HDF5 dataset
['dorsal striatum' 'dopamine' 'substantia nigra' 'reward learning' 'habit formation' 'compulsive behavior' 'punishment-resistant reward seeking' 'fiber photometry' 'optogenetics']
| 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 |
['dorsal striatum' 'dopamine' 'substantia nigra' 'reward learning' 'habit formation' 'compulsive behavior' 'punishment-resistant reward seeking' 'fiber photometry' 'optogenetics']
processing
behavior (ProcessingModule)
description: Operant behavioral data from MedPC.
MSN = FR1_BOTH_WStim
Box = 3
reward_port_entry_times (Events)
description: Reward port entry times
timestamps
HDF5 dataset
| Data type | float64 |
|---|---|
| Shape | (210,) |
| Array size | 1.64 KiB |
| Chunk shape | (210,) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 1680 |
| Compressed size (bytes) | 669 |
| Compression ratio | 2.5112107623318387 |
timestamps__unit: seconds
right_nose_poke_times (Events)
description: Right nose poke times
timestamps
HDF5 dataset
| Data type | float64 |
|---|---|
| Shape | (14,) |
| Array size | 112.00 bytes |
| Chunk shape | (14,) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 112 |
| Compressed size (bytes) | 77 |
| Compression ratio | 1.4545454545454546 |
timestamps__unit: seconds
right_reward_times (Events)
description: Right reward times
timestamps
HDF5 dataset
[2242.9 2799.55 3143.2 3389.95 3442.1 3514.85]
| Data type | float64 |
|---|---|
| Shape | (6,) |
| Array size | 48.00 bytes |
| Chunk shape | (6,) |
| Compression | gzip |
| Compression opts | 4 |
| Uncompressed size (bytes) | 48 |
| Compressed size (bytes) | 43 |
| Compression ratio | 1.1162790697674418 |
[2242.9 2799.55 3143.2 3389.95 3442.1 3514.85]
timestamps__unit: seconds
devices
Optogenetics_LED_Dual (Device)
description: Optogenetic stimulus pulses were generated from the Optogenetics-LED-Dual (Prizmatix) driven by the Optogenetics PulserPlus (Prizmatix). Engineered for scaling Optogenetics experiments, the Optogenetics-LED-Dual light source features two independent fiber-coupled LED channels each equipped with independent power and switching control. Optogenetics Pulser / PulserPlus are programmable TTL pulse train generators for pulsing LEDs, lasers and shutters used in Optogenetics activation in neurophysiology and behavioral research.
manufacturer: Prizmatix
ogen_sites
OptogeneticStimulusSite (OptogeneticStimulusSite)
device (Device)
description: Optogenetic stimulus pulses were generated from the Optogenetics-LED-Dual (Prizmatix) driven by the Optogenetics PulserPlus (Prizmatix). Engineered for scaling Optogenetics experiments, the Optogenetics-LED-Dual light source features two independent fiber-coupled LED channels each equipped with independent power and switching control. Optogenetics Pulser / PulserPlus are programmable TTL pulse train generators for pulsing LEDs, lasers and shutters used in Optogenetics activation in neurophysiology and behavioral research.
manufacturer: Prizmatix
description: Mice for DMS excitatory optogenetics experiments received 1 ml of AAV5-EF1a-DIO-hChR2(H134R)-EYFP (3.3e13 GC/mL, Addgene, lot v17652) or the control fluorophore-only virus AAV5-EF1a-DIO-EYFP (3.5e12 virus molecules/mL, UNC Vector Core, lot AV4310K) in medial (AP -3.1, ML 0.8, DV -4.7) and a single fiber optic implant (Prizmatix; 250mm core, 0.66 NA) over ipsilateral DMS (AP 0.8, ML 1.5, DV -2.8). Hemispheres were counterbalanced between mice.
excitation_lambda: 460.0
location: Injection location: medial SNc (AP -3.1, ML 0.8, DV -4.7)
Stimulation location: DMS (AP 0.8, ML 1.5, DV -2.8)
subject (Subject)
age: P10W/
age__reference: birth
description: Male and female WT (C57BL/6J) and (DAT)::IRES-Cre knockin mice (JAX006660) were obtained from The Jackson Laboratory and crossed in house. Only heterozygote transgenic mice, obtained by backcrossing to C57BL/6J wildtypes, were used for experiments. Littermates of the same sex were randomly assigned to experimental groups (fiber photometry-14 males, 22 females; DMS excitatory optogenetics- 20 males, 19 females; DMS inhibitory optogenetics- 13 males, 13 females; DLS excitatory optogenetics- 18 males, 18 females). Adult mice at least 10 weeks of age were used in all experiments. Mice were group housed under a conventional 12 h light cycle (dark from 7:00pm to 7:00am) with ad libitum access to food and water prior to operant training. All experiments were approved by the Northwestern University Institutional Animal Care and Use Committee.
genotype: DAT-IRES-Cre: B6.SJLSlc6a3tm1.1(cre)Bkmn/J
sex: F
species: Mus musculus
subject_id: 119.416
strain: C57BL/6J
experiment_description: Compulsive behavior is a defining feature of disorders such as substance use disorders. Current evidence suggests that corticostriatal circuits control the expression of established compulsions, but little is known about the mechanisms regulating the development of compulsions. We hypothesized that dopamine, a critical modulator of striatal synaptic plasticity, could control alterations in corticostriatal circuits leading to the development of compulsions (defined here as continued reward seeking in the face of punishment). We used dual-site fiber photometry to measure dopamine axon activity in the dorsomedial striatum (DMS) and the dorsolateral striatum (DLS) as compulsions emerged. Individual variability in the speed with which compulsions emerged was predicted by DMS dopamine axon activity. Amplifying this dopamine signal accelerated animals' transitions to compulsion, whereas inhibition delayed it. In contrast, amplifying DLS dopamine signaling had no effect on the emergence of compulsions. These results establish DMS dopamine signaling as a key controller of the development of compulsive reward seeking.
session_id: Opto-DMS-Excitatory-ChR2-2020-10-20T13-00-57
lab: Lerner
institution: Northwestern Unitersity
notes: Hemisphere with DMS: Right
Experiment: DMS Excitatory
Behavior: RI60
Punishment Group: nan
Did Not Learn: False
source_script: Created using NeuroConv v0.4.11
source_script_file_name: /opt/anaconda3/envs/lerner_lab_to_nwb_env/lib/python3.12/site-packages/neuroconv/basedatainterface.py
surgery: ChR2 in DMS projecting SNc, probe in DMS
stimulus_notes: Excitatory stimulation on rewarded nosepokes
Retrieve Optogenetic and Behavioral Data
In [4]:
# Optogenetic Stimulation
optogenetic_stimulation_timestamps = nwbfile.stimulus['OptogeneticSeries'].timestamps[:]
optogenetic_stimulation_data = nwbfile.stimulus['OptogeneticSeries'].data[:]
opto_onset_times = optogenetic_stimulation_timestamps[optogenetic_stimulation_data == 0.015]
opto_offset_times = optogenetic_stimulation_timestamps[optogenetic_stimulation_data == 0]
# Behavior
right_nose_poke_times = nwbfile.processing['behavior'].data_interfaces['right_nose_poke_times'].timestamps[:]
right_reward_times = nwbfile.processing['behavior'].data_interfaces['right_reward_times'].timestamps[:]
reward_port_entry_times = nwbfile.processing['behavior'].data_interfaces['reward_port_entry_times'].timestamps[:]
Plot
In [5]:
t_start = 1
t_end = 3600
right_nose_poke_mask = np.logical_and(right_nose_poke_times >= t_start, right_nose_poke_times < t_end)
right_reward_mask = np.logical_and(right_reward_times >= t_start, right_reward_times < t_end)
reward_port_entry_mask = np.logical_and(reward_port_entry_times >= t_start, reward_port_entry_times < t_end)
opto_onset_mask = np.logical_and(opto_onset_times >= t_start, opto_onset_times < t_end)
opto_offset_mask = np.logical_and(opto_offset_times >= t_start, opto_offset_times < t_end)
lineoffsets = 1
linelengths = 1
alpha = 0.3
ylim = [-2, 2]
y = np.arange(-1, 0, 0.1)
fix, ax = plt.subplots(figsize=(10, 5))
ax.eventplot(right_nose_poke_times[right_nose_poke_mask], lineoffsets=lineoffsets, linelengths=linelengths, color='r', label='Right Nose Poke')
ax.eventplot(right_reward_times[right_reward_mask], lineoffsets=lineoffsets, linelengths=linelengths, color='g', label='Right Reward')
for i, (onset_time, offset_time) in enumerate(zip(opto_onset_times[opto_onset_mask], opto_offset_times[opto_offset_mask])):
x1 = onset_time*np.ones(len(y))
x2 = offset_time*np.ones(len(y))
if i == 0:
ax.fill_betweenx(y, x1, x2, color='b', alpha=alpha, label='Optogenetic Stimulation')
else:
ax.fill_betweenx(y, x1, x2, color='b', alpha=alpha)
ax.set_ylim(ylim)
ax.set_title('DMS Excitatory ChR2')
ax.yaxis.set_visible(False)
ax.set_xlabel('Time (s)')
_ = ax.legend(bbox_to_anchor=(1.01, 1), loc='upper left')
In [6]:
t_start = 2200
t_end = 2250
right_nose_poke_mask = np.logical_and(right_nose_poke_times >= t_start, right_nose_poke_times < t_end)
right_reward_mask = np.logical_and(right_reward_times >= t_start, right_reward_times < t_end)
reward_port_entry_mask = np.logical_and(reward_port_entry_times >= t_start, reward_port_entry_times < t_end)
opto_onset_mask = np.logical_and(opto_onset_times >= t_start, opto_onset_times < t_end)
opto_offset_mask = np.logical_and(opto_offset_times >= t_start, opto_offset_times < t_end)
lineoffsets = 1
linelengths = 1
alpha = 0.3
ylim = [-2, 2]
y = np.arange(-1, 0, 0.1)
fix, ax = plt.subplots(figsize=(10, 5))
ax.eventplot(right_nose_poke_times[right_nose_poke_mask], lineoffsets=lineoffsets, linelengths=linelengths, color='r', label='Right Nose Poke')
ax.eventplot(right_reward_times[right_reward_mask], lineoffsets=lineoffsets, linelengths=linelengths, color='g', label='Right Reward')
for i, (onset_time, offset_time) in enumerate(zip(opto_onset_times[opto_onset_mask], opto_offset_times[opto_offset_mask])):
x1 = onset_time*np.ones(len(y))
x2 = offset_time*np.ones(len(y))
if i == 0:
ax.fill_betweenx(y, x1, x2, color='b', alpha=alpha, label='Optogenetic Stimulation')
else:
ax.fill_betweenx(y, x1, x2, color='b', alpha=alpha)
ax.set_ylim(ylim)
ax.set_title('DMS Excitatory ChR2')
ax.yaxis.set_visible(False)
ax.set_xlabel('Time (s)')
_ = ax.legend(bbox_to_anchor=(1.01, 1), loc='upper left')
In [ ]: