@@ -58,37 +58,28 @@ def getDicomFileName(cfg, scanNum, fileNum):
58
58
59
59
return fullFileName
60
60
61
+ attributesToAnonymize = [
62
+ 'PatientID' , 'PatientAge' , 'PatientBirthDate' , 'PatientName' ,
63
+ 'PatientSex' , 'PatientSize' , 'PatientWeight' , 'PatientPosition' ,
64
+ 'StudyDate' , 'StudyTime' , 'SeriesDate' , 'SeriesTime' ,
65
+ 'AcquisitionDate' , 'AcquisitionTime' , 'ContentDate' , 'ContentTime' ,
66
+ 'InstanceCreationDate' , 'InstanceCreationTime' ,
67
+ 'PerformedProcedureStepStartDate' , 'PerformedProcedureStepStartTime'
68
+ ]
61
69
62
70
def anonymizeDicom (dicomImg ):
63
71
"""
64
72
This function takes in the dicom image that you read in and deletes
65
- lots of different variables . The purpose of this is to anonymize the
73
+ lots of different attributes . The purpose of this is to anonymize the
66
74
dicom data before transferring it to the cloud.
67
75
68
76
Used externally.
69
77
"""
70
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientID
71
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientAge
72
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientBirthDate
73
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientName
74
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientSex
75
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientSize
76
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientWeight
77
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PatientPosition
78
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .StudyDate
79
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .StudyTime
80
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .SeriesDate
81
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .SeriesTime
82
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .AcquisitionDate
83
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .AcquisitionTime
84
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .ContentDate
85
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .ContentTime
86
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .InstanceCreationDate
87
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .InstanceCreationTime
88
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PerformedProcedureStepStartDate
89
- if hasattr (dicomImg , 'PatientID' ): del dicomImg .PerformedProcedureStepStartTime
90
- return dicomImg
78
+ for toAnonymize in attributesToAnonymize :
79
+ if hasattr (dicomImg , toAnonymize ):
80
+ setattr (dicomImg , toAnonymize , "" )
91
81
82
+ return dicomImg
92
83
93
84
def readDicomFromFile (filename ):
94
85
"""
0 commit comments