Skip to content

Commit 9488bd2

Browse files
authored
Merge branch 'main' into import-cleanup-again
2 parents 33a7598 + 43fe8bd commit 9488bd2

File tree

4 files changed

+56
-55
lines changed

4 files changed

+56
-55
lines changed

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

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
#

src/spikeinterface/extractors/neoextractors/spikeglx.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,18 @@ def __init__(
7575

7676
self._kwargs.update(dict(folder_path=str(Path(folder_path).absolute()), load_sync_channel=load_sync_channel))
7777

78+
stream_is_nidq_or_sync = "nidq" in self.stream_id or "SYNC" in self.stream_id
79+
if stream_is_nidq_or_sync:
80+
# Do not add probe information for the sync or nidq stream. Early return
81+
return None
82+
7883
# Checks if the probe information is available and adds location, shanks and sample shift if available.
7984
signals_info_dict = {e["stream_name"]: e for e in self.neo_reader.signals_info_list}
8085
meta_filename = signals_info_dict[self.stream_id]["meta_file"]
86+
8187
ap_meta_filename = meta_filename.replace(".lf", ".ap") if "lf" in self.stream_id else meta_filename
8288
ap_meta_file_exists = Path(ap_meta_filename).exists()
83-
stream_is_not_nidq = "nidq" not in self.stream_id
84-
add_probe_properties = ap_meta_file_exists and stream_is_not_nidq and not load_sync_channel
89+
add_probe_properties = ap_meta_file_exists and not load_sync_channel
8590

8691
if add_probe_properties:
8792
probe = probeinterface.read_spikeglx(ap_meta_filename)

src/spikeinterface/extractors/tests/test_neoextractors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ class SpikeGLXRecordingTest(RecordingCommonTestSuite, unittest.TestCase):
101101
downloads = ["spikeglx"]
102102
entities = [
103103
("spikeglx/Noise4Sam_g0", {"stream_id": "imec0.ap"}),
104-
("spikeglx/Noise4Sam_g0", {"stream_id": "imec0.ap", "load_sync_channel": True}),
105104
("spikeglx/Noise4Sam_g0", {"stream_id": "imec0.lf"}),
106105
("spikeglx/Noise4Sam_g0", {"stream_id": "nidq"}),
106+
("spikeglx/Noise4Sam_g0", {"stream_id": "imec0.ap-SYNC"}),
107107
]
108108

109109

0 commit comments

Comments
 (0)