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

Tools for Generation of Hybrid recordings #2436

Open
wants to merge 110 commits into
base: main
Choose a base branch
from

Conversation

yger
Copy link
Collaborator

@yger yger commented Jan 24, 2024

For the hybrid project, make a function that can get Templates from any recording. To be discussed, as some features to play/interact with Templates are currently only written for WaveformExtactor and might need to be duplicated

@yger yger added enhancement New feature or request hybrid Related to Hybrid testing labels Jan 24, 2024
@yger yger self-assigned this Jan 24, 2024
@yger
Copy link
Collaborator Author

yger commented Jan 26, 2024

This PR depends on #2410

@alejoe91
Copy link
Member

Added additional functionalities for hybrid generations:

  • filter a Templates object based on amplitudes and depths
  • scale Templates between min/max user selected amps
  • shift Templates to move them away from their original position

Also extended the plot_unit_templates to work with a sorting_analyzer_or_templates object

@alejoe91
Copy link
Member

@samuelgarcia @yger since I was working on it, I also added a Widen/Narrow option and scalebars for plot_unit_waveforms/templates. Here's how it looks:

Screencast.from.14-05-2024.12.39.14.webm

This is ready to merge on my side!

else:
template_info = fetch_templates_info().iloc[template_df_or_indices]
requested_datasets = np.unique(template_info["dataset"]).tolist()
print(f"Fetching templates from {len(requested_datasets)} datasets")
Copy link
Collaborator

Choose a reason for hiding this comment

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

a dreaded verbose option here?

Copy link
Member

Choose a reason for hiding this comment

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

Yep! should be safe here :)

Copy link
Collaborator

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

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

We can add those things after the PR is merged as well : )

s3_path = f"s3://spikeinterface-template-database/{dataset}/"
zarr_group = zarr.open_consolidated(s3_path, storage_options={"anon": True})

templates_object = Templates.from_zarr_group(zarr_group)

return templates_object


def fetch_templates_info() -> "pandas.DataFrame":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def fetch_templates_info() -> "pandas.DataFrame":
import functools
@functools.cache
def fetch_templates_info() -> "pandas.DataFrame":

https://docs.python.org/3/library/functools.html#functools.cache

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, this will fail if people still use python 3.8 : /

We can use functools.lru_cache(maxsize=1) instead if you want to support that but I would rather move forward to the bright future of python 3. 9 as minimal.

Copy link
Member

Choose a reason for hiding this comment

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

yes let's do that for the sorting analyzer release



def fetch_templates_from_database(dataset="test_templates.zarr") -> Templates:
def fetch_template_dataset(dataset="test_templates.zarr") -> Templates:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def fetch_template_dataset(dataset="test_templates.zarr") -> Templates:
@functools.cache
def fetch_template_dataset(dataset="test_templates.zarr") -> Templates:

import zarr
import numpy as np

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import functools

channel_locations = sorting_analyzer.get_channel_locations()[
sorting_analyzer.channel_ids_to_indices(channel_ids)
]
unit_colors = get_unit_colors(unit_ids)
Copy link
Member

Choose a reason for hiding this comment

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

Use get_some_colors and revert signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hybrid Related to Hybrid testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants