Skip to content
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 facemap interace and aligned timestamps #11

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/higley_lab_to_nwb/benisty_2022/benisty_2022_convert_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str,
video_file_path = data_dir_path / session_id / f"{session_id}.avi"
source_data.update(dict(Video=dict(file_paths=[video_file_path], verbose=False)))
conversion_options.update(dict(Video=dict(stub_test=stub_test, external_mode=False)))


# Add Facemap outpt
video_file_path = data_dir_path / session_id / f"{session_id}.avi"
mat_file_path = data_dir_path / session_id / f"{session_id}_proc.mat"
source_data.update(
dict(
FacemapInterface=dict(mat_file_path=str(mat_file_path), video_file_path=str(video_file_path), verbose=False)
)
)

converter = Benisty2022NWBConverter(source_data=source_data)

# Add datetime to conversion
Expand All @@ -125,7 +134,9 @@ def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str,
metadata = dict_deep_update(metadata, editable_metadata)

# Run conversion
converter.run_conversion(metadata=metadata, nwbfile_path=nwbfile_path, conversion_options=conversion_options)
converter.run_conversion(
metadata=metadata, nwbfile_path=nwbfile_path, conversion_options=conversion_options, overwrite=True
)


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
nwb-conversion-tools==0.11.1 # Example of specific pinned dependecy
some-extra-package==1.11.3 # Example of another extra package that's necessary for the current conversion
roiextractors @ git+https://github.com/catalystneuro/roiextractors.git@8db5f9cb3a7ee5efee49b7fd0b694c7a8105519a # Github pinned dependency
roiextractors
neuroconv @ git+https://github.com/catalystneuro/neuroconv.git@facemap
ndx-facemap-motionsvd @ git+https://github.com/catalystneuro/ndx-facemap-motionsvd.git@main
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from higley_lab_to_nwb.benisty_2022.benisty_2022_spike2signals_interface import Benisty2022Spike2SignalsInterface
from higley_lab_to_nwb.benisty_2022.benisty_2022_imaginginterface import Benisty2022ImagingInterface

from neuroconv.datainterfaces import VideoInterface
from neuroconv.datainterfaces import VideoInterface, FacemapInterface
weiglszonja marked this conversation as resolved.
Show resolved Hide resolved


class Benisty2022NWBConverter(NWBConverter):
Expand All @@ -13,6 +13,7 @@ class Benisty2022NWBConverter(NWBConverter):
data_interface_classes = dict(
Spike2Signals=Benisty2022Spike2SignalsInterface,
Video=VideoInterface,
FacemapInterface=FacemapInterface,
ImagingBlueExcitationGreenChannel=Benisty2022ImagingInterface,
ImagingBlueExcitationRedChannel=Benisty2022ImagingInterface,
ImagingUVExcitationGreenChannel=Benisty2022ImagingInterface,
Expand All @@ -24,14 +25,16 @@ class Benisty2022NWBConverter(NWBConverter):
def temporally_align_data_interfaces(self):
ttlsignal_interface = self.data_interface_objects["Spike2Signals"]
video_interface = self.data_interface_objects["Video"]
facemap_interface = self.data_interface_objects["FacemapInterface"]
video_interface._timestamps = video_interface.get_timestamps()
stream_id = next(
(
stream_id
for stream_id, stream_name in ttlsignal_interface.stream_ids_to_names_map.items()
for stream_id, stream_name in ttlsignal_interface.ttl_stream_ids_to_names_map.items()
if stream_name == "TTLSignalPupilCamera"
),
None,
)
ttl_times = ttlsignal_interface.get_event_times_from_ttl(stream_id=stream_id)
video_interface.set_aligned_starting_time(ttl_times[0])
facemap_interface.set_aligned_starting_time(ttl_times[0])