Skip to content

Commit

Permalink
notes
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Nov 6, 2024
1 parent 475358a commit cb9c23e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/fox_lab_to_nwb/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def add_to_nwbfile(
) -> None:

mat = read_mat(self.file_path)
rec_struct = mat["rec"]
daq_struct = rec_struct["daq"]
recording_structure = mat["rec"]
daq_struct = recording_structure["daq"]

timestamps = daq_struct["tstamps"]

Expand Down
25 changes: 22 additions & 3 deletions src/fox_lab_to_nwb/conversion_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,28 @@ Point-person: Amy Streets (axs2909@case.edu) and Kris Lea (kxl786@case.edu)

https://sites.google.com/site/cwrufoxlab/people

Paper is still not out, but according to the authors it should be similar to this one:

https://www.biorxiv.org/content/10.1101/2024.03.13.583703v1

The data is available here:



## Trial structure

Organized with folder hierarchy, with one folder for all trials of a single type/cross containing individual trial folders (ex. \Tshx18D07\Tshx18D07_240124_115923_f3_r1 where the cross is Tsh x 18D07 lines, the individual trial folder is “cross” _ “date” _ “time” _ “fly number” _ “trial repeat number”).
Folder name:
- Tshx18D07_240124_115923_f3_r1

Info here:
Tshx18D07 = cross
240124 = date
115923 = time
f3 = fly number
r1 = trial repeat number


