Skip to content

Commit

Permalink
make visualization support float fs
Browse files Browse the repository at this point in the history
  • Loading branch information
Amirshahi Alireza committed Sep 20, 2023
1 parent 7408652 commit 46df411
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/timescoring/visualization.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import matplotlib.pyplot as plt
from matplotlib.axes import Axes
import matplotlib.colors as mc
import matplotlib.ticker as ticker
import colorsys
import numpy as np

Expand Down Expand Up @@ -105,8 +106,10 @@ def plotEventScoring(ref: Annotation, hyp: Annotation,

# Plot REF TP & FN
for event in score.ref.events:
start_idx = int(round(event[0] * score.fs))
end_idx = int(round(event[1] * score.fs))
# TP
if np.any(score.tpMask[round(event[0] * score.fs):round(event[1] * score.fs)]):
if np.any(score.tpMask[start_idx:end_idx]):
color = 'tab:green'
else:
color = 'tab:purple'
Expand All @@ -115,11 +118,13 @@ def plotEventScoring(ref: Annotation, hyp: Annotation,

# Plot HYP TP & FP
for event in score.hyp.events:
start_idx = int(round(event[0] * score.fs))
end_idx = int(round(event[1] * score.fs))
# FP
if np.all(~score.tpMask[round(event[0] * score.fs):round(event[1] * score.fs)]):
if np.all(~score.tpMask[start_idx:end_idx]):
_plotEvent([event[0], event[1] - (1 / ref.fs)], [0.5, 0.5], 'tab:red', ax)
# TP
elif np.all(score.tpMask[round(event[0] * score.fs):round(event[1] * score.fs)]):
elif np.all(score.tpMask[start_idx:end_idx]):
ax.plot([event[0], event[1] - (1 / ref.fs)], [0.5, 0.5],
color='tab:green', linewidth=5, solid_capstyle='butt', linestyle='solid')
# Mix TP, FP
Expand Down

0 comments on commit 46df411

Please sign in to comment.