Skip to content

Commit ae39f71

Browse files
committed
docs and test
1 parent 5d595a7 commit ae39f71

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

brainbox/ephys_plots.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,15 @@ def line_amp_plot(spike_amps, spike_depths, spike_times, chn_coords, d_bin=10, d
376376

377377

378378
def plot_brain_regions(channel_ids, channel_depths=None, brain_regions=None, display=True, ax=None):
379+
"""
380+
Plot brain regions along probe, if channel depths is provided will plot along depth otherwise along channel idx
381+
:param channel_ids: atlas ids for each channel
382+
:param channel_depths: depth along probe for each channel
383+
:param brain_regions: BrainRegions object
384+
:param display: whether to output plot
385+
:param ax: axis to plot on
386+
:return:
387+
"""
379388

380389
if channel_depths is not None:
381390
assert channel_ids.shape[0] == channel_depths.shape[0]
@@ -414,7 +423,20 @@ def plot_brain_regions(channel_ids, channel_depths=None, brain_regions=None, dis
414423

415424

416425
def plot_cdf(spike_amps, spike_depths, spike_times, n_amp_bins=10, d_bin=40, amp_range=None, d_range=None,
417-
display=False, cmap='hot'):
426+
display=False, cmap='hot'):
427+
"""
428+
Plot cumulative amplitude of spikes across depth
429+
:param spike_amps:
430+
:param spike_depths:
431+
:param spike_times:
432+
:param n_amp_bins: number of amplitude bins to use
433+
:param d_bin: the value of the depth bins in um (default is 40 um)
434+
:param amp_range: amp range to use [amp_min, amp_max], if not given automatically computed from spike_amps
435+
:param d_range: depth range to use, by default [0, 3840]
436+
:param display: whether or not to display plot
437+
:param cmap:
438+
:return:
439+
"""
418440

419441
amp_range = amp_range or np.quantile(spike_amps, (0, 0.9))
420442
amp_bins = np.linspace(amp_range[0], amp_range[1], n_amp_bins)

ibllib/atlas/regions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ def _mapping_from_regions_list(self, new_map, lateralize=False):
152152
def remap(self, region_ids, source_map='Allen', target_map='Beryl'):
153153
"""
154154
Remap atlas regions ids from source map to target map
155-
:param region_ids:
156-
:param source_map:
157-
:param target_map:
155+
:param region_ids: atlas ids to map
156+
:param source_map: map name which original region_ids are in
157+
:param target_map: map name onto which to map
158158
:return:
159159
"""
160160
_, inds = ismember(region_ids, self.id[self.mappings[source_map]])

ibllib/tests/test_atlas.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ def test_mappings_not_lateralized(self):
5757
inds_[0] = 0
5858
assert np.all(inds == inds_)
5959

60+
def test_remap(self):
61+
# Test mapping atlas ids from one map to another
62+
atlas_id = np.array([463, 685]) # CA3 and PO
63+
cosmos_atlas_id = self.brs.remap(atlas_id, source_map='Allen', target_map='Cosmos')
64+
expectd_cosmos_id = [1089, 549] # HPF and TH
65+
assert np.all(cosmos_atlas_id == expectd_cosmos_id)
66+
6067

6168
class TestAtlasSlicesConversion(unittest.TestCase):
6269

0 commit comments

Comments
 (0)