Loading Passive Data
Passive stimuli related events. The passive protocol is split into three sections 1. Spontaneous activity (SP) 2. Receptive Field Mapping (RFM) 3. Task replay (TR)
Relevant datasets
passivePeriods.intervalsTable.csv (SP)
passiveRFM.times.npy (RFM)
_iblrig_RFMapStim.raw.bin (RFM)
passiveGabor.table.csv (TR - visual)
passiveStims.table.csv (TR - auditory)
Loading
Loading spontaneous activity
[2]:
from one.api import ONE
one = ONE()
eid = '4ecb5d24-f5cc-402c-be28-9d0f7cb14b3a'
passive_times = one.load_dataset(eid, '*passivePeriods*', collection='alf')
SP_times = passive_times['spontaneousActivity']
Loading recpetive field mapping
[3]:
from brainbox.io.one import load_passive_rfmap
RFMap = load_passive_rfmap(eid, one=one)
/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/one/alf/files.py:10: FutureWarning: `one.alf.files` will be removed in version 3.0. Use `one.alf.path` instead.
warnings.warn(
Loading task replay
[4]:
# Load visual stimulus task replay events
visual_TR = one.load_dataset(eid, '*passiveGabor*', collection='alf')
# Load auditory stimulus task replay events
auditory_TR = one.load_dataset(eid, '*passiveStims*', collection='alf')
More details
Useful modules
Exploring passive data
Example 1: Compute firing rate for each cluster during spontaneous activity
[5]:
# Find first probe insertion for session
pid = one.alyx.rest('insertions', 'list', session=eid)[0]['id']
from brainbox.io.one import SpikeSortingLoader
from iblatlas.atlas import AllenAtlas
import numpy as np
ba = AllenAtlas()
# Load in spikesorting
sl = SpikeSortingLoader(pid=pid, one=one, atlas=ba)
spikes, clusters, channels = sl.load_spike_sorting()
clusters = sl.merge_clusters(spikes, clusters, channels)
# Find spike times during spontaneous activity
SP_idx = np.bitwise_and(spikes['times'] >= SP_times[0], spikes['times'] <= SP_times[1])
# Count the number of clusters during SP time period and compute firing rate
from brainbox.population.decode import get_spike_counts_in_bins
counts, cluster_ids = get_spike_counts_in_bins(spikes['times'][SP_idx], spikes['clusters'][SP_idx],
np.c_[SP_times[0], SP_times[1]])
fr = counts / (SP_times[1] - SP_times[0])
Downloading: /home/runner/Downloads/ONE/openalyx.internationalbrainlab.org/histology/ATLAS/Needles/Allen/average_template_25.nrrd Bytes: 32998960
100%|██████████| 31.470260620117188/31.470260620117188 [00:03<00:00, 9.73it/s]
Downloading: /home/runner/Downloads/ONE/openalyx.internationalbrainlab.org/histology/ATLAS/Needles/Allen/annotation_25.nrrd Bytes: 4035363
100%|██████████| 3.848422050476074/3.848422050476074 [00:01<00:00, 2.81it/s]
/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/one/util.py:543: ALFWarning: Multiple revisions: "", "2024-05-06"
warnings.warn(f'Multiple revisions: {rev_list}', alferr.ALFWarning)
/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/one/util.py:543: ALFWarning: Multiple revisions: "", "2024-05-06"
warnings.warn(f'Multiple revisions: {rev_list}', alferr.ALFWarning)
Example 2: Find RFM stimulus positions and timepoints
[6]:
# Find out at what times each voxel on the screen was turned 'on' (grey to white) or turned 'off' (grey to black)
from brainbox.task.passive import get_on_off_times_and_positions
RF_frame_times, RF_frame_pos, RF_frame_stim = get_on_off_times_and_positions(RFMap)
# Find times where pixel at location x=1, y=4 on display was turned 'on'
pixel_idx = np.bitwise_and(RF_frame_pos[:, 0] == 1, RF_frame_pos[:, 1] == 4)
stim_on_frames = RF_frame_stim['on'][pixel_idx]
stim_on_times = RF_frame_times[stim_on_frames[0][0]]
Other relevant examples
COMING SOON