Skip to content

Extract events from spike glx #1383

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

Merged
merged 11 commits into from
Apr 22, 2024

Conversation

manimoh
Copy link
Contributor

@manimoh manimoh commented Jan 29, 2024

Trying to fix this

@alejoe91
Copy link
Contributor

Thanks @manimoh

This is great! Could you add a test for it? We have several SpikeGLX test files in the GIN epy_testing_data repo, and I'm sure (hope) at least one of them has digital events!

@apdavison apdavison added this to the 0.14.0 milestone Feb 23, 2024
@manimoh
Copy link
Contributor Author

manimoh commented Mar 23, 2024

Hi @alejoe91
Sorry for the late reply! I actually did end up looking at the SpikeGLX test files in the repo you mentioned, but none of them have digital events. I had shared a couple of files in a separate spikeinterface issue, if you could add one or both of those two the test files repo, I could write some tests using that.

@TheChymera TheChymera force-pushed the extract_events_from_SpikeGLX branch from 11c8495 to e152c5e Compare April 11, 2024 17:54
@TheChymera
Copy link
Contributor

@alejoe91 I pushed a test for it. Won't work right now, since there's no testing data.
Should we submit a PR for that on the gin repo directly?

@manimoh
Copy link
Contributor Author

manimoh commented Apr 11, 2024

DigitalChannelTest_g0.zip
@TheChymera This archive are the required files that will work for the tests that we wrote

@alejoe91
Copy link
Contributor

Thanks! @samuelgarcia can you upload to GIN?

@TheChymera
Copy link
Contributor

@alejoe91 I submitted a PR here → https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/pulls/125

Will fix the reference as soon as that's merged.

@alejoe91
Copy link
Contributor

Thanks! Can you add a line to the README (on the GIN PR) with the provenance of the file?

@TheChymera
Copy link
Contributor

@alejoe91
Copy link
Contributor

@alejoe91 done in https://gin.g-node.org/TheChymera/ephy_testing_data/commit/19f7708a8393b34821584922d1dc0ae499242c16

Merged ;)

@TheChymera
Copy link
Contributor

@alejoe91 good? 5c1d2d9

Also, why is the entities_to_test variable defined but never used? 🤔

@alejoe91
Copy link
Contributor

@TheChymera can you fix the conflicts? then it's should be ready!

@alejoe91
Copy link
Contributor

@TheChymera acually, there seem to be somthing wrong with the files you uploaded to GIN, see https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/src/master/spikeglx/DigitalChannelTest_g0/DigitalChannelTest_g0_t0.nidq.bin

This seems to arise from a missing sync command: https://gin.g-node.org/G-Node/Info/wiki/Annexed+Content

Can you make another PR with the fix?

@alejoe91
Copy link
Contributor

alejoe91 commented Apr 13, 2024

@TheChymera acually, there seem to be somthing wrong with the files you uploaded to GIN, see https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/src/master/spikeglx/DigitalChannelTest_g0/DigitalChannelTest_g0_t0.nidq.bin

This seems to arise from a missing sync command: https://gin.g-node.org/G-Node/Info/wiki/Annexed+Content

Can you make another PR with the fix?

@TheChymera acually, there seem to be somthing wrong with the files you uploaded to GIN, see https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/src/master/spikeglx/DigitalChannelTest_g0/DigitalChannelTest_g0_t0.nidq.bin

This seems to arise from a missing sync command: https://gin.g-node.org/G-Node/Info/wiki/Annexed+Content

Can you make another PR with the fix?

Actually tried one here: https://gin.g-node.org/NeuralEnsemble/ephy_testing_data/pulls/127

@alejoe91
Copy link
Contributor

@TheChymera the new test files were tested! But triggered some errors. Have you seen this before?

Copy link
Contributor

@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.

One of the tests was failing because of a typo (maybe a bad autocomplete? )

@alejoe91
Copy link
Contributor

Ok should be fixed now :)

@TheChymera entities_to_test is indeed used by the base testing class, and that was one source of failures because "standard" tests expect some analog signals too

@TheChymera
Copy link
Contributor

@alejoe91 thanks for fixing this up :) are we ready to go? ^^

@yarikoptic
Copy link
Contributor

I wonder why other CI workflows didn't run., e.g.

@alejoe91
Copy link
Contributor

@yarikoptic that workflow only runs if changes in core/project.toml/workflows ;)

Comment on lines 322 to 332
def _rescale_event_timestamp(self, event_timestamps, dtype, event_channel_index):
info = self.signals_info_dict[0, "nidq"] # There are no events that are not in the nidq stream
if not self._use_direct_evt_timestamps:
event_times = event_timestamps.astype(dtype) / float(info["sampling_rate"])
else: # Does this ever happen?
event_times = event_timestamps.astype(dtype)
return event_times

def _rescale_epoch_duration(self, raw_duration, dtype, event_channel_index):
return None

Copy link
Contributor

Choose a reason for hiding this comment

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

Rescaling event timestamps should always return time so I think the else comment is a good question. The idea is that the get event timestamps should return for whatever the data is in (ie frames, samples, seconds). Then if the data is not in time we use the rescale function to switch it to time. I guess my question is what is the point of using the flag use_direct_evt_timestamps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think as I was writing that piece of code, I did wonder about the necessity of using the flag because spikeglx never actually deals with timestamps on its own, and just sample numbers. So I do think we can just safely say

event_times = event_timestamps.astype(dtype) / float(info["sampling_rate"])
return event_times

without any use of conditionals involving that flag!

@zm711 zm711 removed the needs-input label Apr 16, 2024
@yarikoptic
Copy link
Contributor

@yarikoptic that workflow only runs if changes in core/project.toml/workflows ;)

makes sense.. but why not to sweep python versions for call-iotests which are the only ones triggered here?

@zm711
Copy link
Contributor

zm711 commented Apr 16, 2024

makes sense.. but why not to sweep python versions for call-iotests which are the only ones triggered here?

@yarikoptic, our iotests are currently being run from a cached conda environment to make them faster when dependencies don't change. This requires a fixed python version. If we got rid of the caching the env we could sweep versions, but then creating the new envs would take time. We actually just ran into an issue with testing where it autoupdated to python 3.12 which broke a lot of code during one of our PRs, so that would be a bit more work to improve the CI.

Copy link
Contributor

@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.

Sounds good to me. Just tagged to delete the flag and then make your edits to the rescale to simplify. @manimoh

@@ -111,6 +111,7 @@ def __init__(self, dirname="", load_sync_channel=False, load_channel_location=Fa
self.dirname = dirname
self.load_sync_channel = load_sync_channel
self.load_channel_location = load_channel_location
self._use_direct_evt_timestamps = None
Copy link
Contributor

Choose a reason for hiding this comment

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

We would delete this then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sweet. I triggered tests. Once we run these this looks good to me. I'll let @alejoe91 have the final say since he knows spikeglx better than me.

@TheChymera
Copy link
Contributor

@alejoe91 so, are we good? :3

@alejoe91
Copy link
Contributor

Yep! Thanks for implementing this @manimoh @TheChymera !!

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

Successfully merging this pull request may close these issues.

Digital Channels are not available in SpikeGLX's 'nidq' stream
6 participants