Skip to content

Commit bbe2a53

Browse files
committed
Fix conflicts
2 parents 02540f4 + acf848f commit bbe2a53

File tree

75 files changed

+1109
-523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1109
-523
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ If you find SpikeInterface useful in your research, please cite:
134134
```
135135

136136
Please also cite other relevant papers for the specific components you use.
137-
For a ful list of references, please check the [references](https://spikeinterface.readthedocs.io/en/latest/references.html) page.
137+
For a full list of references, please check the [references](https://spikeinterface.readthedocs.io/en/latest/references.html) page.

doc/how_to/handle_drift.rst

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,38 +1455,32 @@ Plot the results
14551455
We load back the results and use the widgets module to explore the
14561456
estimated drift motion.
14571457

1458-
For all methods we have 4 plots: \* top left: time vs estimated peak
1459-
depth \* top right: time vs peak depth after motion correction \* bottom
1460-
left: the average motion vector across depths and all motion across
1461-
spatial depths (for non-rigid estimation) \* bottom right: if motion
1462-
correction is non rigid, the motion vector across depths is plotted as a
1463-
map, with the color code representing the motion in micrometers.
1464-
1465-
A few comments on the figures: \* the preset **‘rigid_fast’** has only
1466-
one motion vector for the entire probe because it is a “rigid” case. The
1467-
motion amplitude is globally underestimated because it averages across
1468-
depths. However, the corrected peaks are flatter than the non-corrected
1469-
ones, so the job is partially done. The big jump at=600s when the probe
1470-
start moving is recovered quite well. \* The preset **kilosort_like**
1471-
gives better results because it is a non-rigid case. The motion vector
1472-
is computed for different depths. The corrected peak locations are
1473-
flatter than the rigid case. The motion vector map is still be a bit
1474-
noisy at some depths (e.g around 1000um). \* The preset **dredge** is
1475-
offcial DREDge re-implementation in spikeinterface. It give the best
1476-
result : very fast and smooth motion estimation. Very few noise. This
1477-
method also capture very well the non rigid motion gradient along the
1478-
probe. The best method on the market at the moement. An enormous thanks
1479-
to the dream team : Charlie Windolf, Julien Boussard, Erdem Varol, Liam
1480-
Paninski. Note that in the first part of the recording before the
1481-
imposed motion (0-600s) we clearly have a non-rigid motion: the upper
1482-
part of the probe (2000-3000um) experience some drifts, but the lower
1483-
part (0-1000um) is relatively stable. The method defined by this preset
1484-
is able to capture this. \* The preset **nonrigid_accurate** this is the
1485-
ancestor of “dredge” before it was published. It seems to give the good
1486-
results on this recording but with bit more noise. \* The preset
1487-
**dredge_fast** similar than dredge but faster (using grid_convolution).
1488-
\* The preset **nonrigid_fast_and_accurate** a variant of
1489-
nonrigid_accurate but faster (using grid_convolution).
1458+
For all methods we have 4 plots:
1459+
* top left: time vs estimated peak
1460+
* top right: time vs peak depth after motion correction
1461+
* bottom left: the average motion vector across depths and all motion across spatial depths (for non-rigid estimation)
1462+
* bottom right: if motion correction is non rigid, the motion vector across depths is plotted as a map,
1463+
with the color code representing the motion in micrometers.
1464+
1465+
A few comments on the figures:
1466+
* the preset **‘rigid_fast’** has only one motion vector for the entire probe because it is a “rigid” case. The
1467+
motion amplitude is globally underestimated because it averages across depths. However, the corrected peaks
1468+
are flatter than the non-corrected ones, so the job is partially done. The big jump at=600s when the probe start
1469+
moving is recovered quite well.
1470+
* The preset **kilosort_like** gives better results because it is a non-rigid case. The motion vector is computed
1471+
for different depths. The corrected peak locations are flatter than the rigid case. The motion vector map is still
1472+
be a bit noisy at some depths (e.g around 1000um).
1473+
* The preset **dredge** is official DREDge re-implementation in spikeinterface. It give the best result : very fast
1474+
and smooth motion estimation. Very few noise. This method also capture very well the non rigid motion gradient along
1475+
the probe. The best method on the market at the moement. An enormous thanks to the dream team : Charlie Windolf,
1476+
Julien Boussard, Erdem Varol, Liam Paninski. Note that in the first part of the recording before the imposed motion
1477+
(0-600s) we clearly have a non-rigid motion: the upper part of the probe (2000-3000um) experience some drifts, but the
1478+
lower part (0-1000um) is relatively stable. The method defined by this preset is able to capture this.
1479+
* The preset **nonrigid_accurate** this is the ancestor of “dredge” before it was published. It seems to give good results
1480+
on this recording but with bit more noise.
1481+
* The preset **dredge_fast** similar than dredge but faster (using grid_convolution).
1482+
* The preset **nonrigid_fast_and_accurate** a variant of
1483+
nonrigid_accurate but faster (using grid_convolution).
14901484

14911485
.. code:: ipython3
14921486

doc/modules/preprocessing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ the "chain" concept for this module. For example:
257257
rec_only_good_channels = detect_and_remove_bad_channels(recording=rec)
258258
259259
# detect and interpolate the bad channels
260-
rec_interpolated_channels = detect_and_interpolate_bad_channels(remove_channel_ids=bad_channel_ids)
260+
rec_interpolated_channels = detect_and_interpolate_bad_channels(recording=rec)
261261
262262
263263
* :py:func:`~spikeinterface.preprocessing.detect_bad_channels()`

examples/how_to/handle_drift.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -133,32 +133,33 @@ def preprocess_chain(rec):
133133
# We load back the results and use the widgets module to explore the estimated drift motion.
134134
#
135135
# For all methods we have 4 plots:
136+
#
136137
# * top left: time vs estimated peak depth
137138
# * top right: time vs peak depth after motion correction
138139
# * bottom left: the average motion vector across depths and all motion across spatial depths (for non-rigid estimation)
139140
# * bottom right: if motion correction is non rigid, the motion vector across depths is plotted as a map, with the color code representing the motion in micrometers.
140141
#
141142
# A few comments on the figures:
142-
# * the preset **'rigid_fast'** has only one motion vector for the entire probe because it is a "rigid" case.
143-
# The motion amplitude is globally underestimated because it averages across depths.
144-
# However, the corrected peaks are flatter than the non-corrected ones, so the job is partially done.
145-
# The big jump at=600s when the probe start moving is recovered quite well.
146-
# * The preset **kilosort_like** gives better results because it is a non-rigid case.
147-
# The motion vector is computed for different depths.
148-
# The corrected peak locations are flatter than the rigid case.
149-
# The motion vector map is still be a bit noisy at some depths (e.g around 1000um).
150-
# * The preset **dredge** is offcial DREDge re-implementation in spikeinterface.
151-
# It give the best result : very fast and smooth motion estimation. Very few noise.
152-
# This method also capture very well the non rigid motion gradient along the probe.
153-
# The best method on the market at the moement.
154-
# An enormous thanks to the dream team : Charlie Windolf, Julien Boussard, Erdem Varol, Liam Paninski.
155-
# Note that in the first part of the recording before the imposed motion (0-600s) we clearly have a non-rigid motion:
156-
# the upper part of the probe (2000-3000um) experience some drifts, but the lower part (0-1000um) is relatively stable.
157-
# The method defined by this preset is able to capture this.
158-
# * The preset **nonrigid_accurate** this is the ancestor of "dredge" before it was published.
159-
# It seems to give the good results on this recording but with bit more noise.
160-
# * The preset **dredge_fast** similar than dredge but faster (using grid_convolution).
161-
# * The preset **nonrigid_fast_and_accurate** a variant of nonrigid_accurate but faster (using grid_convolution).
143+
# * the preset **'rigid_fast'** has only one motion vector for the entire probe because it is a "rigid" case.
144+
# The motion amplitude is globally underestimated because it averages across depths.
145+
# However, the corrected peaks are flatter than the non-corrected ones, so the job is partially done.
146+
# The big jump at=600s when the probe start moving is recovered quite well.
147+
# * The preset **kilosort_like** gives better results because it is a non-rigid case.
148+
# The motion vector is computed for different depths.
149+
# The corrected peak locations are flatter than the rigid case.
150+
# The motion vector map is still be a bit noisy at some depths (e.g around 1000um).
151+
# * The preset **dredge** is offcial DREDge re-implementation in spikeinterface.
152+
# It give the best result : very fast and smooth motion estimation. Very few noise.
153+
# This method also capture very well the non rigid motion gradient along the probe.
154+
# The best method on the market at the moement.
155+
# An enormous thanks to the dream team : Charlie Windolf, Julien Boussard, Erdem Varol, Liam Paninski.
156+
# Note that in the first part of the recording before the imposed motion (0-600s) we clearly have a non-rigid motion:
157+
# the upper part of the probe (2000-3000um) experience some drifts, but the lower part (0-1000um) is relatively stable.
158+
# The method defined by this preset is able to capture this.
159+
# * The preset **nonrigid_accurate** this is the ancestor of "dredge" before it was published.
160+
# It seems to give the good results on this recording but with bit more noise.
161+
# * The preset **dredge_fast** similar than dredge but faster (using grid_convolution).
162+
# * The preset **nonrigid_fast_and_accurate** a variant of nonrigid_accurate but faster (using grid_convolution).
162163
#
163164
#
164165

@@ -205,6 +206,7 @@ def preprocess_chain(rec):
205206
# We can see here that some clusters seem to be more compact on the 'y' axis, especially for the preset "nonrigid_accurate".
206207
#
207208
# Be aware that there are two ways to correct for the motion:
209+
#
208210
# 1. Interpolate traces and detect/localize peaks again (`interpolate_recording()`)
209211
# 2. Compensate for drifts directly on peak locations (`correct_motion_on_peaks()`)
210212
#

examples/tutorials/core/plot_4_sorting_analyzer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@
4343
##############################################################################
4444
# Let's now instantiate the recording and sorting objects:
4545

46-
recording = se.MEArecRecordingExtractor(local_path)
46+
recording, sorting = se.read_mearec(local_path)
4747
print(recording)
48-
sorting = se.MEArecSortingExtractor(local_path)
4948
print(sorting)
5049

5150
###############################################################################

examples/tutorials/extractors/plot_1_read_various_formats.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# :py:class:`~spikeinterface.extractors.Spike2RecordingExtractor` object:
6262
#
6363

64-
recording = se.Spike2RecordingExtractor(spike2_file_path, stream_id="0")
64+
recording = se.read_spike2(spike2_file_path, stream_id="0")
6565
print(recording)
6666

6767
##############################################################################
@@ -75,11 +75,6 @@
7575
print(sorting)
7676
print(type(sorting))
7777

78-
##############################################################################
79-
# The :py:func:`~spikeinterface.extractors.read_mearec` function is equivalent to:
80-
81-
recording = se.MEArecRecordingExtractor(mearec_folder_path)
82-
sorting = se.MEArecSortingExtractor(mearec_folder_path)
8378

8479
##############################################################################
8580
# SI objects (:py:class:`~spikeinterface.core.BaseRecording` and :py:class:`~spikeinterface.core.BaseSorting`)

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ qualitymetrics = [
120120
]
121121

122122
test_core = [
123-
"pytest",
123+
"pytest<8.4.0",
124124
"pytest-dependency",
125125
"psutil",
126126

@@ -146,7 +146,7 @@ test_preprocessing = [
146146

147147

148148
test = [
149-
"pytest",
149+
"pytest<8.4.0",
150150
"pytest-dependency",
151151
"pytest-cov",
152152
"psutil",

src/spikeinterface/core/analyzer_extension_core.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def _run(self, verbose=False, **job_kwargs):
194194
self.nbefore,
195195
self.nafter,
196196
mode=mode,
197-
return_scaled=self.sorting_analyzer.return_scaled,
197+
return_in_uV=self.sorting_analyzer.return_in_uV,
198198
file_path=file_path,
199199
dtype=self.params["dtype"],
200200
sparsity_mask=sparsity_mask,
@@ -216,7 +216,7 @@ def _set_params(
216216
if dtype is None:
217217
dtype = recording.get_dtype()
218218

219-
if np.issubdtype(dtype, np.integer) and self.sorting_analyzer.return_scaled:
219+
if np.issubdtype(dtype, np.integer) and self.sorting_analyzer.return_in_uV:
220220
dtype = "float32"
221221

222222
dtype = np.dtype(dtype)
@@ -427,7 +427,7 @@ def _run(self, verbose=False, **job_kwargs):
427427
# retrieve spike vector and the sampling
428428
some_spikes = self.sorting_analyzer.get_extension("random_spikes").get_random_spikes()
429429

430-
return_scaled = self.sorting_analyzer.return_scaled
430+
return_in_uV = self.sorting_analyzer.return_in_uV
431431

432432
return_std = "std" in self.params["operators"]
433433
output = estimate_templates_with_accumulator(
@@ -436,7 +436,7 @@ def _run(self, verbose=False, **job_kwargs):
436436
unit_ids,
437437
self.nbefore,
438438
self.nafter,
439-
return_scaled=return_scaled,
439+
return_in_uV=return_in_uV,
440440
return_std=return_std,
441441
verbose=verbose,
442442
**job_kwargs,
@@ -648,7 +648,7 @@ def get_templates(self, unit_ids=None, operator="average", percentile=None, save
648648
channel_ids=self.sorting_analyzer.channel_ids,
649649
unit_ids=unit_ids,
650650
probe=self.sorting_analyzer.get_probe(),
651-
is_scaled=self.sorting_analyzer.return_scaled,
651+
is_scaled=self.sorting_analyzer.return_in_uV,
652652
)
653653
else:
654654
raise ValueError("`outputs` must be 'numpy' or 'Templates'")
@@ -732,7 +732,7 @@ def _merge_extension_data(
732732
def _run(self, verbose=False, **job_kwargs):
733733
self.data["noise_levels"] = get_noise_levels(
734734
self.sorting_analyzer.recording,
735-
return_scaled=self.sorting_analyzer.return_scaled,
735+
return_in_uV=self.sorting_analyzer.return_in_uV,
736736
**self.params,
737737
**job_kwargs,
738738
)

src/spikeinterface/core/baserecording.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ def get_traces(
295295
end_frame: int | None = None,
296296
channel_ids: list | np.array | tuple | None = None,
297297
order: "C" | "F" | None = None,
298-
return_scaled: bool = False,
298+
return_scaled: bool | None = None,
299+
return_in_uV: bool = False,
299300
cast_unsigned: bool = False,
300301
) -> np.ndarray:
301302
"""Returns traces from recording.
@@ -312,7 +313,11 @@ def get_traces(
312313
The channel ids. If None, all channels are used, default: None
313314
order : "C" | "F" | None, default: None
314315
The order of the traces ("C" | "F"). If None, traces are returned as they are
315-
return_scaled : bool, default: False
316+
return_scaled : bool | None, default: None
317+
DEPRECATED. Use return_in_uV instead.
318+
If True and the recording has scaling (gain_to_uV and offset_to_uV properties),
319+
traces are scaled to uV
320+
return_in_uV : bool, default: False
316321
If True and the recording has scaling (gain_to_uV and offset_to_uV properties),
317322
traces are scaled to uV
318323
cast_unsigned : bool, default: False
@@ -327,7 +332,7 @@ def get_traces(
327332
Raises
328333
------
329334
ValueError
330-
If return_scaled is True, but recording does not have scaled traces
335+
If return_in_uV is True, but recording does not have scaled traces
331336
"""
332337
segment_index = self._check_segment_index(segment_index)
333338
channel_indices = self.ids_to_indices(channel_ids, prefer_slice=True)
@@ -351,15 +356,24 @@ def get_traces(
351356
traces = traces.astype(f"int{2 * (dtype.itemsize) * 8}") - 2 ** (nbits - 1)
352357
traces = traces.astype(f"int{dtype.itemsize * 8}")
353358

354-
if return_scaled:
359+
# Handle deprecated return_scaled parameter
360+
if return_scaled is not None:
361+
warnings.warn(
362+
"`return_scaled` is deprecated and will be removed in a future version. Use `return_in_uV` instead.",
363+
category=DeprecationWarning,
364+
stacklevel=2,
365+
)
366+
return_in_uV = return_scaled
367+
368+
if return_in_uV:
355369
if not self.has_scaleable_traces():
356370
if self._dtype.kind == "f":
357371
# here we do not truely have scale but we assume this is scaled
358372
# this helps a lot for simulated data
359373
pass
360374
else:
361375
raise ValueError(
362-
"This recording does not support return_scaled=True (need gain_to_uV and offset_"
376+
"This recording does not support return_in_uV=True (need gain_to_uV and offset_"
363377
"to_uV properties)"
364378
)
365379
else:

0 commit comments

Comments
 (0)