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 structure for aggregated data AggregatedBinnedAlignedSpikes #16

Merged
merged 11 commits into from
Aug 21, 2024

Conversation

h-mayorquin
Copy link
Collaborator

@h-mayorquin h-mayorquin commented Aug 8, 2024

First draft/ proof of concept of an structure to get aggregated data for many events (i.e. different stimuli or events). This is an idea proposed by @bendichter and I am calling it here AggregatedBinnedAlignedSpikes

I added some tests for the basic constructor and a method for getting data corresponding to a specific event aggregated_binnned_align_spikes.get_data_for_stimuli(event_index=0)

One point that I am still not sure about is how to manage timestamps. BinnedAlignedSpikes has a timestamps that stores the times at which the single event for which the data is obtained ocurred.

We could use the same index approach that we use for the data here that we use for the timestamps but then either we would have the tiemestamps to be non-monotric or we would need to re-order the data once the user passess it to us. Thinking on how to handle this, so far the structure does not have timestamps.

TO-DO

  • Add examples to the readme
  • Discuss timestamps
  • Add round-trip tests.

@h-mayorquin h-mayorquin requested a review from bendichter August 8, 2024 21:19
@h-mayorquin h-mayorquin self-assigned this Aug 8, 2024
@bendichter
Copy link
Contributor

I think the aggregated events should be in temporal order, so the timestamps would be in order.

Another approach would be to put them in order by condition first and by time second. That ordering would in theory allow you to write code that selects trials of a specific type more efficiently, but in practice such code would be over-engineered anyway and would probably only save milliseconds in practice.

@h-mayorquin
Copy link
Collaborator Author

OK, so if we with the first approach we can do two things:

  1. We asked the user to pass the timestamps already sorted, which in turn implies they have to sort their data and the event indices. The downside of this is that we are making it more complicated for them to user they interface which we can ameliorate with some documentation or a helper function.
  2. We do this inside the function, we can easily get the timestamps and use the argsorted indices to keep them everything in check insides. The downside of this is that it modifies the order data of the user implictly so it might lead to annoying surprises.

I am leaning to 1 but if you have other consideration that might be escaping me I am all ears.

@h-mayorquin h-mayorquin marked this pull request as ready for review August 14, 2024 18:29
milliseconds_from_event_to_first_bin=milliseconds_from_event_to_first_bin,
data=data, # Shape (number_of_units, aggregated_events_counts, number_of_bins)
timestamps=timestamps, # As many timestamps as the second dimension of data
event_indices=event_indices, # An index indicating which event each of the counts corresponds to
Copy link
Contributor

Choose a reason for hiding this comment

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

what are you indexing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe stimulus_id would be better


The `aggregated_events_counts` represents the total number of repetitions for all the events being aggregated. For example, if data is being aggregated from two stimuli where the first stimulus appeared twice and the second appeared three times, the aggregated_events_counts would be 5.

The `event_indices` is an indicator vector that should be constructed so that `data[:, event_indices == event_index, :]` corresponds to the binned spike counts around the event with the specified event_index. You can retrieve the same data using the convenience method `aggregated_binned_aligned_spikes.get_data_for_event(event_index)`.
Copy link
Contributor

@bendichter bendichter Aug 19, 2024

Choose a reason for hiding this comment

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

Try not to confuse the terms "event" and "stimulus". You have a stimulus index, not an event index.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you thinking that this structure is only for aggregating stimulus? I think that would simplify the language but the other structure in the extension is not only for stimulus but for events, trials, etc.

@h-mayorquin
Copy link
Collaborator Author

OK. So we discussed in the last meeting that we will focus this on the dicarlo case for binning spikes over multiple stimulus. We will dispose of the need for the two structures. I will merge this and do another PR with the requested changes.

@h-mayorquin h-mayorquin merged commit 3247ad5 into main Aug 21, 2024
30 checks passed
@h-mayorquin h-mayorquin deleted the add_structure_for_aggregated_data branch August 21, 2024 16:12
@h-mayorquin h-mayorquin mentioned this pull request Aug 21, 2024
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.

2 participants