Beispiel #1
0
# import alf.io as aio
# import brainbox as bb
from oneibl.one import ONE
import brainbox.io.one as bbone

one = ONE()

# --- Example session:
eid = 'aad23144-0e52-4eac-80c5-c4ee2decb198'  # Example: repeated site

# Test with eid that does not have any probe planned/histology values in Alyx
# eid = 'da188f2c-553c-4e04-879b-c9ea2d1b9a93'

# ----- RECOMMENDED: Option 1 (default) ------
# 1. Get spikes, cluster (with brain regions assigned to clusters) and channels
spikes, clusters, channels = bbone.load_spike_sorting_with_channel(eid,
                                                                   one=one)
del spikes, clusters, channels  # Delete for the purpose of the example

# ---------------------------------------------
# 2. Get only spikes and clusters (without brain regions assigned to clusters)
#    data separately from channels
#    Use merger function to get channels information into clusters
#    Adding feature x, y from default
spikes, clusters = bbone.load_spike_sorting(eid, one=one)
channels = bbone.load_channel_locations(eid, one=one)
keys = ['x', 'y']
clusters_brain = bbone.merge_clusters_channels(clusters,
                                               channels,
                                               keys_to_add_extra=keys)
del spikes, clusters, clusters_brain, channels  # Delete for the purpose of the example
Beispiel #2
0
Downloads and loads in spikes, clusters and channels data for a given session. Data is returned

"""

from oneibl.one import ONE
import brainbox.io.one as bbone
one = ONE()

# Find eid of interest
eid = one.search(subject='CSH_ZAD_001', date='2020-01-14')[0]

##################################################################################################
# Example 1:
# Download spikes, clusters and channels data for all available probes for this session.
# The data for each probe is returned as a dict
spikes, clusters, channels = bbone.load_spike_sorting_with_channel(eid,
                                                                   one=one)
print(spikes.keys())
print(spikes['probe00'].keys())

##################################################################################################
# Example 2:
# Download spikes, clusters and channels data for a single probe
spikes, clusters, channels = bbone.load_spike_sorting_with_channel(
    eid, one=one, probe='probe00')
print(spikes.keys())

##################################################################################################
# Example 3:
# The default spikes and clusters datasets that are downloaded are '
# ['clusters.channels',
#  'clusters.depths',
Beispiel #3
0
from oneibl.one import ONE
one = ONE()

EID = '15f742e1-1043-45c9-9504-f1e8a53c1744'
REGION = 'SNr'
PROBE = 'probe01'
PRE_TIME = 0.6
POST_TIME = -0.1
DECODER = 'bayes-multinomial'
ITERATIONS = 1000
DATA_PATH, FIG_PATH, SAVE_PATH = paths()
FIG_PATH = join(FIG_PATH, 'Decoding', 'Sessions', DECODER)

# %%
# Load in data
spikes, clusters, channels = bbone.load_spike_sorting_with_channel(EID, aligned=True, one=one)
ses_path = one.path_from_eid(EID)
trials = alf.io.load_object(join(ses_path, 'alf'), 'trials')

# Get trial vectors
incl_trials = (trials.probabilityLeft == 0.8) | (trials.probabilityLeft == 0.2)
trial_times = trials.stimOn_times[incl_trials]
probability_left = trials.probabilityLeft[incl_trials]
trial_blocks = (trials.probabilityLeft[incl_trials] == 0.2).astype(int)

# Get clusters in this brain region
region_clusters = combine_layers_cortex(clusters[PROBE]['acronym'])
clusters_in_region = clusters[PROBE].metrics.cluster_id[region_clusters == REGION]

# Select spikes and clusters
spks_region = spikes[PROBE].times[np.isin(spikes[PROBE].clusters, clusters_in_region)]
import ibllib.atlas as atlas
from oneibl.one import ONE
import brainbox.io.one as bbone
import brainbox.plot as bbplot

# === Parameters section (edit) ===
ba = atlas.AllenAtlas(25)
one = ONE(base_url="https://alyx.internationalbrainlab.org")

eid = 'aad23144-0e52-4eac-80c5-c4ee2decb198'

prob_des = one.load(eid, dataset_types=['probes.description'])
n_probe = len(prob_des[0])

# Get information for the session
spikes, clusters, channels = bbone.load_spike_sorting_with_channel(
    eid, one=one, dataset_types=['spikes.depths'])

# Loop over probes
for i_probe in range(0, n_probe):
    # Get single probe trajectory
    probe_label = prob_des[0][i_probe].get('label')

    trajs = one.alyx.rest('trajectories',
                          'list',
                          session=eid,
                          provenance='Histology track',
                          probe=probe_label)

    if len(trajs) == 0:
        print(f"No histology recorded for probe {probe_label}")
        continue