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

bug in overlap detection hotfix #15

Merged
merged 1 commit into from
May 26, 2024
Merged
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
13 changes: 7 additions & 6 deletions src/new_fave/utils/textgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,20 @@ def mark_overlaps(
tier1 = atg[i].Phone
tier2 = atg[j].Phone

x1 = np.array([seq.start for seq in tier1 if seq.label != ""])
x2 = np.array([seq.end for seq in tier1 if seq.label != ""])
x1 = tier1.starts
x2 = tier1.ends

y1 = np.array([seq.start for seq in tier2 if seq.label != ""])
y2 = np.array([seq.end for seq in tier2 if seq.label != ""])
y1 = tier2.starts
y2 = tier2.ends

a = np.array([x >= y1 for x in x2])
b = np.array([x <= y2 for x in x1])

overlap_locs = np.where(a & b)

for idx1, idx2 in zip(*overlap_locs):
tier1[idx1].overlapped = True
tier2[idx2].overlapped = True
if tier1[idx1].label != "" and tier2[idx2].label != "":
tier1[idx1].overlapped = True
tier2[idx2].overlapped = True

return overlap_locs
Loading