-
Notifications
You must be signed in to change notification settings - Fork 23
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
[Discussion] semantics of set_aligned_starting_time
#608
Comments
It's setting a shift factor - if no timestamps present, this defines the start time - if timestamps, those timestamps are unaligned or else why would you be using this method, therefore we shift by the constant starting time to become aligned |
Yeah, that's the problem to me, I don't think on the
Gross alignment vs fine alignment. The timestamps are fine I just want to set the correct start time because a video recording the behavior, for example, did not start until 20 seconds before a trial period and I want to move them there. Right now, I will need to extract the timestamps, modify them and use the |
There is no such separation in NWB There is only the vector of timestamps
if you need to extract it anyway, just perform whatever operations you need to when you set the full timestamps - no need to interact with any other method. The automated shifting is for interfaces that automatically fetch their vector, which may or may not be regular a priori, and determination of which convention (start time + rate or timestamps) occurs later on |
I don't understand your argument here. There is a
I don't need to extract it, I want to set the Software is about trade-offs. I gave you two positive points about the proposal. Could you give some possible cost of the proposal or the benefit of the status quo (i.e. making the method shift)? |
Setting what you call 'fine alignment' via the TTL should already be in the common clock, so why would you need to shift it by anything else? Maybe we're missing context here... Could you fully describe your current alignment setup and we can analyze if you're utilizing the methods correctly, and if so where the confusion of method names comes into play? |
Let me try this differently without the fine alingment vs gross alingment distinction. I am saying that maybe we should modify the semantics of the function so this assertion passes (currently it does not): from neuroconv.tools.testing.mock_interfaces import MockRecordingInterface
from pynwb.testing.mock.file import mock_NWBFile
recording_interface_1 = MockRecordingInterface(num_channels=4, sampling_frequency=30_000.0, durations=[1])
recording_interface_2 = MockRecordingInterface(num_channels=4, sampling_frequency=30_000.0, durations=[1])
timestamps2 = 10 + recording_interface_1.get_timestamps()
recording_interface_2.recording_extractor.set_times(times=timestamps2, with_warning=False)
starting_time_of_recording_2 = 5.0
recording_interface_2.set_aligned_segment_starting_times(aligned_segment_starting_times=[starting_time_of_recording_2])
nwbfile = mock_NWBFile()
metdata = recording_interface_2.get_metadata()
recording_interface_2.add_to_nwbfile(nwbfile=nwbfile, metadata=metdata)
nwbfile.acquisition["ElectricalSeries"].starting_time
assert starting_time_of_recording_2 == nwbfile.acquisition["ElectricalSeries"].starting_time The proposal is: And I am asking you is:
|
Thanks for providing at least one example to work with However, the call pattern in the example is exactly what worries be because I see it as a misapplication of the methods More complicated than it needs to beIf you take a look at timestamps2 = 10 + recording_interface_1.get_timestamps()
recording_interface_2.recording_extractor.set_times(times=timestamps2, with_warning=False)
starting_time_of_recording_2 = 5.0
recording_interface_2.set_aligned_segment_starting_times(aligned_segment_starting_times=[starting_time_of_recording_2]) why did you not add your I'd say the current example is more complicated than it needs to be to achieve the desired result, but that's the next point. Expectations vs. RealityThanks for providing the assertion you're going for - and this related to what I see as the bigger problem, though you haven't brought it up yet so I'm trying to guide you to it - there is absolutely no guarantee from any of the details in the example above (aside from implicit knowledge about the Mock design but lets abstract away to a real world recording interface) that you will even end up with a Though even if we restrict to the overly complicated example, and make the hard assumption that all timestamps have been regular, I would say that the expected EducationHardest thing about temporal alignment is educating the usage of it, regardless of what the methods are named. Did the docs fail you in some way? Can they be improved to communicate this expected usage better? GeneralityOne reason I am so reluctant to revisit a complete backcompatability break just to rename one of these methods is because they apply to all 40+ interfaces we support, and in several of them they may or may not have the exact behavior you expected here - meaning it's not a problem Currently your issue is with recording interfaces (along with their very specific additional 'segment' related methods), can you list out all the others where you'd see this occur? What is the symptom of the larger problem? Do you know what it is and how to fix it? |
Also Real world exampleWe try to limit our design and application of the temporal alignment methods to relate the most to real world setups instead of contriving all variety of edge cases ourselves Is your example inspired in any way by a recent conversion? Have you read about the setup anywhere? What are all the various time shifts related to (parsed by TTLs? What is the TTL setup? etc.) No reason to do extra engineering for a case unless it is actually needed in the real world |
From discussion: much internal confusion has been alleviated but passed up to how we represent Real life example: first timestamp of FicTrac is actually there are two cases of TTLs that could be sent to align to a common clock from the camera; a TTL sent when camera turns on (in which case our alignment by a starting time method works entirely as expected and intuitive); or a TTL sent on first frame capture, which is the more common case observed so far in practice But in that second case our alignment approach becomes fairly confusing because we would need to correct for the amount of pre-shift of the format specific timestamps relative to their device starting time A better approach might be to coerce starting times to be relative to the first piece of data captured, such that all data streams in NeuroConv interfaces reliably start from zero in their own time basis and therefore simplify the act of aligning different streams to a single clock, which would directly lead to a consistent understanding of the semantic behavior as requested above Before proceeding however, I think we should take stock of what other cases we know of format-specific timestamps that do not start from zero and if the coercion might cause any problems as far as we can foresee |
Thanks for the summary of our discussion @CodyCBakerPhD. |
So if I read this correctly, it sounds like @h-mayorquin you are noting that |
That is correct. My opinion is that a method named Having two methods and making the current That said, I think that @CodyCBakerPhD did present to me some complexities that made me decrease my confidence on my take. Sadly, I am falling to recall those right now. |
@h-mayorquin I think that is semantically fine to adjust all |
Thanks for looking into this again. I need to re-read it. |
OK. That make sense, I will do this. |
This probably should have come up before but it escaped me back then. The current function for
set_aligned_starting_time
shifts the timestamps:neuroconv/src/neuroconv/basetemporalalignmentinterface.py
Lines 58 to 69 in a239c27
That is, if your timestamps are currently
[1, 2, 3, 4]
and thestarting_time
is3
then the resulting timestamps of the interface will be[4, 5, 6, 7]
. We have shifted everything, in fact, that's how we call the test:neuroconv/src/neuroconv/tools/testing/data_interface_mixins.py
Lines 175 to 185 in a239c27
But the way that I am feeling now when working with this as a user is that after using
set_aligned_starting_time
the resulting timestamps should start from the setstarting_time
. That is, I would have expected the result above to be[3, 4, 5, 6]
. That way, when the interface write the timestamps, the starting time will be in fact3
and not4
as it is currently.It appears to me that the current method is shifting and not setting. What do you guys think?
The text was updated successfully, but these errors were encountered: