-
Notifications
You must be signed in to change notification settings - Fork 5
/
score_sc2.py
38 lines (32 loc) · 1.21 KB
/
score_sc2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''
@author: bhoff
'''
import csv
import os
import time
if __name__ == '__main__':
crossWalkPath='/metadata/images_crosswalk.tsv'
if not os.path.isfile(crossWalkPath):
raise Exception(crossWalkPath+' does not exist')
examsMetadataPath='/metadata/exams_metadata.tsv'
if not os.path.isfile(examsMetadataPath):
raise Exception(examsMetadataPath+' does not exist')
time.sleep(120) # sleep for two minutes
existingsamples = []
with open(crossWalkPath,'r') as tsvin:
tsvin = csv.reader(tsvin, delimiter='\t')
f = open('/output/predictions.tsv', 'w')
f.write("subjectId\tlaterality\tconfidence\n")
first=True
for row in tsvin:
if first: # skip the header row
first=False
continue
sample = row[0] + row[4] #Make sure there are no duplicated samples
if sample not in existingsamples:
f.write('%s\t%s\t0\n' % (row[0], row[4]))
existingsamples.append(row[0] + row[4])
imageFile='/scoringData/'+row[5]
if not os.path.isfile(imageFile):
raise Exception(imageFile+' does not exist')
f.close()