Skip to content

Commit

Permalink
Merge branch 'release/2.26'
Browse files Browse the repository at this point in the history
  • Loading branch information
mayofaulkner committed Sep 25, 2023
2 parents bf068a4 + de4e084 commit e30380c
Show file tree
Hide file tree
Showing 68 changed files with 456 additions and 7,128 deletions.
6 changes: 0 additions & 6 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
include ibllib/atlas/allen_structure_tree.csv
include ibllib/atlas/franklin_paxinos_structure_tree.csv
include ibllib/atlas/beryl.npy
include ibllib/atlas/cosmos.npy
include ibllib/atlas/swanson.npy
include ibllib/atlas/mappings.pqt
include ibllib/io/extractors/extractor_types.json
include ibllib/io/extractors/task_extractor_map.json
include brainbox/tests/wheel_test.p
Expand Down
2 changes: 1 addition & 1 deletion brainbox/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from ibllib import atlas
from iblatlas import atlas


def _label2values(imlabel, fill_values, ba):
Expand Down
2 changes: 1 addition & 1 deletion brainbox/ephys_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
plot_image, plot_probe, plot_scatter, arrange_channels2banks)
from brainbox.processing import compute_cluster_average
from iblutil.numerical import bincount2D
from ibllib.atlas.regions import BrainRegions
from iblatlas.regions import BrainRegions


