Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dredge lfp and dredge ap #3062

Merged
merged 37 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
400b0b3
initial copy/paste from dredge
samuelgarcia Jun 19, 2024
ddf094b
Move motion files into new motion subfolder
samuelgarcia Jun 21, 2024
a6424f2
Reorganize dredge function with already existing
samuelgarcia Jun 21, 2024
cabbbeb
dredge test file
samuelgarcia Jun 21, 2024
00bef34
fix
samuelgarcia Jun 21, 2024
62c75f8
Put spatial_bin_centers in get_windows()
samuelgarcia Jun 21, 2024
13c81ac
small fix
samuelgarcia Jun 21, 2024
1ac451c
motion_estimation() : refactoring party.
samuelgarcia Jun 26, 2024
532ea48
start porting dredge_ap
samuelgarcia Jun 26, 2024
c2f5289
important comments
samuelgarcia Jun 26, 2024
cab6646
wip dredge_ap
samuelgarcia Jun 27, 2024
37014bb
more refactoring and parameters change
samuelgarcia Jun 27, 2024
e2e9bff
import fix
samuelgarcia Jun 27, 2024
20a0e90
Merge branch 'main' of github.com:SpikeInterface/spikeinterface into …
samuelgarcia Jun 28, 2024
ea01729
fixing dredge_ap details
samuelgarcia Jun 28, 2024
75decf6
still rafactor and fix estimate_motion() for dredge_ap
samuelgarcia Jul 3, 2024
ae18211
move doc for dredge classes
samuelgarcia Jul 3, 2024
21072ff
Merge with main
samuelgarcia Jul 4, 2024
64f3177
wip
samuelgarcia Jul 5, 2024
41e6eda
dredge_lfp doc
samuelgarcia Jul 8, 2024
5c250e1
dredge_lfp doc
samuelgarcia Jul 8, 2024
840e9c1
dredge_lfp doc
samuelgarcia Jul 8, 2024
8ef01d9
Add tutorial motion.
samuelgarcia Jul 8, 2024
35ab6b0
Merge branch 'main' into dredge_lfp
samuelgarcia Jul 11, 2024
18b7cfe
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 11, 2024
de7df4b
Fix tests
alejoe91 Jul 12, 2024
261b021
Cleanup how to
alejoe91 Jul 12, 2024
41d3903
Handle negative/0 windows, contact_depth->contact_depths, add verbosi…
alejoe91 Jul 12, 2024
27a7f12
typo
alejoe91 Jul 12, 2024
96789ba
Merge branch 'main' into dredge_lfp
alejoe91 Jul 12, 2024
997cdba
Use numpy.broadcast_to for conv_engine numpy in normxcorr1d
alejoe91 Jul 12, 2024
b3c954b
Merge branch 'dredge_lfp' of github.com:samuelgarcia/spikeinterface i…
alejoe91 Jul 12, 2024
e8f4e76
formatting
alejoe91 Jul 12, 2024
7568260
Fix tdc2 and propagate to API
alejoe91 Jul 12, 2024
e318088
raise error if num_windows<1 and fix motion test
alejoe91 Jul 12, 2024
4c4e70f
Fix final(?) torch import
alejoe91 Jul 12, 2024
abb6a7c
Fix generation tests
alejoe91 Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/modules/sortingcomponents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Here is an example with non-rigid motion estimation:
from spikeinterface.sortingcomponents.motion_estimation import estimate_motion
motion, temporal_bins, spatial_bins,
extra_check = estimate_motion(recording=recording, peaks=peaks, peak_locations=peak_locations,
direction='y', bin_duration_s=10., bin_um=10., margin_um=0.,
direction='y', bin_s=10., bin_um=10., margin_um=0.,
method='decentralized_registration',
rigid=False, win_shape='gaussian', win_step_um=50., win_sigma_um=150.,
progress_bar=True, verbose=True)
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/generation/hybrid_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)
from spikeinterface.core.template_tools import get_template_extremum_channel

from spikeinterface.sortingcomponents.motion_utils import Motion
from spikeinterface.sortingcomponents.motion import Motion

