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

Add get_times() method to imaging classes #379

Open
h-mayorquin opened this issue Nov 5, 2024 · 2 comments
Open

Add get_times() method to imaging classes #379

h-mayorquin opened this issue Nov 5, 2024 · 2 comments

Comments

@h-mayorquin
Copy link
Collaborator

We have set_times:

def set_times(self, times: ArrayType) -> None:
"""Set the recording times (in seconds) for each frame.
Parameters
----------
times: array-like
The times in seconds for each frame.
Raises
------
ValueError
If the length of 'times' does not match the number of frames.
"""
num_frames = self.get_num_frames()
num_timestamps = len(times)
if num_timestamps != num_frames:
raise ValueError(
f"Mismatch between the number of frames and timestamps: "
f"{num_frames} frames, but {num_timestamps} timestamps provided. "
"Ensure the length of 'times' matches the number of frames."
)
self._times = np.array(times).astype("float64", copy=False)

In neuroconv we use this construct to get the times:
https://github.com/catalystneuro/neuroconv/blob/419ab11104ff9e67d63f6400aacb3e12081c90d1/src/neuroconv/tools/roiextractors/roiextractors.py#L534-L535

Maybe we should have a method that does this for us like in spikeinterface?

https://github.com/SpikeInterface/spikeinterface/blob/bfe9fb649b58c48d2a04949061154f75f8e08b1f/src/spikeinterface/core/baserecording.py#L429-L450

Thoughts?

@pauladkisson
Copy link
Member

We already have frame_to_time, which basically performs this function. But maybe it should be renamed? And/or maybe it should provide all the times by default?

@h-mayorquin
Copy link
Collaborator Author

h-mayorquin commented Nov 6, 2024

Let's not have function with the same name than the spikeinterface one but with a different signature and behavior. The second option would work for me though.

I would prefer to unify the extractor API and just follow spikeinterface here. get_times can be a wrapper around frame_to_time if code duplication is your concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants