-
Notifications
You must be signed in to change notification settings - Fork 0
/
nlstsvstodcm.sh
506 lines (450 loc) · 20.8 KB
/
nlstsvstodcm.sh
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
#!/bin/sh
#
# Usage: ./nlstsvstodcm.sh nlstfolder/participantid/filename.svs [outdir]
infile="$1"
outdir="$2"
metadatacsvdir="NLSTMetadataCSV"
TMPJSONFILE="/tmp/`basename $0`.$$"
# these persist across invocations ...
FILEMAPPINGSPECIMENIDTOUID="NLSTspecimenIDToUIDMap.csv"
FILEMAPPINGSTUDYIDTOUID="NLSTstudyIDToUIDMap.csv"
FILEMAPPINGSTUDYIDTODATETIME="NLSTstudyIDToDateTimeMap.csv"
UIDMAPPINGFILE="tabulateduids.csv"
TMPSLIDEUIDFILE="slideuid.csv"
#JHOVE="${HOME}/work/jhove/jhove"
PIXELMEDDIR="${HOME}/work/pixelmed/imgbook"
PATHTOADDITIONAL="${PIXELMEDDIR}/lib/additional"
# "pathology-NLST_1225files/117492/9718.svs"
filename=`basename "${infile}" '.svs'`
foldername=`dirname "${infile}"`
# case_id is what NLST metadata calls pid (participant id)
case_id=`basename "${foldername}"`
slide_id="${case_id}_${filename}"
echo "slide_id = ${slide_id}"
if [ -z "${outdir}" ]
then
outdir="Converted/NLST/${slide_id}"
fi
csvfilename="nlst_780_prsn_idc_20210527.csv"
#echo "csvfilename = ${csvfilename}"
if [ -f "${csvfilename}" ]
then
csvlineforslide=`egrep ",${case_id}," "${csvfilename}" | head -1`
fi
#race,cigsmok,gender,age,loclhil,locllow,loclup,locrhil,locrlow,locrmid,locunk,locrup,locoth,locmed,loclmsb,locrmsb,loccar,loclin,lesionsize,de_type,de_grade,de_stag,scr_res0,scr_res1,scr_res2,scr_iso0,scr_iso1,scr_iso2,cancyr,can_scr,canc_rpt_link,pid,dataset_version,scr_days0,scr_days1,scr_days2,candx_days,canc_free_days,de_stag_7thed
race=`echo "${csvlineforslide}" | awk -F, '{print $1}'`
cigsmok=`echo "${csvlineforslide}" | awk -F, '{print $2}'`
gender=`echo "${csvlineforslide}" | awk -F, '{print $3}'`
# is actually age at randomization, not biopsy, but use anyway :(
age=`echo "${csvlineforslide}" | awk -F, '{print $4}'`
specimen_id="${slide_id}"
fixation="FFPE" # assume ... not in available metadata
echo "infile = ${infile}"
echo "filename = ${filename}"
echo "slide_id = ${slide_id}"
echo "specimen_id = ${specimen_id}"
echo "case_id = ${case_id}"
echo "fixation = ${fixation}"
echo "race = ${race}"
echo "cigsmok = ${cigsmok}"
echo "gender = ${gender}"
echo "age = ${age}"
slidefilenameforuid="${case_id}/${filename}"
echo "slidefilenameforuid = ${slidefilenameforuid}"
echo "TMPSLIDEUIDFILE = ${TMPSLIDEUIDFILE}"
rm -f "${TMPSLIDEUIDFILE}"
uidarg=""
if [ -f "${UIDMAPPINGFILE}" ]
then
egrep "(Filename|${slidefilenameforuid})" "${UIDMAPPINGFILE}" > "${TMPSLIDEUIDFILE}"
uidarg="UIDFILE ${TMPSLIDEUIDFILE}"
fi
echo "uidarg = ${uidarg}"
# NLST pattern for radiology has different value for PatientName and Clinical Trial Subject ID than PatientID - do not have this so leave it blank
dicompatientid="${case_id}"
dicompatientname=""
dicomspecimenidentifier="${specimen_id}"
dicomstudyid="${case_id}"
dicomaccessionnumber="${case_id}"
# container is the slide
dicomcontaineridentifier="${slide_id}"
dicomclinicaltrialsponsorname="National Cancer Institute"
dicomclinicalprotocolid="NCT00047385"
dicomclinicalprotocolname="NLST-LSS"
dicomctpprojectname="NLST"
dicomclinicaltrialsubjectid="${dicompatientid}"
anatomycodevalue="39607008"
anatomycsd="SCT"
anatomycodemeaning="Lung"
dicomspecimenuid=""
if [ ! -f "${FILEMAPPINGSPECIMENIDTOUID}" ]
then
touch "${FILEMAPPINGSPECIMENIDTOUID}"
fi
if [ ! -z "${dicomspecimenidentifier}" ]
then
# dicomspecimenidentifier may be prefix for other identifiers, so assure bounded by delimiters, and use first if duplicates else fails later
dicomspecimenuid=`egrep "^${dicomspecimenidentifier}," "${FILEMAPPINGSPECIMENIDTOUID}" | awk -F, '{print $2}' | head -1`
if [ -z "${dicomspecimenuid}" ]
then
dicomspecimenuid=`java -cp ${PIXELMEDDIR}/pixelmed.jar -Djava.awt.headless=true com.pixelmed.utils.UUIDBasedOID 2>&1`
echo "${dicomspecimenidentifier},${dicomspecimenuid}" >>"${FILEMAPPINGSPECIMENIDTOUID}"
echo "Created Specimen UID ${dicomspecimenuid} for Specimen ID ${dicomspecimenidentifier}"
else
echo "Reusing Specimen UID ${dicomspecimenuid} for Specimen ID ${dicomspecimenidentifier}"
fi
fi
# dicomspecimenuid may still be unassigned if there is no dicomspecimenidentifier - let Java code fill in new one
dicomstudyuid=""
if [ ! -f "${FILEMAPPINGSTUDYIDTOUID}" ]
then
touch "${FILEMAPPINGSTUDYIDTOUID}"
fi
if [ ! -z "${dicomstudyid}" ]
then
# dicomstudyid may be prefix for other identifiers, so assure bounded by delimiters, and use first if duplicates else fails later
dicomstudyuid=`egrep "^${dicomstudyid}," "${FILEMAPPINGSTUDYIDTOUID}" | awk -F, '{print $2}' | head -1`
if [ -z "${dicomstudyuid}" ]
then
dicomstudyuid=`java -cp ${PIXELMEDDIR}/pixelmed.jar -Djava.awt.headless=true com.pixelmed.utils.UUIDBasedOID 2>&1`
echo "${dicomstudyid},${dicomstudyuid}" >>"${FILEMAPPINGSTUDYIDTOUID}"
echo "Created Study UID ${dicomstudyuid} for Study ID ${dicomstudyid}"
else
echo "Reusing Study UID ${dicomstudyuid} for Study ID ${dicomstudyid}"
fi
fi
# dicomstudyuid may still be unassigned if there is no dicomstudyid - let Java code fill in new one
svsdatetime=`tiffinfo "${infile}" | grep Date | grep Time | head -1 | sed -e 's/^.*Date = \([0-9][0-9]\)[/]\([0-9][0-9]\)[/]\([0-9][0-9]\).*Time = \([0-9][0-9]\)[:]\([0-9][0-9]\)[:]\([0-9][0-9]\).*$/20\3\1\2\4\5\6/'`
echo "svsdatetime = ${svsdatetime}"
# ideally we would pick the earliest study date time, but that would require multiple passes, so just record the 1st encountered and make all the same to satisfy information model (dcentvfy)
dicomstudydatetime=""
if [ ! -f "${FILEMAPPINGSTUDYIDTODATETIME}" ]
then
touch "${FILEMAPPINGSTUDYIDTODATETIME}"
fi
if [ ! -z "${dicomstudyid}" ]
then
# should only be zero or one, but head -1 just in case
dicomstudydatetime=`grep "${dicomstudyid}" "${FILEMAPPINGSTUDYIDTODATETIME}" | head -1 | awk -F, '{print $2}'`
if [ -z "${dicomstudydatetime}" ]
then
dicomstudydatetime="${svsdatetime}"
echo "${dicomstudyid},${dicomstudydatetime}" >>"${FILEMAPPINGSTUDYIDTODATETIME}"
echo "Created Study Date Time ${dicomstudydatetime} for Study ID ${dicomstudyid}"
else
echo "Reusing Study Date Time ${dicomstudydatetime} for Study ID ${dicomstudyid}"
fi
fi
# dicomstudydatetime may still be unassigned if there is no dicomstudyid, or if not found in SVS header - let Java code fill in one based on SVS files ImageDescription
dicomstudydate=""
dicomstudytime=""
if [ ! -z "${dicomstudydatetime}" ]
then
dicomstudydate=`echo "${dicomstudydatetime}" | sed -e 's/^\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*$/\1/'`
dicomstudytime=`echo "${dicomstudydatetime}" | sed -e 's/^.*\([0-9][0-9][0-9][0-9][0-9][0-9]\)$/\1/'`
fi
dicomstudydescription="Histopathology"
echo "dicompatientname = ${dicompatientname}"
echo "dicompatientid = ${dicompatientid}"
echo "dicomstudyid = ${dicomstudyid}"
echo "dicomstudyuid = ${dicomstudyuid}"
echo "dicomstudydatetime = ${dicomstudydatetime}"
echo "dicomstudydate = ${dicomstudydate}"
echo "dicomstudytime = ${dicomstudytime}"
echo "dicomstudydescription = ${dicomstudydescription}"
echo "dicomaccessionnumber = ${dicomaccessionnumber}"
echo "dicomspecimenidentifier = ${dicomspecimenidentifier}"
echo "dicomspecimenuid = ${dicomspecimenuid}"
echo "dicomcontaineridentifier = ${dicomcontaineridentifier}"
echo "dicomclinicaltrialsponsorname = ${dicomclinicaltrialsponsorname}"
echo "dicomclinicalprotocolid = ${dicomclinicalprotocolid}"
echo "dicomclinicalprotocolname = ${dicomclinicalprotocolname}"
echo "dicomctpprojectname = ${dicomctpprojectname}"
echo "dicomclinicaltrialsiteid = ${dicomclinicaltrialsiteid}"
echo "dicomclinicaltrialsitename = ${dicomclinicaltrialsitename}"
echo "dicomclinicaltrialsubjectid = ${dicomclinicaltrialsubjectid}"
echo "anatomycodevalue = ${anatomycodevalue}"
echo "anatomycsd = ${anatomycsd}"
echo "anatomycodemeaning = ${anatomycodemeaning}"
dicomsex=""
if [ "${gender}" = "1" ]
then
dicomsex="M"
elif [ "${gender}" = "2" ]
then
dicomsex="F"
fi
echo "dicomsex = ${dicomsex}"
dicomage=""
if [ ! -z "${age}" ]
then
if [ ${age} -ge 100 ]
then
dicomage="${age}Y"
elif [ ${age} -ge 10 ]
then
dicomage="0${age}Y"
fi
fi
echo "dicomage = ${dicomage}"
dicomethnicgroup=""
if [ "${race}" = "1" ]
then
dicomethnicgroup="White"
elif [ "${race}" = "2" ]
then
dicomethnicgroup="Black or African"
elif [ "${race}" = "3" ]
then
dicomethnicgroup="Asian"
elif [ "${race}" = "4" ]
then
dicomethnicgroup="American Indian"
elif [ "${race}" = "5" ]
then
dicomethnicgroup="Native Hawaiian"
elif [ "${race}" = "6" ]
then
dicomethnicgroup="More than one"
fi
echo "dicomethnicgroup = ${dicomethnicgroup}"
smokingstatuscodevalue=""
if [ "${cigsmok}" = "0" ]
then
smokingstatuscodevalue="8517006"
smokingstatuscsd="SCT"
smokingstatuscodemeaning="Former Smoker"
elif [ "${cigsmok}" = "1" ]
then
smokingstatuscodevalue="77176002"
smokingstatuscsd="SCT"
smokingstatuscodemeaning="Current Smoker"
fi
echo "smokingstatuscodemeaning = ${smokingstatuscodemeaning}"
dicomspecimenshortdescription="FFPE HE"
echo "dicomspecimenshortdescription = ${dicomspecimenshortdescription}"
dicomspecimendetaileddescription=""
echo "dicomspecimendetaileddescription = ${dicomspecimendetaileddescription}"
dicomseriesdescription="${dicomspecimenshortdescription}"
echo "dicomseriesdescription = ${dicomseriesdescription}"
echo >"${TMPJSONFILE}" "{"
echo >>"${TMPJSONFILE}" " \"options\" : {"
echo >>"${TMPJSONFILE}" " \"AppendToContributingEquipmentSequence\" : false"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " \"top\" : {"
echo >>"${TMPJSONFILE}" " \"PatientName\" : \"${dicompatientname}\","
echo >>"${TMPJSONFILE}" " \"PatientID\" : \"${dicompatientid}\","
if [ ! -z "${dicomsex}" ]
then
echo >>"${TMPJSONFILE}" " \"PatientSex\" : \"${dicomsex}\","
fi
if [ ! -z "${dicomage}" ]
then
echo >>"${TMPJSONFILE}" " \"PatientAge\" : \"${dicomage}\","
fi
if [ ! -z "${dicomsize}" ]
then
echo >>"${TMPJSONFILE}" " \"PatientSize\" : \"${dicomsize}\","
fi
if [ ! -z "${dicomweight}" ]
then
echo >>"${TMPJSONFILE}" " \"PatientWeight\" : \"${dicomweight}\","
fi
if [ ! -z "${dicomethnicgroup}" ]
then
echo >>"${TMPJSONFILE}" " \"EthnicGroup\" : \"${dicomethnicgroup}\","
fi
echo >>"${TMPJSONFILE}" " \"StudyID\" : \"${dicomstudyid}\","
echo >>"${TMPJSONFILE}" " \"StudyInstanceUID\" : \"${dicomstudyuid}\","
if [ ! -z "${dicomstudydate}" ]
then
echo >>"${TMPJSONFILE}" " \"StudyDate\" : \"${dicomstudydate}\","
fi
if [ ! -z "${dicomstudytime}" ]
then
echo >>"${TMPJSONFILE}" " \"StudyTime\" : \"${dicomstudytime}\","
fi
echo >>"${TMPJSONFILE}" " \"StudyDescription\" : \"${dicomstudydescription}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialSponsorName\" : \"${dicomclinicaltrialsponsorname}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialProtocolID\" : \"${dicomclinicalprotocolid}\","
echo >>"${TMPJSONFILE}" " \"00130010\" : \"CTP\","
echo >>"${TMPJSONFILE}" " \"00131010\" : \"${dicomctpprojectname}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialProtocolName\" : \"${dicomclinicalprotocolname}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialSiteID\" : \"${dicomclinicaltrialsiteid}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialSiteName\" : \"${dicomclinicaltrialsitename}\","
echo >>"${TMPJSONFILE}" " \"ClinicalTrialSubjectID\" : \"${dicomclinicaltrialsubjectid}\","
echo >>"${TMPJSONFILE}" " \"AcquisitionContextSequence\" : ["
if [ ! -z "${smokingstatuscodevalue}" ]
then
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"365981007\", \"csd\" : \"SCT\", \"cm\" : \"Tobacco Smoking Behavior\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"${smokingstatuscodevalue}\", \"csd\" : \"${smokingstatuscsd}\", \"cm\" : \"${smokingstatuscodemeaning}\" }"
echo >>"${TMPJSONFILE}" " }"
fi
echo >>"${TMPJSONFILE}" " ],"
echo >>"${TMPJSONFILE}" " \"SeriesNumber\" : \"1\","
echo >>"${TMPJSONFILE}" " \"SeriesDescription\" : \"${dicomseriesdescription}\","
echo >>"${TMPJSONFILE}" " \"AccessionNumber\" : \"${dicomaccessionnumber}\","
echo >>"${TMPJSONFILE}" " \"ContainerIdentifier\" : \"${dicomcontaineridentifier}\","
echo >>"${TMPJSONFILE}" " \"IssuerOfTheContainerIdentifierSequence\" : [],"
echo >>"${TMPJSONFILE}" " \"ContainerTypeCodeSequence\" : { \"cv\" : \"433466003\", \"csd\" : \"SCT\", \"cm\" : \"Microscope slide\" },"
echo >>"${TMPJSONFILE}" " \"SpecimenDescriptionSequence\" : ["
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"SpecimenIdentifier\" : \"${dicomspecimenidentifier}\","
echo >>"${TMPJSONFILE}" " \"IssuerOfTheSpecimenIdentifierSequence\" : [],"
echo >>"${TMPJSONFILE}" " \"SpecimenUID\" : \"${dicomspecimenuid}\","
if [ ! -z "${dicomspecimenshortdescription}" ]
then
echo >>"${TMPJSONFILE}" " \"SpecimenShortDescription\" : \"${dicomspecimenshortdescription}\","
fi
if [ ! -z "${dicomspecimendetaileddescription}" ]
then
echo >>"${TMPJSONFILE}" " \"SpecimenDetailedDescription\" : \"${dicomspecimendetaileddescription}\","
fi
echo >>"${TMPJSONFILE}" " \"SpecimenPreparationSequence\" : ["
if [ "${fixation}" = "FFPE" ]
then
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"SpecimenPreparationStepContentItemSequence\" : ["
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"TEXT\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"121041\", \"csd\" : \"DCM\", \"cm\" : \"Specimen Identifier\" },"
echo >>"${TMPJSONFILE}" " \"TextValue\" : \"${dicomspecimenidentifier}\""
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"111701\", \"csd\" : \"DCM\", \"cm\" : \"Processing type\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"9265001\", \"csd\" : \"SCT\", \"cm\" : \"Specimen processing\" }"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"430864009\", \"csd\" : \"SCT\", \"cm\" : \"Tissue Fixative\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"431510009\", \"csd\" : \"SCT\", \"cm\" : \"Formalin\" }"
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" " ]"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"SpecimenPreparationStepContentItemSequence\" : ["
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"TEXT\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"121041\", \"csd\" : \"DCM\", \"cm\" : \"Specimen Identifier\" },"
echo >>"${TMPJSONFILE}" " \"TextValue\" : \"${dicomspecimenidentifier}\""
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"111701\", \"csd\" : \"DCM\", \"cm\" : \"Processing type\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"9265001\", \"csd\" : \"SCT\", \"cm\" : \"Specimen processing\" }"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"430863003\", \"csd\" : \"SCT\", \"cm\" : \"Embedding medium\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"311731000\", \"csd\" : \"SCT\", \"cm\" : \"Paraffin wax\" }"
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" " ]"
echo >>"${TMPJSONFILE}" " },"
fi
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"SpecimenPreparationStepContentItemSequence\" : ["
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"TEXT\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"121041\", \"csd\" : \"DCM\", \"cm\" : \"Specimen Identifier\" },"
echo >>"${TMPJSONFILE}" " \"TextValue\" : \"${dicomspecimenidentifier}\""
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"111701\", \"csd\" : \"DCM\", \"cm\" : \"Processing type\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"127790008\", \"csd\" : \"SCT\", \"cm\" : \"Staining\" }"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"424361007\", \"csd\" : \"SCT\", \"cm\" : \"Using substance\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"12710003\", \"csd\" : \"SCT\", \"cm\" : \"hematoxylin stain\" }"
echo >>"${TMPJSONFILE}" " },"
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"ValueType\" : \"CODE\","
echo >>"${TMPJSONFILE}" " \"ConceptNameCodeSequence\" : { \"cv\" : \"424361007\", \"csd\" : \"SCT\", \"cm\" : \"Using substance\" },"
echo >>"${TMPJSONFILE}" " \"ConceptCodeSequence\" : { \"cv\" : \"36879007\", \"csd\" : \"SCT\", \"cm\" : \"water soluble eosin stain\" }"
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" " ]"
echo >>"${TMPJSONFILE}" " }"
if [ ! -z "${anatomycodevalue}" ]
then
echo >>"${TMPJSONFILE}" " ],"
echo >>"${TMPJSONFILE}" " \"PrimaryAnatomicStructureSequence\" : { \"cv\" : \"${anatomycodevalue}\", \"csd\" : \"${anatomycsd}\", \"cm\" : \"${anatomycodemeaning}\" }"
else
echo >>"${TMPJSONFILE}" " ]"
fi
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" " ],"
echo >>"${TMPJSONFILE}" " \"OpticalPathSequence\" : ["
echo >>"${TMPJSONFILE}" " {"
echo >>"${TMPJSONFILE}" " \"OpticalPathIdentifier\" : \"1\","
echo >>"${TMPJSONFILE}" " \"IlluminationColorCodeSequence\" : { \"cv\" : \"414298005\", \"csd\" : \"SCT\", \"cm\" : \"Full Spectrum\" },"
echo >>"${TMPJSONFILE}" " \"IlluminationTypeCodeSequence\" : { \"cv\" : \"111744\", \"csd\" : \"DCM\", \"cm\" : \"Brightfield illumination\" }"
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" " ]"
echo >>"${TMPJSONFILE}" " }"
echo >>"${TMPJSONFILE}" "}"
cat "${TMPJSONFILE}"
tiffinfo "${infile}"
rm -rf "${outdir}"
mkdir -p "${outdir}"
date
java -cp ${PIXELMEDDIR}/pixelmed.jar:${PATHTOADDITIONAL}/javax.json-1.0.4.jar:${PATHTOADDITIONAL}/opencsv-2.4.jar:${PATHTOADDITIONAL}/jai_imageio.jar \
-Djava.awt.headless=true \
-XX:-UseGCOverheadLimit \
-Xmx8g \
-Dorg.slf4j.simpleLogger.log.com.pixelmed.convert.TIFFToDicom=debug \
-Dorg.slf4j.simpleLogger.log.com.pixelmed.convert.AddTIFFOrOffsetTables=info \
com.pixelmed.convert.TIFFToDicom \
"${TMPJSONFILE}" \
"${infile}" \
"${outdir}/DCM" \
SM 1.2.840.10008.5.1.4.1.1.77.1.6 \
ADDTIFF MERGESTRIPS DONOTADDDCMSUFFIX INCLUDEFILENAME \
${uidarg}
date
rm "${TMPJSONFILE}"
rm -f "${TMPSLIDEUIDFILE}"
ls -l "${outdir}"
for i in ${outdir}/*
do
dciodvfy -new -filename "$i" 2>&1 | egrep -v '(Retired Person Name form|Warning - Unrecognized defined term <THUMBNAIL>|Error - Value is zero for value 1 of attribute <Slice Thickness>|Error - Value is zero for value 1 of attribute <Imaged Volume Depth>)'
done
#for i in ${outdir}/*
#do
# dcfile -filename "$i"
#done
# Not -decimal (which is nice for rows, cols) because fails to display FL and FD values at all ([bugs.dicom3tools] (000554)) :(
(cd "${outdir}"; dctable -describe -recurse -k TransferSyntaxUID -k FrameOfReferenceUID -k LossyImageCompression -k LossyImageCompressionMethod -k LossyImageCompressionRatio -k InstanceNumber -k ImageType -k FrameType -k PhotometricInterpretation -k NumberOfFrames -k Rows -k Columns -k ImagedVolumeWidth -k ImagedVolumeHeight -k ImagedVolumeDepth -k ImageOrientationSlide -k XOffsetInSlideCoordinateSystem -k YOffsetInSlideCoordinateSystem -k PixelSpacing -k ObjectiveLensPower -k PrimaryAnatomicStructureSequence -k PrimaryAnatomicStructureModifierSequence -k ClinicalTrialProtocolID DCM*)
#for i in ${outdir}/*
#do
# echo "$i"
# tiffinfo "$i"
#done
# TIFF validation by JHOVE - throws java.io.IOException: Unable to create temporary file
#for i in ${outdir}/*
#do
# echo "$i"
# "${JHOVE}" "$i"
#done
#baselayerfile=`find "${outdir}" -name '*.dcm' | sort | head -1`
#echo "Making pyramids from ${baselayerfile} ..."
#date
#java -cp ${PIXELMEDDIR}/pixelmed.jar:${PATHTOADDITIONAL}/jai_imageio.jar \
# -Djava.awt.headless=true \
# -XX:-UseGCOverheadLimit \
# -Xmx8g \
# com.pixelmed.apps.TiledPyramid \
# "${baselayerfile}" \
# "${outdir}"
#date
echo "dcentvfy ..."
dcentvfy ${outdir}/*
#will not add pyramid files (yet) if created since name not DCM*
(cd "${outdir}"; \
java -cp ${PIXELMEDDIR}/pixelmed.jar -Djava.awt.headless=true com.pixelmed.dicom.DicomDirectory DICOMDIR DCM*; \
#dciodvfy -new DICOMDIR 2>&1 | egrep -v '(Retired Person Name form|Warning - Attribute is not present in standard DICOM IOD|Warning - Dicom dataset contains attributes not present in standard DICOM IOD)'; \
#dcdirdmp -v DICOMDIR \
)