@@ -408,7 +408,7 @@ def get_custom_classification(label, config=None):
408408 for k in classifications .keys ():
409409 val = classifications [k ]
410410
411- if not isinstance (val , basestring ):
411+ if not isinstance (val , str ):
412412 log .warn ("Expected string value for classification key %s" , k )
413413 continue
414414
@@ -587,18 +587,27 @@ def dicom_classify(zip_file_path, outbase, timezone, config=None):
587587 classification = {'Custom' : ['N/A' ]}
588588 elif dcm .get ("Modality" ) != "MR" :
589589 classification = {}
590- dicom_file ["classification" ] = classification
590+ dicom_file ["classification" ]. update ( classification )
591591
592592 # If no pixel data present, make classification intent "Non-Image"
593593 if not hasattr (dcm , "PixelData" ):
594- nonimage_intent = { "Intent" : [ " Non-Image"]}
594+ nonimage_intent = " Non-Image"
595595 # If classification is a dict, update dict with intent
596596 if isinstance (dicom_file ["classification" ], dict ):
597- dicom_file ["classification" ].update (nonimage_intent )
597+ classification = dicom_file ['classification' ]
598+ # If intent not present, add it with nonimage_intent
599+ if 'Intent' not in classification :
600+ classification ['Intent' ] = nonimage_intent
601+ else :
602+ # Otherwise append non-image if not in Intent
603+ if nonimage_intent not in classification ['Intent' ]:
604+ classification ['Intent' ].append (nonimage_intent )
598605 # Else classification is a list, assign dict with intent
599606 else :
600607 dicom_file ["classification" ] = nonimage_intent
601608
609+
610+
602611 # File info from dicom header
603612 dicom_file ["info" ] = get_dicom_header (dcm )
604613
0 commit comments