Organized with folder hierarchy, with one folder for all trials of a single type/cross containing individual trial folders (ex. \Tshx18D07\Tshx18D07_240124_115923_f3_r1 where the

# DeepLabCut output files
config files missing but Video and DLC output files are available
Expand Down Expand Up @@ -81,16 +99,17 @@ Not yet available
### Tshx18D07_240124_115923_f3_r1.fly2
This is supposed to be a struct with DAQ data and the wingbeat analysis. Can't open it with matlab online unless extension is changed to .mat

Channel names:
Channel names:
- CamSync
- CamTrigger
- OptoTrigger
- LWingBeatAmp
- RWingBeatAmp
- WingBeatFreq
- LHutchen # What does Hutchen mean? Could be halteres?
- LHutchen
- RHutchen
- PTrigger
- WindTrigger

These can't be extracted with pyton from matlab because they are strings. Are they always the same order?

Expand Down
5 changes: 3 additions & 2 deletions src/fox_lab_to_nwb/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ NWBFile:
experimenter:
- Streets, Amy
- Lea, Kriss
- Fox, Jessica
surgery: TBD
Subject:
sex: M
species: Drosophila melanogaster # TODO: Figure this one out
sex: F
species: Drosophila melanogaster
description: fly
43 changes: 20 additions & 23 deletions src/fox_lab_to_nwb/streets_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
from fox_lab_to_nwb.behavior import BehaviorInterface


def run_trial_conversion(trial_data_folder: Path, output_dir_path: Optional[Path] = None, verbose: bool = True):
def run_trial_conversion(trial_folder_path: Path, output_dir_path: Optional[Path] = None, verbose: bool = True):

if verbose:
start_time = time.time()

if output_dir_path is None:
output_dir_path = Path.home() / "conversion_nwb"

# Parse metadta from the trial_data_folder name
# Parse metadta from the trial_folder_path name
# Define the correct parsing pattern
pattern = r"{cross}_{date}_{time}_f{fly_number}_r{trial_repeat_number}"
parsed_metadata = parse.parse(pattern, trial_data_folder.name)
parsed_metadata = parse.parse(pattern, trial_folder_path.name)

trial_repeat_number = parsed_metadata["trial_repeat_number"]
cross = parsed_metadata["cross"] # TODO, where in subject metadata should this be? Example Tshx18D07
Expand All @@ -39,46 +39,43 @@ def run_trial_conversion(trial_data_folder: Path, output_dir_path: Optional[Path
# Behavior interface
format = "fly2" # Authors said in email this might change
daq_file_name = f"{cross}_{session_date}_{session_time}_f{fly_number}_r{trial_repeat_number}.{format}"
file_path = trial_data_folder / daq_file_name
file_path = trial_folder_path / daq_file_name
behavior_interface = BehaviorInterface(file_path=file_path)

# Video Interface
# TODO: are the names of the video files always the same per trial? we need
# More trials to find out

side_cam_name = "SideCam_000000.avi"
file_path = trial_data_folder / side_cam_name
file_path = trial_folder_path / side_cam_name
side_cam_interface = VideoInterface(file_paths=[file_path], metadata_key_name="SideCam")

top_camera_name = "TOPCAM_000000.avi"
file_path = trial_data_folder / top_camera_name
file_path = trial_folder_path / top_camera_name

top_cam_interface = VideoInterface(file_paths=[file_path], metadata_key_name="TopCam")

# TODO: this is my name, see how authors refer to this camera
back_camera_name = "XZ_1_186.mp4"
haltere_camera_name = "XZ_1_186.mp4"

file_path = trial_data_folder / back_camera_name
back_cam_interface = VideoInterface(file_paths=[file_path], metadata_key_name="BackCam")
file_path = trial_folder_path / haltere_camera_name
haltere_cam_interface = VideoInterface(file_paths=[file_path], metadata_key_name="BackCam")

# DLC interface

top_cam_dlc_file_name = "TOPCAM_000000DLC_resnet50_antennatrackingMar11shuffle1_100000.h5"
top_cam_file_path = trial_folder_path / top_cam_dlc_file_name
top_cam_dlc_interface = DeepLabCutInterface(file_path=top_cam_file_path)

file_path = trial_data_folder / top_cam_dlc_file_name
top_cam_dlc_interface = DeepLabCutInterface(file_path=file_path)

back_cam_dlc_file_name = "XZ_1_186DLC_resnet50_haltereMar13shuffle1_100000.h5"
file_path = trial_data_folder / back_cam_dlc_file_name
back_cam_dlc_interface = DeepLabCutInterface(file_path=file_path)
haltere_cam_dlc_file_name = "XZ_1_186DLC_resnet50_haltereMar13shuffle1_100000.h5"
halter_cam_file_path = trial_folder_path / haltere_cam_dlc_file_name
haltere_cam_dlc_interface = DeepLabCutInterface(file_path=halter_cam_file_path)

data_interface = {
"Behavior": behavior_interface,
"SideCam": side_cam_interface,
"TopCam": top_cam_interface,
"BackCam": back_cam_interface,
"BackCam": haltere_cam_interface,
"DeepLabCutTopCam": top_cam_dlc_interface,
"DLCBackCamDlc": back_cam_dlc_interface,
"DeepLabCutHalterCam": haltere_cam_dlc_interface,
}

converter = ConverterPipe(data_interfaces=data_interface)
Expand All @@ -101,7 +98,7 @@ def run_trial_conversion(trial_data_folder: Path, output_dir_path: Optional[Path
# Run conversion, this adds the basic data to the NWBFile
conversion_options = {
"DeepLabCutTopCam": {"container_name": "PoseEstimationTopCam"},
"DLCBackCamDlc": {"container_name": "PoseEstimationBackCam"},
"DeepLabCutHalterCam": {"container_name": "PoseEstimationHaltereCam"},
}

converter.run_conversion(
Expand All @@ -127,7 +124,7 @@ def run_trial_conversion(trial_data_folder: Path, output_dir_path: Optional[Path
verbose = True
data_path = Path("/home/heberto/cohen_project/Sample data/Fox Lab")
assert data_path.exists(), f"Folder {data_path} does not exist"
trial_data_folder = data_path / "Tshx18D07_240124_115923_f3_r1"
assert trial_data_folder.exists(), f"Folder {trial_data_folder} does not exist"
trial_folder_path = data_path / "Tshx18D07_240124_115923_f3_r1"
assert trial_folder_path.exists(), f"Folder {trial_folder_path} does not exist"

run_trial_conversion(trial_data_folder=trial_data_folder, verbose=verbose)
run_trial_conversion(trial_folder_path=trial_folder_path, verbose=verbose)

0 comments on commit cb9c23e

Please sign in to comment.