-
Notifications
You must be signed in to change notification settings - Fork 3
/
dcm_bdayAgeGet.bash
executable file
·129 lines (91 loc) · 2.2 KB
/
dcm_bdayAgeGet.bash
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
#
# mcheck-fs_meta.bash
#
# Copyright 2008 Rudolph Pienaar
# Massachusetts General Hospital
#
# GPL v2
#
# "include" the set of common script functions
source common.bash
let Gi_verbose=0
G_SYNOPSIS="
NAME
dcm_bdayAgeGet.bash
SYNOPSIS
dcm_bdayAgeGet.bash [-v <verbosity>] <DCMFILE>
DESCRIPTION
'dcm_bdayAgeGet.bash' is a simple wrapper about dcm_dump_file
that filters out the age and birthday field from a <DCMDIR>.
ARGUMENTS
-v <level> (optional)
Verbosity level.
<DCMFILE>
A DiCOM file.
PRECONDITIONS
o /usr/pubsw/bin/dcm_dump_file
POSTCONDITIONS
o Age and birthdate data are echoed to stdout
HISTORY
19 April 2006
o Initial design and coding.
"
###\\\
# Globals are in capital letters. Immutable globals are prefixed by 'G'.
###///
G_SELF=`basename $0`
G_PID=$$
# Actions
A_noDCMFILE="checking for <DCMFILE>"
# Error messages
EM_noDCMFILE="could not read <DCMFILE>."
# Error codes
EC_noDCMFILE=1
# Defaults
D_whatever=
###\\\
# Function definitions
###///
###\\\
# Process command options
###///
while getopts v: option ; do
case "$option"
in
v) let Gi_verbose=$OPTARG ;;
\?) synopsis_show
exit 0;;
esac
done
verbosity_check
topDir=$(pwd)
shift $(($OPTIND - 1))
DCMFILE=$1
if (( ${#DCMFILE} )) ; then
statusPrint "Checking for <DCMFILE>"
fileExist_check $DCMFILE || fatal noDCMFILE
else
DCMFILE=$(ls -1 *1.dcm | head -n 1)
fi
NAME=$(mri_probedicom --i $DCMFILE --t 10 10)
SEX=$(mri_probedicom --i $DCMFILE --t 10 40)
BDAY=$(mri_probedicom --i $DCMFILE --t 10 30)
IMAGEDATE=$(mri_probedicom --i $DCMFILE --t 08 23)
AGE=$(mri_probedicom --i $DCMFILE --t 10 1010)
# The PatientAge tag (0010, 1010) is an optional tag and may
# not be present in the DICOM data. However, the StudyDate and
# PatientBirthDay may still be present so attempt to compute the
# age from these fields.
if (( $? )) ; then
AGE=$(age_calc.py $BDAY $IMAGEDATE)
fi
exec 1>&6 6>&-
printf "%40s\t%-20s\n" "Patient Age at scan" "$AGE"
printf "%40s\t%-20s\n" "Patient birthday" "$BDAY"
printf "%40s\t%-20s\n" "Image date" "$IMAGEDATE"
printf "%40s\t%-20s\n" "Patient name" "$NAME"
printf "%40s\t%-20s\n" "Patient sex" "$SEX"
verbosity_check
statusPrint "Cleaning up"
shut_down 0