From 65fada0555bbec1f4fb1eebef6aa338784800450 Mon Sep 17 00:00:00 2001 From: ZhixiaoSu Date: Mon, 8 Jul 2024 12:59:29 -0700 Subject: [PATCH] Check if archived timestamps already exists. Adjusted subplot index. --- src/aind_ephys_rig_qc/generate_report.py | 4 +++- src/aind_ephys_rig_qc/temporal_alignment.py | 17 +++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/aind_ephys_rig_qc/generate_report.py b/src/aind_ephys_rig_qc/generate_report.py index 34649c6..71d7efb 100644 --- a/src/aind_ephys_rig_qc/generate_report.py +++ b/src/aind_ephys_rig_qc/generate_report.py @@ -108,11 +108,13 @@ def generate_qc_report( outfile = os.path.join(directory, "ephys-rig-QC_output.txt") + print("Finished.") + with open(outfile, "a") as output_file: output_file.write(datetime.now().strftime("%Y-%m-%d %H:%M:%S") + "\n") output_file.write(output_content) - print("Finished.") + def get_stream_info(directory): diff --git a/src/aind_ephys_rig_qc/temporal_alignment.py b/src/aind_ephys_rig_qc/temporal_alignment.py index 6f7c7fd..93bf71b 100644 --- a/src/aind_ephys_rig_qc/temporal_alignment.py +++ b/src/aind_ephys_rig_qc/temporal_alignment.py @@ -172,7 +172,7 @@ def search_harp_line(recording, directory, pdf=None): ax2 = axs[1] else: ax1 = axs[0, line_ind] - ax2 = axs[0, line_ind] + ax2 = axs[1, line_ind] curr_events = events[ (events.stream_name == nidaq_stream_name) & (events.processor_id == nidaq_stream_source_node_id) @@ -246,11 +246,16 @@ def archive_and_replace_original_timestamps( archive_filename : str The name of the file for archiving the original timestamps """ - # rename the original timestamps file - os.rename( - os.path.join(directory, timestamp_filename), - os.path.join(directory, archive_filename), - ) + + if not os.path.exists(os.path.join(directory, archive_filename)): + # rename the original timestamps file + os.rename( + os.path.join(directory, timestamp_filename), + os.path.join(directory, archive_filename), + ) + else: + print("Original timestamps already archived. Removed current timestamps.") + os.remove(os.path.join(directory, timestamp_filename)) # save the new timestamps np.save(os.path.join(directory, timestamp_filename), new_timestamps)