Skip to content

Commit

Permalink
blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
oliche committed Feb 27, 2024
1 parent e2a8908 commit be2f35b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/spikeinterface/extractors/alfsortingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

try:
import pandas as pd

HAVE_PANDAS = True
except:
HAVE_PANDAS = False
Expand Down Expand Up @@ -43,12 +44,12 @@ def __init__(self, folder_path, sampling_frequency=30000):
assert self.installed, self.installation_mesg
# check correct parent folder:
self._folder_path = Path(folder_path)
spikes = alfio.load_object(self._folder_path, 'spikes', short_keys=True)
clusters = alfio.load_object(self._folder_path, 'clusters', short_keys=True)
spikes = alfio.load_object(self._folder_path, "spikes", short_keys=True)
clusters = alfio.load_object(self._folder_path, "clusters", short_keys=True)
total_units = clusters[next(iter(clusters))].size
unit_ids = np.arange(total_units) # in alf format, spikes.clusters index directly into clusters
BaseSorting.__init__(self, unit_ids=unit_ids, sampling_frequency=sampling_frequency)
sorting_segment = ALFSortingSegment(spikes['clusters'], spikes["times"], sampling_frequency)
sorting_segment = ALFSortingSegment(spikes["clusters"], spikes["times"], sampling_frequency)
self.add_sorting_segment(sorting_segment)
self.extra_requirements.append("pandas")
self.extra_requirements.append("ONE-api")
Expand Down
10 changes: 5 additions & 5 deletions src/spikeinterface/extractors/tests/test_alfsortingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def test_alf_sorting_extractor():
spike_times = []
spike_clusters = []
for i, fr in enumerate([123, 78, 145]):
st = np.cumsum(- np.log(np.random.rand(int(rec_len_secs * firing_rate * 1.5))) / firing_rate)
st = st[:np.searchsorted(st, rec_len_secs)]
st = np.cumsum(-np.log(np.random.rand(int(rec_len_secs * firing_rate * 1.5))) / firing_rate)
st = st[: np.searchsorted(st, rec_len_secs)]
spike_times.append(st)
spike_clusters.append(st * 0 + i)
spike_times = np.concatenate(spike_times)
Expand All @@ -25,9 +25,9 @@ def test_alf_sorting_extractor():

with tempfile.TemporaryDirectory() as td:
folder_path = Path(td)
np.save(folder_path.joinpath('spikes.times.npy'), spike_times)
np.save(folder_path.joinpath('spikes.clusters.npy'), spike_clusters)
np.save(folder_path.joinpath('clusters.channels.npy'), np.arange(3))
np.save(folder_path.joinpath("spikes.times.npy"), spike_times)
np.save(folder_path.joinpath("spikes.clusters.npy"), spike_clusters)
np.save(folder_path.joinpath("clusters.channels.npy"), np.arange(3))

sorting = read_alf_sorting(folder_path, sampling_frequency=30000)
assert sorting.get_unit_spike_train(0).size > 50_000

0 comments on commit be2f35b

Please sign in to comment.