-
Notifications
You must be signed in to change notification settings - Fork 190
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 hdf5 backend support forNwbRecordingExtractor
#2298
Add hdf5 backend support forNwbRecordingExtractor
#2298
Conversation
@h-mayorquin Overall this looks very good. I am a bit concerned about the electrical_series_name / electrical_series_location. I understand you are trying to maximize the chance that it will find the correct electrical series object, and provide helpful output when it is not found. But I think it's best to be explicit about the procedure that is used to determine this. Perhaps you could simplify wherever possible? And more importantly spell out the procedure in the docs for the class? |
@magland Thanks for taking a look. I added further explanation in the docstring concerning
Yes, so to describe it here. The intention is for It to iterate over all the groups in the hdf5 file and find the one which name matches with |
I did some changes in the last commit as changing all the behavior is too drastic. I instead moved to a factory pattern where the old behavior is called when a flag "fast_mode" is set to False. That is, if The advantages of the factory pattern are:
The disavantages are that is a tad more complex and it introduces more code to mantain. There is some code-duplication now between the I added tests for the two modes now. Also I feel unsatisfied with the name |
OK, I changed |
NwbRecordingExtractor
NwbRecordingExtractor
Co-authored-by: Alessio Buccino <[email protected]>
After a discussion with @alejoe91 we decided to change the name to "use_pynwb" and the default should be |
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.
Thansk for this amazing work @h-mayorquin
I have a couple of very minor final requests!
sampling_frequency = electrical_series["starting_time"].attrs["rate"] | ||
elif "timestamps" in electrical_series.keys(): | ||
t_start = electrical_series["timestamps"][0] | ||
sampling_frequency = 1 / np.median(np.diff(electrical_series["timestamps"][:1000])) |
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.
sampling_frequency = 1 / np.median(np.diff(electrical_series["timestamps"][:1000])) | |
sampling_frequency = 1 / np.median(np.diff(electrical_series["timestamps"][:samples_for_rate_estimation])) |
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.
Let's change this.
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.
I also think that the samples_for_rate_estimation
default is too large. I think tha 1000 samples should be OK.
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.
agreed. Can you change to 1000?
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.
Should be done.
@pytest.mark.parametrize("electrical_series_name", ["ElectricalSeries1", "ElectricalSeries2"]) | ||
def test_that_hdf5_and_pynwb_extractors_return_the_same_data(path_to_nwbfile, electrical_series_name): | ||
recording_extractor_hdf5 = NwbRecordingExtractor( | ||
path_to_nwbfile, | ||
electrical_series_name=electrical_series_name, | ||
use_pynwb=False, | ||
) | ||
|
||
recording_extractor_pynwb = NwbRecordingExtractor( | ||
path_to_nwbfile, | ||
electrical_series_name=electrical_series_name, | ||
use_pynwb=True, | ||
) | ||
|
||
check_recordings_equal(recording_extractor_hdf5, recording_extractor_pynwb) |
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.
Thanks!!!
Thanks @h-mayorquin and @alejoe91 ! |
Depends on #2294. This makes the NWB extraction faster as it avoids the nwb validation.
@magland If you have some time to sparse it would be great to get your pair of eyes.