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

Follow up #9 #12

Merged
merged 2 commits into from
Jul 1, 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
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def add_binary_signals(self, nwbfile: NWBFile, metadata: dict):

event_dfs = []
for event_name in ["lick", "reward", "stimulus_led", "stimulus_sound"]:
if event_name not in behavior_data:
continue
start_times, end_times = self._get_start_end_times(binary_event_data=behavior_data[event_name])
if not len(start_times):
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def dual_wavelength_session_to_nwb(
ttl_file_path=ttl_file_path,
ttl_stream_name=ttl_stream_names[0],
motion_corrected_imaging_file_path=motion_corrected_imaging_file_paths[0],
behavior_file_path=behavior_file_paths[0],
stub_test=stub_test,
)

Expand Down Expand Up @@ -111,6 +112,11 @@ def dual_wavelength_session_to_nwb(
session_folder_path / "R600_AP9_117_crop_MC_ROIs_new.mat",
]

behavior_file_paths = [
session_folder_path / "chatdat600_AP9_470_570_2021.08.21_10.48.07_aligned_ttlIn1_movie1.mat",
session_folder_path / "chatdat600_AP9_470_570_2021.08.21_10.48.07_aligned_ttlIn2_movie1.mat",
]

ttl_file_path = session_folder_path / "chatdat600_AP9_470_570_2021.08.21_10.48.07.mat"
ttl_stream_names = ["ttlIn1", "ttlIn2"]

Expand All @@ -130,6 +136,7 @@ def dual_wavelength_session_to_nwb(
fiber_locations_file_path=fiber_locations_file_path,
excitation_wavelengths_in_nm=excitation_wavelengths_in_nm,
indicators=indicators,
behavior_file_paths=behavior_file_paths,
nwbfile_path=nwbfile_path,
stub_test=stub_test,
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ def single_wavelength_session_to_nwb(
indicator: str,
ttl_file_path: Union[str, Path],
ttl_stream_name: str,
behavior_file_path: Union[str, Path],
behavior_file_path: Optional[Union[str, Path]] = None,
motion_corrected_imaging_file_path: Optional[Union[str, Path]] = None,
frame_indices: Optional[List[int]] = None,
nwbfile_path: Optional[Union[str, Path]] = None,
nwbfile: Optional[NWBFile] = None,
behavior_avi_file_path: Union[str, Path] = None,
sampling_frequency: float = None,
stub_test: bool = False,
) -> NWBFile:
Expand Down Expand Up @@ -58,7 +57,7 @@ def single_wavelength_session_to_nwb(
An in-memory NWBFile object to add the data to. If None, a new NWBFile object will be created.
motion_corrected_imaging_file_path : Union[str, Path]
The path to the .tif file containing the motion corrected imaging data.
behavior_file_path : Union[str, Path]
behavior_file_path : Union[str, Path], optional
The path to the .mat file containing the processed behavior data.
nwbfile_path : Union[str, Path]
The path to the NWB file to be created.
Expand Down Expand Up @@ -92,12 +91,12 @@ def single_wavelength_session_to_nwb(
conversion_options.update(dict(FiberPhotometry=dict(stub_test=stub_test)))

# Add motion corrected imaging data
if sampling_frequency is None:
ome_metadata = extract_ome_metadata(file_path=raw_imaging_file_path)
parsed_metadata = parse_ome_metadata(metadata=ome_metadata)
sampling_frequency = parsed_metadata["sampling_frequency"]
if motion_corrected_imaging_file_path is not None:
# We need the sampling frequency from the raw imaging data
if sampling_frequency is None:
ome_metadata = extract_ome_metadata(file_path=raw_imaging_file_path)
parsed_metadata = parse_ome_metadata(metadata=ome_metadata)
sampling_frequency = parsed_metadata["sampling_frequency"]
source_data.update(
dict(
ProcessedImaging=dict(
Expand Down Expand Up @@ -126,8 +125,9 @@ def single_wavelength_session_to_nwb(
conversion_options.update(dict(Segmentation=dict(stub_test=stub_test)))

# Add behavior
source_data.update(dict(Behavior=dict(file_path=str(behavior_file_path))))
conversion_options.update(dict(Behavior=dict(stub_test=stub_test)))
if behavior_file_path is not None:
source_data.update(dict(Behavior=dict(file_path=str(behavior_file_path))))
conversion_options.update(dict(Behavior=dict(stub_test=stub_test)))

# Add behavior camera recording (optional)
subject_id = raw_fiber_photometry_file_path.parent.parent.name
Expand Down
Loading