catalystneuro / clandinin-lab-to-nwb

MIT License
0 stars 0 forks source link

Add session start times #8

Closed alessandratrapani closed 1 year ago

alessandratrapani commented 1 year ago

Add 4 different interfaces: one for each modality (functional or anatomical) + channel (Green and Red) combination

h-mayorquin commented 1 year ago

OK, writing it here:

Within the metadata of the converter (that collects the metadata from all the interfaces) you have now two entries for the photon series:

metadata["Ophys"]["TwoPhotonSeries"]
[{'name': 'FunctionalGreenTwoPhotonSeries', 'description': 'Imaging data acquire...ng readout', 'unit': 'px', 'imaging_plane': 'ImagingPlane', 'dimension': [...], 'format': '.nii', 'scan_line_rate': 15833.056254848874, 'field_of_view': [...]}, {'name': 'FunctionalRedTwoPhotonSeries', 'description': 'Imaging data acquire...istration.', 'unit': 'px', 'imaging_plane': 'ImagingPlane', 'dimension': [...], 'format': '.nii', 'scan_line_rate': 15833.056254848874, 'field_of_view': [...]}]
len(metadata["Ophys"]["TwoPhotonSeries"])
2

When you add the specific interface to the nwb file, you need to say from which of those two entries the metada will be used:

https://github.com/catalystneuro/neuroconv/blob/6164f98c8d271c5432cc45d4c5c745b15721060c/src/neuroconv/datainterfaces/ophys/baseimagingextractorinterface.py#L101-L125

Check the photon_series_index value there whose default is 0. This is the reason that you series is written with the same name twice. I modified this in the last commit so it should be fixed.

Now, this behavior is not very discoverably and in my opinion not well documented. The problem stems from the fact that while our metadata and data extraction methods flow through two different pipelines (the data goes through the extractor whereas the metadata is handled with the get_metadata function) they are very coupled at the implementation level. I don't know how to solve this but at least we should document it.

h-mayorquin commented 1 year ago

The only thing left to do here is to fix the convert script so it correctly fetches all the data from one session.

h-mayorquin commented 1 year ago

This PR now is about adding the session start times correctly for the interfaces.