from spikeinterface.generation.drift_tools import (
InjectDriftingTemplatesRecording,
Expand Down
49 changes: 22 additions & 27 deletions src/spikeinterface/preprocessing/motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
method="locally_exclusive",
peak_sign="neg",
detect_threshold=8.0,
exclude_sweep_ms=0.1,
radius_um=50,
exclude_sweep_ms=0.8,
radius_um=80.,
),
"select_kwargs": dict(),
"localize_peaks_kwargs": dict(
Expand All @@ -35,16 +35,13 @@
"estimate_motion_kwargs": dict(
method="decentralized",
direction="y",
bin_duration_s=2.0,
bin_s=1.0,
rigid=False,
bin_um=5.0,
margin_um=0.0,
# win_shape="gaussian",
# win_step_um=50.0,
# win_sigma_um=150.0,
hist_margin_um=20.0,
win_shape="gaussian",
win_step_um=100.0,
win_sigma_um=200.0,
win_step_um=200.0,
win_scale_um=300.0,
histogram_depth_smooth_um=5.0,
histogram_time_smooth_s=None,
pairwise_displacement_method="conv",
Expand Down Expand Up @@ -78,13 +75,14 @@
method="locally_exclusive",
peak_sign="neg",
detect_threshold=8.0,
exclude_sweep_ms=0.5,
radius_um=50,
exclude_sweep_ms=0.8,
radius_um=80.,
),
"select_kwargs": dict(),
"localize_peaks_kwargs": dict(
method="grid_convolution",
radius_um=40.0,
# radius_um=40.0,
radius_um=80.0,
upsampling_um=5.0,
sigma_ms=0.25,
margin_um=30.0,
Expand All @@ -94,16 +92,13 @@
"estimate_motion_kwargs": dict(
method="decentralized",
direction="y",
bin_duration_s=2.0,
bin_s=2.0,
rigid=False,
bin_um=5.0,
margin_um=0.0,
# win_shape="gaussian",
# win_step_um=50.0,
# win_sigma_um=150.0,
hist_margin_um=0.0,
win_shape="gaussian",
win_step_um=100.0,
win_sigma_um=200.0,
win_scale_um=200.0,
histogram_depth_smooth_um=5.0,
histogram_time_smooth_s=None,
pairwise_displacement_method="conv",
Expand Down Expand Up @@ -149,7 +144,7 @@
),
"estimate_motion_kwargs": dict(
method="decentralized",
bin_duration_s=10.0,
bin_s=10.0,
rigid=True,
),
"interpolate_motion_kwargs": dict(
Expand Down Expand Up @@ -179,11 +174,11 @@
),
"estimate_motion_kwargs": dict(
method="iterative_template",
bin_duration_s=2.0,
bin_s=2.0,
rigid=False,
win_step_um=50.0,
win_sigma_um=150.0,
margin_um=0,
win_scale_um=150.0,
hist_margin_um=0,
win_shape="rect",
),
"interpolate_motion_kwargs": dict(
Expand All @@ -201,6 +196,7 @@
}



def correct_motion(
recording,
preset="nonrigid_accurate",
Expand Down Expand Up @@ -241,8 +237,8 @@ def correct_motion(
* :py:func:`~spikeinterface.sortingcomponents.peak_detection.detect_peaks`
* :py:func:`~spikeinterface.sortingcomponents.peak_selection.select_peaks`
* :py:func:`~spikeinterface.sortingcomponents.peak_localization.localize_peaks`
* :py:func:`~spikeinterface.sortingcomponents.motion_estimation.estimate_motion`
* :py:func:`~spikeinterface.sortingcomponents.motion_interpolation.interpolate_motion`
* :py:func:`~spikeinterface.sortingcomponents.motion.motion_estimation.estimate_motion`
* :py:func:`~spikeinterface.sortingcomponents.motion.motion_interpolation.interpolate_motion`


Possible presets : {}
Expand Down Expand Up @@ -286,8 +282,7 @@ def correct_motion(
from spikeinterface.sortingcomponents.peak_detection import detect_peaks, detect_peak_methods
from spikeinterface.sortingcomponents.peak_selection import select_peaks
from spikeinterface.sortingcomponents.peak_localization import localize_peaks, localize_peak_methods
from spikeinterface.sortingcomponents.motion_estimation import estimate_motion
from spikeinterface.sortingcomponents.motion_interpolation import InterpolateMotionRecording
from spikeinterface.sortingcomponents.motion import estimate_motion, InterpolateMotionRecording
from spikeinterface.core.node_pipeline import ExtractDenseWaveforms, run_node_pipeline

# get preset params and update if necessary
Expand Down Expand Up @@ -431,7 +426,7 @@ def save_motion_info(motion_info, folder, overwrite=False):


def load_motion_info(folder):
from spikeinterface.sortingcomponents.motion_utils import Motion
from spikeinterface.sortingcomponents.motion import Motion

folder = Path(folder)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

from spikeinterface.core import get_noise_levels
from spikeinterface.sortingcomponents.benchmark.benchmark_tools import Benchmark, BenchmarkStudy, _simpleaxis
from spikeinterface.sortingcomponents.motion_estimation import estimate_motion
from spikeinterface.sortingcomponents.motion import estimate_motion
from spikeinterface.sortingcomponents.peak_detection import detect_peaks
from spikeinterface.sortingcomponents.peak_selection import select_peaks
from spikeinterface.sortingcomponents.peak_localization import localize_peaks
from spikeinterface.widgets import plot_probe_map

from spikeinterface.sortingcomponents.motion_utils import Motion
from spikeinterface.sortingcomponents.motion import Motion

# import MEArec as mr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from spikeinterface.sorters import run_sorter

from spikeinterface.comparison import GroundTruthComparison
from spikeinterface.sortingcomponents.motion_interpolation import InterpolateMotionRecording
from spikeinterface.sortingcomponents.motion.motion_interpolation import InterpolateMotionRecording
from spikeinterface.curation import MergeUnitsSorting


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def load_folder(cls, folder):

result[k] = load_extractor(folder / k)
elif format == "Motion":
from spikeinterface.sortingcomponents.motion_utils import Motion
from spikeinterface.sortingcomponents.motion import Motion

result[k] = Motion.load(folder / k)
elif format == "zarr_templates":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def test_benchmark_motion_estimaton(create_cache_folder):
localize_kwargs=dict(method=loc_method),
estimate_motion_kwargs=dict(
method=est_method,
bin_duration_s=1.0,
bin_s=1.0,
bin_um=5.0,
rigid=False,
win_step_um=50.0,
win_sigma_um=200.0,
win_scale_um=200.0,
),
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_benchmark_motion_interpolation(create_cache_folder):
# plt.show()

cases = {}
bin_duration_s = 1.0
bin_s = 1.0

cases["static_SC2"] = dict(
label="No drift - no correction - SC2",
Expand Down
5 changes: 5 additions & 0 deletions src/spikeinterface/sortingcomponents/motion/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .motion_utils import Motion
from .motion_estimation import estimate_motion
from .motion_interpolation import (correct_motion_on_peaks, interpolate_motion_on_traces,
InterpolateMotionRecording, interpolate_motion)
from .motion_cleaner import clean_motion_vector
Loading
Loading