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

Improve generate.py with spatial on generate_template() #2098

Merged
merged 12 commits into from
Oct 24, 2023

Conversation

samuelgarcia
Copy link
Member

@samuelgarcia samuelgarcia commented Oct 12, 2023

This add:

  • a speed delay to mimic propagation on generate template used in generate_ground_truth()
  • use multi columns for the Probe in generate_ground_truth()

@yger

@yger
Copy link
Collaborator

yger commented Oct 12, 2023

Cool, awesome, I'll test that asap in between two grant proposals :-) Thanks a lot. The propagation is isotropic for now, am I right?

@alejoe91 alejoe91 added the core Changes to core module label Oct 12, 2023
@samuelgarcia samuelgarcia marked this pull request as ready for review October 23, 2023 08:09
Copy link
Collaborator

@zm711 zm711 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring comments

src/spikeinterface/core/generate.py Outdated Show resolved Hide resolved
src/spikeinterface/core/generate.py Outdated Show resolved Hide resolved
src/spikeinterface/core/generate.py Show resolved Hide resolved
Comment on lines +1027 to +1043
dist = distances[u, :].copy()
dist -= np.min(dist)
delay_s = dist / propagation_speed / 1000.0
sample_shifts = delay_s * fs

# apply the delay with fft transform to get sub sample shift
n = wfs.shape[0]
wfs_f = np.fft.rfft(wfs, axis=0)
if n % 2 == 0:
# n is even sig_f[-1] is nyquist and so pi
omega = np.linspace(0, np.pi, wfs_f.shape[0])
else:
# n is odd sig_f[-1] is exactly nyquist!! we need (n-1) / n factor!!
omega = np.linspace(0, np.pi * (n - 1) / n, wfs_f.shape[0])
# broadcast omega and sample_shifts depend the axis
shifts = omega[:, np.newaxis] * sample_shifts[np.newaxis, :]
wfs = np.fft.irfft(wfs_f * np.exp(-1j * shifts), n=n, axis=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@samuelgarcia samuelgarcia merged commit 501d9fb into SpikeInterface:main Oct 24, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Changes to core module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants