Skip to content

Commit 47b1c35

Browse files
authored
Merge branch 'main' into metric_system_units_docs
2 parents cf26c9a + 0841834 commit 47b1c35

12 files changed

Lines changed: 57 additions & 55 deletions

File tree

doc/how_to/combine_recordings.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Combine recordings in SpikeInterface
44
In this tutorial we will walk through combining multiple recording objects. Sometimes this occurs due to hardware
55
settings (e.g. Intan software has a default setting of new files every 1 minute) or the experimenter decides to
66
split their recording into multiple files for different experimental conditions. If the probe has not been moved,
7-
however, then during sorting it would likely make sense to combine these individual reocrding objects into one
7+
however, then during sorting it would likely make sense to combine these individual recording objects into one
88
recording object.
99

1010
**Why Combine?**

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "spikeinterface"
3-
version = "0.102.3"
3+
version = "0.102.4"
44
authors = [
55
{ name="Alessio Buccino", email="alessiop.buccino@gmail.com" },
66
{ name="Samuel Garcia", email="sam.garcia.die@gmail.com" },
@@ -126,17 +126,17 @@ test_core = [
126126

127127
# for github test : probeinterface and neo from master
128128
# for release we need pypi, so this need to be commented
129-
# "probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
130-
# "neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
129+
"probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
130+
"neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
131131
]
132132

133133
test_extractors = [
134134
# Functions to download data in neo test suite
135135
"pooch>=1.8.2",
136136
"datalad>=1.0.2",
137137
# Commenting out for release
138-
# "probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
139-
# "neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
138+
"probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
139+
"neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
140140
]
141141

142142
test_preprocessing = [
@@ -174,8 +174,8 @@ test = [
174174

175175
# for github test : probeinterface and neo from master
176176
# for release we need pypi, so this need to be commented
177-
# "probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
178-
# "neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
177+
"probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git",
178+
"neo @ git+https://github.com/NeuralEnsemble/python-neo.git",
179179
]
180180

181181
docs = [
@@ -200,8 +200,8 @@ docs = [
200200
"datalad>=1.0.2",
201201

202202
# for release we need pypi, so this needs to be commented
203-
# "probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git", # We always build from the latest version
204-
# "neo @ git+https://github.com/NeuralEnsemble/python-neo.git", # We always build from the latest version
203+
"probeinterface @ git+https://github.com/SpikeInterface/probeinterface.git", # We always build from the latest version
204+
"neo @ git+https://github.com/NeuralEnsemble/python-neo.git", # We always build from the latest version
205205
]
206206

207207
dev = [

src/spikeinterface/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@
2727
# This flag must be set to False for release
2828
# This avoids using versioning that contains ".dev0" (and this is a better choice)
2929
# This is mainly useful when using run_sorter in a container and spikeinterface install
30-
# DEV_MODE = True
31-
DEV_MODE = False
30+
DEV_MODE = True
31+
# DEV_MODE = False

src/spikeinterface/benchmark/benchmark_base.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,15 +594,22 @@ def load_folder(cls, folder):
594594
elif format == "sorting":
595595
from spikeinterface.core import load_extractor
596596

597-
result[k] = load(folder / k)
597+
sorting_folder = folder / k
598+
if sorting_folder.exists():
599+
result[k] = load(sorting_folder)
598600
elif format == "Motion":
599601
from spikeinterface.core.motion import Motion
600602

601-
result[k] = Motion.load(folder / k)
603+
motion_folder = folder / k
604+
if motion_folder.exists():
605+
result[k] = Motion.load(motion_folder)
602606
elif format == "zarr_templates":
603607
from spikeinterface.core.template import Templates
604608

605-
result[k] = Templates.from_zarr(folder / k)
609+
zarr_folder = folder / k
610+
if zarr_folder.exists():
611+
612+
result[k] = Templates.from_zarr(zarr_folder)
606613

607614
return result
608615

src/spikeinterface/core/baserecording.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,9 @@ def frame_slice(self, start_frame: int | None, end_frame: int | None) -> BaseRec
757757
Parameters
758758
----------
759759
start_frame : int, optional
760-
The start frame, if not provided it is set to 0
760+
Start frame index. If None, defaults to the beginning of the recording (frame 0).
761761
end_frame : int, optional
762-
The end frame, it not provided it is set to the total number of samples
762+
End frame index. If None, defaults to the last frame of the recording.
763763
764764
Returns
765765
-------
@@ -779,9 +779,9 @@ def time_slice(self, start_time: float | None, end_time: float | None) -> BaseRe
779779
Parameters
780780
----------
781781
start_time : float, optional
782-
The start time in seconds. If not provided it is set to 0.
782+
Start time in seconds. If None, defaults to the beginning of the recording.
783783
end_time : float, optional
784-
The end time in seconds. If not provided it is set to the total duration.
784+
End time in seconds. If None, defaults to the end of the recording.
785785
786786
Returns
787787
-------

src/spikeinterface/extractors/nwbextractors.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,13 @@ def _fetch_recording_segment_info_backend(self, file, cache, load_time_vector, s
759759
if "starting_time" in electrical_series.keys():
760760
t_start = electrical_series["starting_time"][()]
761761
sampling_frequency = electrical_series["starting_time"].attrs["rate"]
762+
timestamps = None
762763
elif "timestamps" in electrical_series.keys():
763764
timestamps = electrical_series["timestamps"][:]
764765
t_start = timestamps[0]
765766
sampling_frequency = 1.0 / np.median(np.diff(timestamps[:samples_for_rate_estimation]))
767+
else:
768+
raise ValueError("TimeSeries must have either starting_time or timestamps")
766769

767770
if load_time_vector and timestamps is not None:
768771
times_kwargs = dict(time_vector=electrical_series["timestamps"])
@@ -1572,6 +1575,8 @@ def _fetch_recording_segment_info(self, file, cache, load_time_vector, samples_f
15721575
timestamps = timeseries.timestamps
15731576
sampling_frequency = 1.0 / np.median(np.diff(timestamps[:samples_for_rate_estimation]))
15741577
t_start = timestamps[0]
1578+
else:
1579+
raise ValueError("TimeSeries must have either starting_time or timestamps")
15751580

15761581
if load_time_vector and timestamps is not None:
15771582
times_kwargs = dict(time_vector=timestamps)

src/spikeinterface/postprocessing/spike_amplitudes.py

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,19 @@ class ComputeSpikeAmplitudes(AnalyzerExtension):
1717
Computes the spike amplitudes.
1818
1919
Needs "templates" to be computed first.
20-
Localize spikes in 2D or 3D with several methods given the template.
20+
Computes spike amplitudes from the template's peak channel for every spike.
2121
2222
Parameters
2323
----------
2424
sorting_analyzer : SortingAnalyzer
2525
A SortingAnalyzer object
26-
ms_before : float, default: 0.5
27-
The left window, before a peak, in milliseconds
28-
ms_after : float, default: 0.5
29-
The right window, after a peak, in milliseconds
30-
spike_retriver_kwargs : dict
31-
A dictionary to control the behavior for getting the maximum channel for each spike
32-
This dictionary contains:
33-
* channel_from_template: bool, default: True
34-
For each spike is the maximum channel computed from template or re estimated at every spikes
35-
channel_from_template = True is old behavior but less acurate
36-
channel_from_template = False is slower but more accurate
37-
* radius_um: float, default: 50
38-
In case channel_from_template=False, this is the radius to get the true peak
39-
* peak_sign, default: "neg"
40-
In case channel_from_template=False, this is the peak sign.
41-
method : "center_of_mass" | "monopolar_triangulation" | "grid_convolution", default: "center_of_mass"
42-
The localization method to use
43-
**method_kwargs : dict, default: {}
44-
Kwargs which are passed to the method function. These can be found in the docstrings of `compute_center_of_mass`, `compute_grid_convolution` and `compute_monopolar_triangulation`.
45-
outputs : "numpy" | "by_unit", default: "numpy"
46-
The output format, either concatenated as numpy array or separated on a per unit basis
26+
peak_sign : "neg" | "pos" | "both", default: "neg"
27+
Sign of the template to compute extremum channel used to retrieve spike amplitudes.
4728
4829
Returns
4930
-------
50-
spike_locations: np.array
51-
All locations for all spikes and all units are concatenated
31+
spike_amplitudes: np.array
32+
All amplitudes for all spikes and all units are concatenated (along time, like in spike vector)
5233
5334
"""
5435

src/spikeinterface/preprocessing/motion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ def compute_motion(
443443
t1 = time.perf_counter()
444444
run_times["estimate_motion"] = t1 - t0
445445

446-
if recording.get_dtype().kind != "f":
447-
recording = recording.astype("float32")
448-
449446
motion_info = dict(
450447
parameters=parameters,
451448
run_times=run_times,
@@ -554,6 +551,9 @@ def correct_motion(
554551
**job_kwargs,
555552
)
556553

554+
if recording.get_dtype().kind != "f":
555+
recording = recording.astype("float32")
556+
557557
recording_corrected = interpolate_motion(recording, motion, **interpolate_motion_kwargs)
558558

559559
if not output_motion and not output_motion_info:

src/spikeinterface/preprocessing/tests/test_motion.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ def test_estimate_and_correct_motion(create_cache_folder):
3232
assert motion_info_loaded["motion"] == motion_info["motion"]
3333

3434

35+
def test_estimate_and_correct_motion_int():
36+
37+
rec = generate_recording(durations=[30.0], num_channels=12).astype(int)
38+
rec_corrected = correct_motion(rec, estimate_motion_kwargs={"win_step_um": 50, "win_scale_um": 100})
39+
assert rec_corrected.get_dtype().kind == "f"
40+
41+
3542
def test_get_motion_parameters_preset():
3643
from pprint import pprint
3744

src/spikeinterface/sorters/runsorter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,10 @@ def run_sorter_container(
479479
extra_kwargs["container_requires_gpu"] = True
480480

481481
if platform.system() == "Linux" and not has_docker_nvidia_installed():
482+
from .utils import get_nvidia_docker_dependencies
483+
482484
warn(
483-
f"nvidia-required but none of \n{get_nvidia_docker_dependecies()}\n were found. "
485+
f"nvidia-required but none of \n{get_nvidia_docker_dependencies()}\n were found. "
484486
f"This may result in an error being raised during sorting. Try "
485487
"installing `nvidia-container-toolkit`, including setting the "
486488
"configuration steps, if running into errors."

0 commit comments

Comments
 (0)