Repository navigation
Fix raster plot handling of segment times where t_start is not zero. - #4790
Conversation
e322cac to
434d58e
Compare
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
41fa6e9 to
98143d1
Compare
8abc381 to
48ca1c9
Compare
aed7a7e to
25de7b4
Compare
6591e5b to
5ae61c4
Compare
5cf7398 to
da4456c
Compare
7b83d1e to
c000d5b
Compare
| color: str = "Gray", | ||
| clim: tuple[float, float] | None = None, | ||
| alpha: float = 1, | ||
| segment_index: int | list[int] | None = None, |
There was a problem hiding this comment.
This is unused in main, but I guess this is public facing and will need a deprecation warning? (although maybe not if its never used anyway)
ba9d6c4 to
7939950
Compare
2421b62 to
266d837
Compare
4a06096 to
eddf608
Compare
|
Thanks @alejoe91 this is now updated! |
| } | ||
|
|
||
|
|
||
| def get_segment_durations(sorting: BaseSorting, segment_indices: list[int] = None): |
There was a problem hiding this comment.
Can we move this to core.sorting_tools?
alejoe91
left a comment
There was a problem hiding this comment.
Hi @JoeZiminski
This looks great! One final request:
Can you move the get_segment_durations and estimate_segment_durations_from_spike_vector to sorting_tools? I think they should be core functions
Done in last commit :) |
|
apologies for delay, cheers @alejoe91! |
This PR updates the raster widgets which was not handling
t_start, and also patches the associatedget_segment_durationsfunction similarly.The previous implementation calculated spike times using the sample index and sampling frequency, but not incorporating
t_start. Similarly created durations for each segment, and used these in raster plots for things like drawing vertical lines betwen segments.This PR fixes by using the newer time-getting machinery for spike times, and replacing
durationswith a dictionary of start-stop times (tuples) per segment calledsegment_start_stop_times. The reason it's a dictionary not a list is because the segments to display can be sub-selected, and if these are not referred to explicitly it gets complicated as the segments are re-indexed in BaseRasterWidget.durationsis just removed, I assume that's okay as was only used internally.Now
get_segment_durationsalso returns thissegment_start_stop_times. Two things are a bit weird with this fuction, one the name is now not great because it returns two things. This has now been updated to check to see if the sorting has a recording, and if so get the start/stop times directly.In the plots below you can see the original issue / fix - in this example the recording has three segments each 10 seconds long starting at [5.0, 25, 50]. The raster plot however all start at
t=0and the segment boundaries are not correct (note motion plot only takes 1 segment).Before

After (images updated after change to axticklabels)
Code to produce plots below, note that the amplitude plots will not generate as show, as needs #4796
Test code