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

Template loading issue and extensions documentation. #3494

Open
OlivierPeron opened this issue Oct 21, 2024 · 1 comment
Open

Template loading issue and extensions documentation. #3494

OlivierPeron opened this issue Oct 21, 2024 · 1 comment
Labels
core Changes to core module

Comments

@OlivierPeron
Copy link
Contributor

OlivierPeron commented Oct 21, 2024

Hi everyone,

I was recently experimenting with the analyzer extensions and found it challenging to locate the parameters for each extension. Perhaps I missed it, but I couldn't find any dedicated page or documentation listing this information. While the get_default_extension_params function from the SortingAnalyzer does provide default parameters, it doesn't offer the full range of available options.

I'm primarily raising this issue not because of that, but rather due to some problems I encountered while using templates. Similar issues might occur with other extensions, but I haven't tested those yet.

Specifically, I used 'median' as the operator to compute my templates from the waveforms, and I saved the template extension in my extension folder. The problem arises when the function get_dense_templates_array is called, as it assumes that templates were saved using the 'average' operator. Here's the relevant code:

if isinstance(one_object, Templates):
    templates_array = one_object.get_dense_templates()
elif isinstance(one_object, SortingAnalyzer):
    if return_scaled != one_object.return_scaled:
        raise ValueError(
            f"get_dense_templates_array: return_scaled={return_scaled} is not compatible; SortingAnalyzer has the opposite setting."
        )
    ext = one_object.get_extension("templates")
    if ext is not None:
        templates_array = ext.data["average"]
    else:
        raise ValueError("SortingAnalyzer requires the 'templates' extension to retrieve templates")
else:
    raise ValueError("Input must be either Templates or SortingAnalyzer")

A possible solution could be to check for the computed operator such as :

if ext is not None:
      operator = ext.params['operators'][0]
      templates_array = ext.data[operator]

Thanks again for all the work !

PERON Olivier

@alejoe91 alejoe91 added the core Changes to core module label Oct 21, 2024
@alejoe91
Copy link
Member

Hi @OlivierPeron

I think it woould be safest to do something like this:

    templates_array = ext.data.get("average") or ext.data.get("median")
    assert templates_array is not None, "Average or median templates have not been computed."

Do you feel like trying to make a pull request?

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

No branches or pull requests

2 participants