-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from catalystneuro/neuroconv_interfaces
Adds Interfaces for SpikeGadgets and Video
- Loading branch information
Showing
10 changed files
with
243 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
from .olson_2024behaviorinterface import Olson2024BehaviorInterface | ||
from .olson_2024nwbconverter import Olson2024NWBConverter | ||
from .olson_2024_behavior_interface import Olson2024BehaviorInterface | ||
from .olson_2024_spike_gadgets_recording_interface import Olson2024SpikeGadgetsRecordingInterface | ||
from .olson_2024_nwbconverter import Olson2024NWBConverter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 25 additions & 27 deletions
52
src/jadhav_lab_to_nwb/olson_2024/olson_2024_convert_session.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,67 @@ | ||
"""Primary script to run to convert an entire session for of data using the NWBConverter.""" | ||
from pathlib import Path | ||
from typing import Union | ||
import datetime | ||
from zoneinfo import ZoneInfo | ||
import shutil | ||
|
||
from neuroconv.utils import load_dict_from_file, dict_deep_update | ||
|
||
from jadhav_lab_to_nwb.olson_2024 import Olson2024NWBConverter | ||
|
||
|
||
def session_to_nwb(data_dir_path: Union[str, Path], output_dir_path: Union[str, Path], stub_test: bool = False): | ||
def session_to_nwb(data_dir_path: str | Path, output_dir_path: str | Path, stub_test: bool = False): | ||
|
||
data_dir_path = Path(data_dir_path) | ||
output_dir_path = Path(output_dir_path) | ||
if stub_test: | ||
output_dir_path = output_dir_path / "nwb_stub" | ||
output_dir_path.mkdir(parents=True, exist_ok=True) | ||
|
||
session_id = "subject_identifier_usually" | ||
session_id = "sample_session" | ||
nwbfile_path = output_dir_path / f"{session_id}.nwb" | ||
|
||
source_data = dict() | ||
conversion_options = dict() | ||
|
||
# Add Recording | ||
source_data.update(dict(Recording=dict())) | ||
# Add Ephys | ||
file_path = data_dir_path / f"{data_dir_path.name}.rec" | ||
source_data.update(dict(Recording=dict(file_path=file_path))) | ||
conversion_options.update(dict(Recording=dict(stub_test=stub_test))) | ||
|
||
# Add Sorting | ||
source_data.update(dict(Sorting=dict())) | ||
conversion_options.update(dict(Sorting=dict())) | ||
|
||
# Add Behavior | ||
source_data.update(dict(Behavior=dict())) | ||
conversion_options.update(dict(Behavior=dict())) | ||
# Add Video | ||
file_paths = [data_dir_path / f"{data_dir_path.name}.1.h264"] | ||
source_data.update(dict(Video=dict(file_paths=file_paths))) | ||
conversion_options.update(dict(Video=dict())) | ||
|
||
converter = Olson2024NWBConverter(source_data=source_data) | ||
|
||
# Add datetime to conversion | ||
metadata = converter.get_metadata() | ||
datetime.datetime( | ||
year=2020, month=1, day=1, tzinfo=ZoneInfo("US/Eastern") | ||
) | ||
date = datetime.datetime.today() # TO-DO: Get this from author | ||
metadata["NWBFile"]["session_start_time"] = date | ||
metadata["NWBFile"]["session_start_time"] = datetime.datetime(2023, 5, 3, 11, 26, 42, tzinfo=ZoneInfo("US/Eastern")) | ||
|
||
# Update default metadata with the editable in the corresponding yaml file | ||
editable_metadata_path = Path(__file__).parent / "olson_2024_metadata.yaml" | ||
editable_metadata = load_dict_from_file(editable_metadata_path) | ||
metadata = dict_deep_update(metadata, editable_metadata) | ||
|
||
metadata["Subject"]["subject_id"] = "a_subject_id" # Modify here or in the yaml file | ||
|
||
# Run conversion | ||
converter.run_conversion(metadata=metadata, nwbfile_path=nwbfile_path, conversion_options=conversion_options) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
# Parameters for conversion | ||
data_dir_path = Path("/Directory/With/Raw/Formats/") | ||
output_dir_path = Path("~/conversion_nwb/") | ||
stub_test = False | ||
|
||
session_to_nwb(data_dir_path=data_dir_path, | ||
output_dir_path=output_dir_path, | ||
stub_test=stub_test, | ||
) | ||
data_dir_path = Path( | ||
"/Volumes/T7/CatalystNeuro/Jadhav/SubLearnProject/SL18_D19/SL18_D19_S01_F01_BOX_SLP_20230503_112642" | ||
) | ||
output_dir_path = Path("/Volumes/T7/CatalystNeuro/Jadhav/conversion_nwb") | ||
stub_test = True | ||
|
||
if output_dir_path.exists(): | ||
shutil.rmtree(output_dir_path, ignore_errors=True) | ||
|
||
session_to_nwb( | ||
data_dir_path=data_dir_path, | ||
output_dir_path=output_dir_path, | ||
stub_test=stub_test, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,47 @@ | ||
NWBFile: | ||
related_publications: | ||
https://doi.org/### or link to APA or MLA citation of the publication | ||
session_description: | ||
A rich text description of the experiment. Can also just be the abstract of the publication. | ||
institution: Institution where the lab is located | ||
institution: Brandeis University | ||
lab: Jadhav | ||
experimenter: | ||
- Last, First Middle | ||
- Last, First Middle | ||
|
||
Subject: | ||
description: Long Evans Rat | ||
genotype: Wild Type | ||
sex: M | ||
species: Rattus norvegicus | ||
age: TBD # in ISO 8601, such as "P1W2D" | ||
sex: TBD # One of M, F, U, or O | ||
subject_id: SL18 | ||
weight: 467g | ||
|
||
Ecephys: | ||
Device: | ||
- name: ProbeNameTBD | ||
description: ProbeDescriptionTBD | ||
manufacturer: ProbeManufacturerTBD | ||
TrodeGroups: | ||
- name: CA1_R | ||
location: Right hippocampal subfield CA1 | ||
device: ProbeNameTBD | ||
nTrodes: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,60,61,62,63,64] | ||
- name: CA1_L | ||
location: Left hippocampal subfield CA1 | ||
device: ProbeNameTBD | ||
nTrodes: [12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27] | ||
- name: SUB_L | ||
location: Left Subiculum | ||
device: ProbeNameTBD | ||
nTrodes: [28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43] | ||
- name: SUB_R | ||
location: Right Subiculum | ||
device: ProbeNameTBD | ||
nTrodes: [44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59] | ||
ElectricalSeries: | ||
- name: ElectricalSeries | ||
description: Raw acquisition of extracellular electrophysiology data recorded by SpikeGadgets. | ||
|
||
Behavior: | ||
Videos: | ||
- name: Video SL18_D19_S01_F01_BOX_SLP_20230503_112642.1 | ||
description: Video of the rat in the box. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
src/jadhav_lab_to_nwb/olson_2024/olson_2024_nwbconverter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
"""Primary NWBConverter class for this dataset.""" | ||
from neuroconv import NWBConverter | ||
from neuroconv.datainterfaces import ( | ||
SpikeGLXRecordingInterface, | ||
PhySortingInterface, | ||
) | ||
from neuroconv.datainterfaces import VideoInterface | ||
|
||
from jadhav_lab_to_nwb.olson_2024 import Olson2024BehaviorInterface | ||
from jadhav_lab_to_nwb.olson_2024 import Olson2024BehaviorInterface, Olson2024SpikeGadgetsRecordingInterface | ||
|
||
|
||
class Olson2024NWBConverter(NWBConverter): | ||
"""Primary conversion class for my extracellular electrophysiology dataset.""" | ||
|
||
data_interface_classes = dict( | ||
Recording=SpikeGLXRecordingInterface, | ||
Sorting=PhySortingInterface, | ||
Behavior=Olson2024BehaviorInterface, | ||
Recording=Olson2024SpikeGadgetsRecordingInterface, | ||
Video=VideoInterface, | ||
) |
Oops, something went wrong.