-
Notifications
You must be signed in to change notification settings - Fork 0
/
alignmentScore.py
executable file
·30 lines (25 loc) · 1.1 KB
/
alignmentScore.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
# Gives a score between 0 (bad) and 1 (excellent) for the alignment of two NRRD samples
import sys
import numpy as np
import CheckImages as ci
import slicescore
def score(template, alignment):
# template file, alignment file (both NRRD)
result = np.mean(
[np.float128(ci.rateOne(alignment, results=None, methord=slicescore.OverlapCoeff, template=template)),
np.float128(ci.rateOne(alignment, results=None, methord=slicescore.avgOverlapCoeff, template=template))])
if np.isnan(result):
result = np.float128(0.0);
return result
if __name__ == "__main__":
if len(sys.argv) < 3:
print 'Error: missing arguments!'
print 'e.g. python alignmentScore.py alignment.nrrd template.nrrd [results.csv]'
else:
r = score(sys.argv[2], sys.argv[1])
print 'The final alignment score is ' + str(r)
if len(sys.argv) > 3:
with open(str(sys.argv[3]), "a") as myfile:
myfile.write('{0:.100f}'.format(float(r)) + ', Alignment Score, ' + str(sys.argv[1]) + ', ' + str(
sys.argv[2]) + '\n')
print 'Done.'