Skip to content

Commit

Permalink
Draft implementation of timestamp alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed May 1, 2024
1 parent 4a84fc3 commit bef3b03
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 226 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ dependencies = [
'matplotlib',
'fpdf2',
'scipy',
'rich'
'rich',
'harp-python'
]

[project.optional-dependencies]
Expand Down
37 changes: 36 additions & 1 deletion src/aind_ephys_rig_qc/generate_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@
from aind_ephys_rig_qc.pdf_utils import PdfReport
from aind_ephys_rig_qc.qc_figures import plot_power_spectrum, plot_raw_data

from aind_ephys_rig_qc.temporal_alignment import align_timestamps

def generate_qc_report(directory, report_name="QC.pdf"):

def generate_qc_report(
directory,
report_name="QC.pdf",
timestamp_alignment_method="local",
original_timestamp_filename="original_timestamps.npy",
):
"""
Generates a PDF report from an Open Ephys data directory
Expand All @@ -27,6 +34,13 @@ def generate_qc_report(directory, report_name="QC.pdf"):
The path to the Open Ephys data directory
report_name : str
The name of the PDF report
timestamp_alignment_method : str
The type of alignment to perform
Option 1: 'local' (default)
Option 2: 'harp' (extract Harp timestamps from the NIDAQ stream)
Option 3: 'none' (don't align timestamps)
original_timestamp_filename : str
The name of the file for archiving the original timestamps
"""

Expand All @@ -40,6 +54,27 @@ def generate_qc_report(directory, report_name="QC.pdf"):
pdf.set_y(45)
pdf.embed_table(get_stream_info(directory), width=pdf.epw)

if (
timestamp_alignment_method == "local"
or timestamp_alignment_method == "harp"
):
# perform local alignment first in either case
align_timestamps(
directory,
align_timestamps_to=timestamp_alignment_method,
original_timestamp_filename=original_timestamp_filename,
pdf=pdf,
)

if timestamp_alignment_method == "harp":
# optionally align to Harp timestamps
align_timestamps(
directory,
align_timestamps_to=timestamp_alignment_method,
original_timestamp_filename=original_timestamp_filename,
pdf=pdf,
)

create_qc_plots(pdf, directory)

pdf.output(os.path.join(directory, report_name))
Expand Down
2 changes: 1 addition & 1 deletion src/aind_ephys_rig_qc/parameters.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"report_name" : "QC.pdf",
"align_timestamps_to" : "local",
"timestamp_alignment_method" : "local",
"original_timestamp_filename" : "original_timestamps.npy"
}
Loading

0 comments on commit bef3b03

Please sign in to comment.