Skip to content

Commit

Permalink
Merge pull request #4 from catalystneuro/video
Browse files Browse the repository at this point in the history
Video
  • Loading branch information
pauladkisson authored Sep 9, 2024
2 parents e871a87 + ee4a20d commit 8da7111
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ndx_events import EventTypesTable, EventsTable, Task, TimestampVectorData

from neuroconv.basedatainterface import BaseDataInterface
from neuroconv.utils import DeepDict
from neuroconv.utils import DeepDict, get_base_schema
from neuroconv.tools import nwb_helpers


Expand All @@ -26,6 +26,41 @@ def get_metadata(self) -> DeepDict:

return metadata

def get_metadata_schema(self) -> dict:
metadata_schema = super().get_metadata_schema()
metadata_schema["properties"]["Behavior"] = get_base_schema(tag="Behavior")
metadata_schema["properties"]["Behavior"]["properties"]["TimeSeries"] = {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
},
},
}
metadata_schema["properties"]["Behavior"]["properties"]["Events"] = {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
},
},
}
metadata_schema["properties"]["Behavior"]["properties"]["ValuedEvents"] = {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"description": {"type": "string"},
},
},
}
return metadata_schema

def add_to_nwbfile(self, nwbfile: NWBFile, metadata: dict):
# Read Data
file_path = self.source_data["file_path"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str,
recording_folder_path = data_dir_path / "Raw Ephys" / "m69_2023-10-31_17-24-15_Day1_A1"
sorting_folder_path = data_dir_path / "Processed Ephys" / "m69_2023-10-31_17-24-15_Day1_A1"
behavior_file_path = data_dir_path / "Behavior" / "m69_231031" / "raw_m69_231031_001.mat"
video_folder_path = data_dir_path / "Video" / "m69_231031"
video_file_paths = [
file_path for file_path in video_folder_path.glob("*.mp4") if not file_path.name.startswith("._")
]
video_file_paths = sorted(video_file_paths)
if stub_test:
output_dir_path = output_dir_path / "nwb_stub"
recording_folder_path = recording_folder_path.with_name(recording_folder_path.name + "_stubbed")
Expand All @@ -43,6 +48,12 @@ def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str,
source_data.update(dict(Behavior=dict(file_path=behavior_file_path)))
conversion_options.update(dict(Behavior=dict()))

# Add Video(s)
for i, video_file_path in enumerate(video_file_paths):
metadata_key_name = f"VideoCamera{i+1}"
source_data.update({metadata_key_name: dict(file_paths=[video_file_path], metadata_key_name=metadata_key_name)})
conversion_options.update({metadata_key_name: dict()})

converter = Schneider2024NWBConverter(source_data=source_data)

# Add datetime to conversion
Expand Down Expand Up @@ -74,6 +85,11 @@ def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str,
)
metadata["Ecephys"]["Device"] = editable_metadata["Ecephys"]["Device"]

# Overwrite video metadata
for i, video_file_path in enumerate(video_file_paths):
metadata_key_name = f"VideoCamera{i+1}"
metadata["Behavior"][metadata_key_name] = editable_metadata["Behavior"][metadata_key_name]

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ Behavior:
ValuedEvents:
- name: tuningTones
description: Times at which tuning tones are played to an animal after a behavioral experiment during ephys recording sessions.
VideoCamera1:
- name: video_camera_1
description: Three IR video cameras (AAK CA20 600TVL 2.8MM) are used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data if necessary.
unit: Frames
VideoCamera2:
- name: video_camera_2
description: Three IR video cameras (AAK CA20 600TVL 2.8MM) are used to monitor the experiments from different angles of interest, allowing for offline analysis of body movements, pupillometry, and other behavioral data if necessary.
unit: Frames

Sorting:
units_description: Neural spikes will be sorted offline using Kilosort 2.5 and Phy2 software and manually curated to ensure precise spike time acquisition.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
- TuningTones has a values field with integers, what does this correspond to?
- 'push' is basically some kind of trials table, but need descriptions for variables ex. ITI_respect?

## Video
- In research overview, 3 cameras are mentioned, but only 2 appear in example data. Missing camera? Or incorrect description?

## Data Requests
- Mice sexes
- Remaining data for Grant's project
Expand All @@ -13,3 +16,4 @@
- stereotactic coordinates of the whole probe
- Detailed description of the behavioral paradigm
- Description of lickometer and lever/treadmill quadrature encoder.
- Detailed description of temporal alignment procedure.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from neuroconv.datainterfaces import (
OpenEphysRecordingInterface,
PhySortingInterface,
VideoInterface,
)
from neuroconv.basedatainterface import BaseDataInterface

from schneider_lab_to_nwb.schneider_2024 import Schneider2024BehaviorInterface

Expand All @@ -15,4 +17,7 @@ class Schneider2024NWBConverter(NWBConverter):
Recording=OpenEphysRecordingInterface,
Sorting=PhySortingInterface,
Behavior=Schneider2024BehaviorInterface,
VideoCamera1=VideoInterface,
VideoCamera2=VideoInterface,
VideoCamera3=VideoInterface,
)

0 comments on commit 8da7111

Please sign in to comment.