-
Notifications
You must be signed in to change notification settings - Fork 45
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
Create Table and helper functions to get position interval name from Interval list key and/or epoch #620
Conversation
… number when interval name not passed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. I had some comments which are more just things to think about but I didn't see anything that I'm sure would fail.
pos_valid_times[0][0], | ||
pos_valid_times[-1][-1], | ||
] # [pos valid time interval start, pos valid time interval end] | ||
if (time_interval[0] < pos_time_interval[0]) and ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the assumption here is that the position time interval is always contained within the interval (with some error). I think we have some other code just checking for any overlap in the intervals (in common interval) which might be more robust?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah looking for values from interval_list_intersect would be an easy way to check if there's any overlap. I don't know if there's use cases where you would want it to return a value for partial overlap, or scenarios where there could be multiple small position intervals in an epoch though? This solution seemed the most strict but more likely to give 1:1 mapping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There can be gaps in the position intervals due to loss of tracking but I agree that it probably won't be a problem
|
||
|
||
def get_pos_interval_list_names(nwb_file_name): | ||
return [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to note a different way this has been done (via regex which I don't necessarily like):
spyglass/src/spyglass/common/common_interval.py
Lines 115 to 119 in 482a652
pos_valid_times = ( | |
interval_list.set_index("interval_list_name") | |
.filter(regex=r"^pos \d+ valid times$", axis=0) | |
.valid_times | |
).sort_index(key=lambda index: [int(name.split()[1]) for name in index]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance you've tested this on Abhilasha's NWB file with only run epochs?
@schema | ||
class PositionIntervalMap(dj.Computed): | ||
definition = """ | ||
-> IntervalList |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth having a dependence on TaskEpoch to have epoch
as a primary key as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it makes any use cases trickier. It would require you to know the epoch at population, which may not be as obvious for derived interval_list_names (?). Epoch could also have a one:many relationship with interval_list_name, so you'd still need a way to select which to use when searching by epoch
|
||
# Check that each pos interval was matched to only one epoch | ||
if len(matching_pos_interval_list_names) > 1: | ||
print( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could potentially raise an Exception here instead
Addresses issue of position interval not always being "pos {epoch-1} valid times".
PositionIntervalMap
incommon_behav
composed ofIntervalList
primary keys andposition_interval_name
secondary keyconvert_epoch_interval_name_to_position_interval_name
function from the decoding core to make use of this table and moves it tocommon_behav
. Function populatesPositionIntervalMap
if map is not found, meaning shouldn't need to populate table elsewhere if you use this function.convert_epoch_interval_name_to_position_interval_name
can find position interval usingnwb_file_name
and eitherepoch
or `interval_list_name'