Skip to content

Commit

Permalink
fixed segments for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Haupt committed Feb 23, 2024
1 parent 743c60a commit 486ea60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,23 @@ def combineResults(folder: str, output_file: str):
# Combine all files
s_id = 1
time_offset = 0

with open(os.path.join(folder, output_file), "w", encoding="utf-8") as f:
f.write("Selection\tView\tChannel\tBegin Path\tBegin Time (s)\tEnd Time (s)\tLow Freq (Hz)\tHigh Freq (Hz)\tSpecies Code\tCommon Name\tConfidence\n")
f.write("Selection\tView\tChannel\tBegin Path\tFile Duration (s)\tBegin Time (s)\tEnd Time (s)\tLow Freq (Hz)\tHigh Freq (Hz)\tSpecies Code\tCommon Name\tConfidence\n")

for rfile in files:
with open(rfile, "r", encoding="utf-8") as rf:

try:

lines = rf.readlines()

# make sure it's a selection table
if not "Selection" in lines[0] or not "File Duration" in lines[0]:
continue

# skip header and add to file
f_duration = float(lines[1].split("\t")[4])

for line in lines[1:]:

# empty line?
Expand All @@ -250,9 +253,6 @@ def combineResults(folder: str, output_file: str):
line[5] = str(float(line[5]) + time_offset)
line[6] = str(float(line[6]) + time_offset)

# remove File Duration
del line[4]

# write line
f.write("\t".join(line))

Expand Down
4 changes: 2 additions & 2 deletions segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def findSegments(afile: str, rfile: str):
for i, line in enumerate(lines):
if rtype == "table" and i > 0:
d = line.split("\t")
start = float(d[4])
end = float(d[5])
start = float(d[5])
end = float(d[6])
species = d[-2]
confidence = float(d[-1])

Expand Down

0 comments on commit 486ea60

Please sign in to comment.