def image_lfp_spectrum_plot(lfp_power, lfp_freq, chn_coords=None, chn_inds=None, freq_range=(0, 300),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from one.api import ONE

from ibllib.atlas import atlas
from iblatlas import atlas
from brainbox.io.one import load_channels_from_insertion

pid = "8413c5c6-b42b-4ec6-b751-881a54413628"
Expand Down
2 changes: 1 addition & 1 deletion brainbox/examples/docs_load_spike_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""

from one.api import ONE
from ibllib.atlas import AllenAtlas
from iblatlas.atlas import AllenAtlas
from brainbox.io.one import SpikeSortingLoader


Expand Down
2 changes: 1 addition & 1 deletion brainbox/examples/plot_atlas_color_values.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import matplotlib.pyplot as plt
from ibllib import atlas
from iblatlas import atlas
from brainbox.atlas import plot_atlas


Expand Down
30 changes: 20 additions & 10 deletions brainbox/io/one.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

from iblutil.util import Bunch
from ibllib.io.extractors.training_wheel import extract_wheel_moves, extract_first_movement_times
from ibllib.atlas import atlas, AllenAtlas, BrainRegions
from iblatlas.atlas import AllenAtlas, BrainRegions
from iblatlas import atlas
from ibllib.pipes import histology
from ibllib.pipes.ephys_alignment import EphysAlignment
from ibllib.plots import vertical_lines
Expand Down Expand Up @@ -243,7 +244,7 @@ def channel_locations_interpolation(channels_aligned, channels=None, brain_regio
'x', 'y', 'z', 'acronym', 'axial_um'
those are the guide for the interpolation
:param channels: Bunch or dictionary of aligned channels containing at least keys 'localCoordinates'
:param brain_regions: None (default) or ibllib.atlas.BrainRegions object
:param brain_regions: None (default) or iblatlas.regions.BrainRegions object
if None will return a dict with keys 'localCoordinates', 'mlapdv', 'brainLocationIds_ccf_2017
if a brain region object is provided, outputts a dict with keys
'x', 'y', 'z', 'acronym', 'atlas_id', 'axial_um', 'lateral_um'
Expand Down Expand Up @@ -372,7 +373,7 @@ def load_channel_locations(eid, probe=None, one=None, aligned=False, brain_atlas
An instance of ONE (shouldn't be in 'local' mode)
aligned : bool
Whether to get the latest user aligned channel when not resolved or use histology track
brain_atlas : ibllib.atlas.BrainAtlas
brain_atlas : iblatlas.BrainAtlas
Brain atlas object (default: Allen atlas)
Returns
-------
Expand Down Expand Up @@ -417,7 +418,7 @@ def load_spike_sorting_fast(eid, one=None, probe=None, dataset_types=None, spike
:param dataset_types: additional spikes/clusters objects to add to the standard default list
:param spike_sorter: name of the spike sorting you want to load (None for default)
:param collection: name of the spike sorting collection to load - exclusive with spike sorter name ex: "alf/probe00"
:param brain_regions: ibllib.atlas.regions.BrainRegions object - will label acronyms if provided
:param brain_regions: iblatlas.regions.BrainRegions object - will label acronyms if provided
:param nested: if a single probe is required, do not output a dictionary with the probe name as key
:param return_collection: (False) if True, will return the collection used to load
:return: spikes, clusters, channels (dict of bunch, 1 bunch per probe)
Expand Down Expand Up @@ -458,7 +459,7 @@ def load_spike_sorting(eid, one=None, probe=None, dataset_types=None, spike_sort
:param probe: name of probe to load in, if not given all probes for session will be loaded
:param dataset_types: additional spikes/clusters objects to add to the standard default list
:param spike_sorter: name of the spike sorting you want to load (None for default)
:param brain_regions: ibllib.atlas.regions.BrainRegions object - will label acronyms if provided
:param brain_regions: iblatlas.regions.BrainRegions object - will label acronyms if provided
:param return_collection:(bool - False) if True, returns the collection for loading the data
:return: spikes, clusters (dict of bunch, 1 bunch per probe)
"""
Expand Down Expand Up @@ -497,7 +498,7 @@ def load_spike_sorting_with_channel(eid, one=None, probe=None, aligned=False, da
spike_sorter : str
Name of the spike sorting you want to load (None for default which is pykilosort if it's
available otherwise the default MATLAB kilosort)
brain_atlas : ibllib.atlas.BrainAtlas
brain_atlas : iblatlas.atlas.BrainAtlas
Brain atlas object (default: Allen atlas)
return_collection: bool
Returns an extra argument with the collection chosen
Expand Down Expand Up @@ -1053,10 +1054,16 @@ def samples2times(self, values, direction='forward'):
def pid2ref(self):
return f"{self.one.eid2ref(self.eid, as_dict=False)}_{self.pname}"

def raster(self, spikes, channels, save_dir=None, br=None, label='raster', time_series=None):
def raster(self, spikes, channels, save_dir=None, br=None, label='raster', time_series=None, **kwargs):
"""
:param spikes: spikes dictionary
:param save_dir: optional if specified
:param spikes: spikes dictionary or Bunch
:param channels: channels dictionary or Bunch.
:param save_dir: if specified save to this directory as "{pid}_{probe}_{label}.png".
Otherwise, plot.
:param br: brain regions object (optional)
:param label: label for saved image (optional, default="raster")
:param time_series: timeseries dictionary for behavioral event times (optional)
:param **kwargs: kwargs passed to `driftmap()` (optional)
:return:
"""
br = br or BrainRegions()
Expand All @@ -1065,7 +1072,10 @@ def raster(self, spikes, channels, save_dir=None, br=None, label='raster', time_
'width_ratios': [.95, .05], 'height_ratios': [.1, .9]}, figsize=(16, 9), sharex='col')
axs[0, 1].set_axis_off()
# axs[0, 0].set_xticks([])
brainbox.plot.driftmap(spikes['times'], spikes['depths'], t_bin=0.007, d_bin=10, vmax=0.5, ax=axs[1, 0])
if kwargs is None:
# set default raster plot parameters
kwargs = {"t_bin": 0.007, "d_bin": 10, "vmax": 0.5}
brainbox.plot.driftmap(spikes['times'], spikes['depths'], ax=axs[1, 0], **kwargs)
title_str = f"{self.pid2ref}, {self.pid} \n" \
f"{spikes['clusters'].size:_} spikes, {np.unique(spikes['clusters']).size:_} clusters"
axs[0, 0].title.set_text(title_str)
Expand Down
Loading

0 comments on commit e30380c

Please sign in to comment.