diff --git a/src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py b/src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py index 2dc0693..6fadbc0 100644 --- a/src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py +++ b/src/cai_lab_to_nwb/zaki_2024/zaki_2024_convert_session.py @@ -22,7 +22,7 @@ def get_miniscope_folder_path(folder_path: Union[str, Path]): miniscope_name = general_metadata["miniscopes"][0] return folder_path / miniscope_name.replace(" ", "_") else: - print("No Miniscope data found at {}".format(folder_path)) + print(f"No Miniscope data found at {folder_path}") return None @@ -41,7 +41,7 @@ def session_to_nwb( include_behavioral_video: bool = True, include_eeg_emg_signals: bool = True, ): - print("Converting session {}".format(session_id)) + print(f"Converting session {session_id}") if verbose: start = time.time() @@ -62,6 +62,7 @@ def session_to_nwb( else: experiment_dir_path = data_dir_path / "Ca_EEG_Experiment" / subject_id / (subject_id + "_Sessions") / session_id include_eeg_emg_signals = False + include_sleep_classification = False # Add Imaging folder_path = experiment_dir_path / date_str / time_str @@ -69,14 +70,20 @@ def session_to_nwb( if miniscope_folder_path is not None and include_imaging: source_data.update(dict(MiniscopeImaging=dict(folder_path=miniscope_folder_path))) conversion_options.update(dict(MiniscopeImaging=dict(stub_test=stub_test))) + elif verbose and not include_imaging: + print(f"Miniscope data will not be included for session {session_id}") + elif verbose and miniscope_folder_path is None: + print(f"No Miniscope data found at {miniscope_folder_path}") # Add Segmentation minian_folder_path = data_dir_path / "Ca_EEG_Calcium" / subject_id / session_id / "minian" if minian_folder_path.is_dir() and include_imaging: source_data.update(dict(MinianSegmentation=dict(folder_path=minian_folder_path))) conversion_options.update(dict(MinianSegmentation=dict(stub_test=stub_test))) - elif verbose: - print("No Minian data found at {}".format(minian_folder_path)) + elif verbose and not include_imaging: + print(f"Minian data will not be included for session {session_id}") + elif verbose and not minian_folder_path.is_dir(): + print(f"No Minian data found at {minian_folder_path}") # Add Motion Correction motion_corrected_video = minian_folder_path / "minian_mc.mp4" @@ -85,16 +92,20 @@ def session_to_nwb( dict(MinianMotionCorrection=dict(folder_path=minian_folder_path, video_file_path=motion_corrected_video)) ) conversion_options.update(dict(MinianMotionCorrection=dict(stub_test=stub_test))) - elif verbose: - print("No motion corrected data found at {}".format(motion_corrected_video)) + elif verbose and not include_imaging: + print(f"Minian Motion Correction data will not be included for session {session_id}") + elif verbose and not motion_corrected_video.is_file(): + print(f"No motion corrected data found at {motion_corrected_video}") # Add Behavioral Video video_file_path = experiment_dir_path / (session_id + ".wmv") if video_file_path.is_file() and include_behavioral_video: source_data.update(dict(Video=dict(file_paths=[video_file_path]))) conversion_options.update(dict(Video=dict(stub_test=stub_test))) - elif verbose: - print("No behavioral video found at {}".format(video_file_path)) + elif verbose and not include_behavioral_video: + print(f"The behavioral video will not be included for session {session_id}") + elif verbose and not video_file_path.is_file(): + print(f"No behavioral video found at {video_file_path}") # Add Freezing Analysis output freezing_output_file_path = experiment_dir_path / (session_id + "_FreezingOutput.csv") @@ -102,8 +113,10 @@ def session_to_nwb( source_data.update( dict(FreezingBehavior=dict(file_path=freezing_output_file_path, video_sampling_frequency=30.0)) ) - elif verbose: - print("No freezing output csv file found at {}".format(freezing_output_file_path)) + elif verbose and not include_freezing_behavior: + print(f"The Freezing Analysis output will not be included for session {session_id}") + elif verbose and not freezing_output_file_path.is_file(): + print(f"No freezing output csv file found at {freezing_output_file_path}") # Add EEG, EMG, Temperature and Activity signals # TODO discuss how to slice this data @@ -113,8 +126,10 @@ def session_to_nwb( if edf_file_path.is_file() and include_eeg_emg_signals: source_data.update(dict(EDFSignals=dict(file_path=edf_file_path))) conversion_options.update(dict(EDFSignals=dict(stub_test=stub_test))) - elif verbose: - print("No .edf file found at {}".format(edf_file_path)) + elif verbose and not include_eeg_emg_signals: + print(f"The EEG, EMG, Temperature and Activity signals will not be included for session {session_id}") + elif verbose and not edf_file_path.is_file(): + print(f"No .edf file found at {edf_file_path}") # Add Sleep Classification output sleep_classification_file_path = ( @@ -124,8 +139,10 @@ def session_to_nwb( source_data.update( dict(SleepClassification=dict(file_path=sleep_classification_file_path, video_sampling_frequency=30.0)) ) - elif verbose: - print("No sleep classification output csv file found at {}".format(sleep_classification_file_path)) + elif verbose and not include_sleep_classification: + print(f"The Sleep Classification output will not be included for session {session_id}") + elif verbose and not sleep_classification_file_path.is_file(): + print(f"No sleep classification output csv file found at {sleep_classification_file_path}") converter = Zaki2024NWBConverter(source_data=source_data) @@ -165,7 +182,7 @@ def session_to_nwb( # Parameters for conversion data_dir_path = Path("D:/") subject_id = "Ca_EEG3-4" - task = "OfflineDay1Session1" + task = "NeutralExposure" session_id = subject_id + "_" + task output_dir_path = Path("D:/cai_lab_conversion_nwb/") stub_test = True