-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstudyMeta.sh
More file actions
66 lines (42 loc) · 1.44 KB
/
studyMeta.sh
File metadata and controls
66 lines (42 loc) · 1.44 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
cd /Volumes/encrypted/babybrains/dicom/MGH
studies=`ls -d */*`
for study in $studies; do echo $study ; done
firstSeries=$(for study in $studies; do echo ${study}/`ls ${study} | head -1` ; done)
for series in $firstSeries; do echo $series ; done
firstDCMs=$(for study in $studies; do find ${study} -name \*.dcm | head -1 ; done)
for dcm in $firstDCMs; do echo $dcm ; done
for dcm in $firstDCMs; do dcmdump $dcm | grep -E 'PatientID|PatientAge|StudyDate' ; done | grep -v IssuerOfPatientID > studyMeta.dump
python << EOF | grep -v "missing" > studyMeta.txt
import json
fp = open('../../converted/studyMap.json')
studyMap = json.load(fp)
fp = open('../../converted/patientMap.json')
patientMap = json.load(fp)
studyMeta = {}
currentID = ''
fp = open('studyMeta.dump')
while True:
try:
studyDateLine = fp.readline()
patientIDLine = fp.readline()
patientAgeLine = fp.readline()
studyDate = studyDateLine.split()[2].strip('[]')
patientID = patientIDLine.split()[2].strip('[]')
patientAge = patientAgeLine.split()[2].strip('[]')
mappedID = patientMap[patientID]
print(mappedID, patientAge, studyDate)
except KeyError:
print('missing %s' % patientID)
continue
except IndexError:
print(studyDateLine)
print(patientIDLine)
print(patientAgeLine)
break
except:
print ('-'*40)
import traceback
traceback.print_exc() # XXX But this goes to stderr!
print ('-'*40)
EOF