Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

Method for extract metada from nwb to make our round trip testing more complete #478

Open
h-mayorquin opened this issue Apr 25, 2022 · 4 comments
Assignees
Labels
discussion Let's talk about it low priority Not currently essential for any projects but would be great for a contributor to work on testing

Comments

@h-mayorquin
Copy link
Collaborator

Right now, our ecephys tests with data, the ones in test_gin_ecephys mainly compare the traces as written from the recording extractors.

check_recordings_equal(RX1=recording, RX2=nwb_recording, check_times=False, return_scaled=False)
check_recordings_equal(RX1=recording, RX2=nwb_recording, check_times=False, return_scaled=True)
# Technically, check_recordings_equal only tests a snippet of data. Above tests are for metadata mostly.
# For GIN test data, sizes should be OK to load all into RAM even on CI
npt.assert_array_equal(
x=recording.get_traces(return_scaled=False), y=nwb_recording.get_traces(return_scaled=False)
)
else:
# Spikeinterface behavior is to load the electrode table channel_name property as a channel_id
nwb_recording = NwbRecordingExtractorSI(file_path=nwbfile_path)
if "channel_name" in recording.get_property_keys():
renamed_channel_ids = recording.get_property("channel_name")
else:
renamed_channel_ids = recording.get_channel_ids().astype("str")
recording = recording.channel_slice(
channel_ids=recording.get_channel_ids(), renamed_channel_ids=renamed_channel_ids
)
check_recordings_equal_si(RX1=recording, RX2=nwb_recording, return_scaled=False)
# This can only be tested if both gain and offest are present
if recording.has_scaled_traces() and nwb_recording.has_scaled_traces():
check_recordings_equal_si(RX1=recording, RX2=nwb_recording, return_scaled=True)

Whereas the corresponding tests for sorting extractor mainly compares the output of the sorting object:

sf = sorting.get_sampling_frequency()
if sf is None: # need to set dummy sampling frequency since no associated acquisition in file
sf = 30000
sorting.set_sampling_frequency(sf)
nwb_sorting = NwbSortingExtractor(file_path=nwbfile_path, sampling_frequency=sf)
check_sortings_equal(SX1=sorting, SX2=nwb_sorting)

That is, of the components of the nwb_file, our test cover mostly the effects of the recording extractors and sorters ignoring the metadata.

I am wondering on whether it would be a good idea to create a method get_metadata for nwb files so we can also compare the get_metadata method of the interface with the data as it is written in the nwb file.

Does this makes sense? is there some obvious hurdle that I am not seeing or something that I am missing?

@h-mayorquin h-mayorquin added discussion Let's talk about it testing labels Apr 25, 2022
@h-mayorquin h-mayorquin self-assigned this Apr 25, 2022
@bendichter
Copy link
Collaborator

are you able to follow the form here?

@CodyCBakerPhD
Copy link
Member

(a) Yes, we need many more tests for checking metadata, that is true. Follow Bens established format for the Neuralynx/Neuroscope.

(b) Getting a metadata dict that matches our schema but constructed from a written NWBFile could indeed be nice, but I wouldn't put it at a high priority. For the tests Ben mentioned, it's so few items that doing manual direct assertions are fine for now.

(c) Why is this issue in the buzsaki repo? Let me see if I can do a fancy issue transfer.

@CodyCBakerPhD CodyCBakerPhD transferred this issue from catalystneuro/buzsaki-lab-to-nwb Apr 25, 2022
@h-mayorquin
Copy link
Collaborator Author

h-mayorquin commented Apr 25, 2022

are you able to follow the form here?

Yes, that's the one I am trying to follow right now.
I am thinking thought that the tests that we are adding over there test that the functions produce the right output.

The idea that I have on mind is to make the round-trip more complete by testing that the metadata is written as expected.

I don't know why I opened this on Buzsaki. A lapse, thanks @CodyCBakerPhD for writing in the right place.

@bendichter
Copy link
Collaborator

The problem is that metadata is pretty unique per input data type so it's tough to put in one big parallel structure

@h-mayorquin h-mayorquin added the low priority Not currently essential for any projects but would be great for a contributor to work on label Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion Let's talk about it low priority Not currently essential for any projects but would be great for a contributor to work on testing
Projects
None yet
Development

No branches or pull requests

3 participants