Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mayofaulkner committed Dec 18, 2024
2 parents 23f9ecb + 549265e commit 526385b
Show file tree
Hide file tree
Showing 17 changed files with 585 additions and 429 deletions.
226 changes: 173 additions & 53 deletions brainbox/behavior/training.py

Large diffs are not rendered by default.

33 changes: 20 additions & 13 deletions brainbox/tests/test_behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,58 +177,65 @@ def test_in_training(self):
trials, task_protocol = self._get_trials(
sess_dates=['2020-08-25', '2020-08-24', '2020-08-21'])
assert (np.all(np.array(task_protocol) == 'training'))
status, info = train.get_training_status(
status, info, crit = train.get_training_status(
trials, task_protocol, ephys_sess_dates=[], n_delay=0)
assert (status == 'in training')
assert (crit['Criteria']['val'] == 'trained_1a')

def test_trained_1a(self):
trials, task_protocol = self._get_trials(
sess_dates=['2020-08-26', '2020-08-25', '2020-08-24'])
assert (np.all(np.array(task_protocol) == 'training'))
status, info = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
status, info, crit = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
assert (status == 'trained 1a')
assert (crit['Criteria']['val'] == 'trained_1b')

def test_trained_1b(self):
trials, task_protocol = self._get_trials(
sess_dates=['2020-08-27', '2020-08-26', '2020-08-25'])
assert (np.all(np.array(task_protocol) == 'training'))
status, info = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
status, info, crit = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
self.assertEqual(status, 'trained 1b')
assert (crit['Criteria']['val'] == 'ready4ephysrig')

def test_training_to_bias(self):
trials, task_protocol = self._get_trials(
sess_dates=['2020-08-31', '2020-08-28', '2020-08-27'])
assert (~np.all(np.array(task_protocol) == 'training') and
np.any(np.array(task_protocol) == 'training'))
status, info = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
status, info, crit = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
assert (status == 'trained 1b')
assert (crit['Criteria']['val'] == 'ready4ephysrig')

def test_ready4ephys(self):
sess_dates = ['2020-09-01', '2020-08-31', '2020-08-28']
trials, task_protocol = self._get_trials(sess_dates=sess_dates)
assert (np.all(np.array(task_protocol) == 'biased'))
status, info = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
status, info, crit = train.get_training_status(trials, task_protocol, ephys_sess_dates=[],
n_delay=0)
assert (status == 'ready4ephysrig')
assert (crit['Criteria']['val'] == 'ready4delay')

def test_ready4delay(self):
sess_dates = ['2020-09-03', '2020-09-02', '2020-08-31']
trials, task_protocol = self._get_trials(sess_dates=sess_dates)
assert (np.all(np.array(task_protocol) == 'biased'))
status, info = train.get_training_status(trials, task_protocol,
ephys_sess_dates=['2020-09-03'], n_delay=0)
status, info, crit = train.get_training_status(trials, task_protocol,
ephys_sess_dates=['2020-09-03'], n_delay=0)
assert (status == 'ready4delay')
assert (crit['Criteria']['val'] == 'ready4recording')

def test_ready4recording(self):
sess_dates = ['2020-09-01', '2020-08-31', '2020-08-28']
trials, task_protocol = self._get_trials(sess_dates=sess_dates)
assert (np.all(np.array(task_protocol) == 'biased'))
status, info = train.get_training_status(trials, task_protocol,
ephys_sess_dates=sess_dates, n_delay=1)
status, info, crit = train.get_training_status(trials, task_protocol,
ephys_sess_dates=sess_dates, n_delay=1)
assert (status == 'ready4recording')
assert (crit['Criteria']['val'] == 'ready4recording')

def test_query_criterion(self):
"""Test for brainbox.behavior.training.query_criterion function."""
Expand Down
34 changes: 29 additions & 5 deletions examples/exploring_data/data_download.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
"source": [
"## Installation\n",
"### Environment\n",
"To use IBL data you will need a python environment with python > 3.8. To create a new environment from scratch you can install [anaconda](https://www.anaconda.com/products/distribution#download-section) and follow the instructions below to create a new python environment (more information can also be found [here](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html))\n",
"To use IBL data you will need a python environment with python > 3.10, although Python 3.12 is recommended. To create a new environment from scratch you can install [anaconda](https://www.anaconda.com/products/distribution#download-section) and follow the instructions below to create a new python environment (more information can also be found [here](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html))\n",
"\n",
"```\n",
"conda create --name ibl python=3.11\n",
"conda create --name ibl python=3.12\n",
"```\n",
"Make sure to always activate this environment before installing or working with the IBL data\n",
"```\n",
Expand Down Expand Up @@ -138,9 +138,33 @@
"outputs": [],
"source": [
"# Each session is represented by a unique experiment id (eID)\n",
"print(sessions[0])"
"print(sessions[0],)"
]
},
{
"metadata": {},
"cell_type": "markdown",
"source": [
"### Find recordings of a specific brain region\n",
"If we are interested in a given brain region, we can use the `search_insertions` method to find all recordings associated with that region. For example, to find all recordings associated with the **Rhomboid Nucleus (RH)** region of the thalamus."
]
},
{
"metadata": {},
"cell_type": "code",
"source": [
"# this is the query that yields the few recordings for the Rhomboid Nucleus (RH) region\n",
"insertions_rh = one.search_insertions(atlas_acronym='RH', datasets='spikes.times.npy', project='brainwide')\n",
"\n",
"# if we want to extend the search to all thalamic regions, we can do the following\n",
"insertions_th = one.search_insertions(atlas_acronym='TH', datasets='spikes.times.npy', project='brainwide')\n",
"\n",
"# the Allen brain regions parcellation is hierarchical, and searching for Thalamus will return all child Rhomboid Nucleus (RH) regions\n",
"assert set(insertions_rh).issubset(set(insertions_th))\n"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -402,9 +426,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
184 changes: 0 additions & 184 deletions examples/loading_data/loading_spike_waveforms.ipynb

This file was deleted.

10 changes: 6 additions & 4 deletions examples/loading_data/loading_spikesorting_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"## Relevant Alf objects\n",
"* channels\n",
"* clusters\n",
"* spikes"
"* spikes\n",
"* waveforms"
]
},
{
Expand Down Expand Up @@ -74,9 +75,10 @@
"outputs": [],
"source": [
"pid = 'da8dfec1-d265-44e8-84ce-6ae9c109b8bd' \n",
"sl = SpikeSortingLoader(pid=pid, one=one)\n",
"spikes, clusters, channels = sl.load_spike_sorting()\n",
"clusters = sl.merge_clusters(spikes, clusters, channels)"
"ssl = SpikeSortingLoader(pid=pid, one=one)\n",
"spikes, clusters, channels = ssl.load_spike_sorting()\n",
"clusters = ssl.merge_clusters(spikes, clusters, channels)\n",
"waveforms = ssl.load_spike_sorting_object('waveforms') # loads in the template waveforms"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion ibllib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import warnings

__version__ = '3.1.0'
__version__ = '3.2.0'
warnings.filterwarnings('always', category=DeprecationWarning, module='ibllib')

# if this becomes a full-blown library we should let the logging configuration to the discretion of the dev
Expand Down
Loading

0 comments on commit 526385b

Please sign in to comment.