def test_is_siemens(self): assert not convert_siemens.is_siemens( read_dicom_directory(test_data.PHILIPS_ANATOMICAL)) assert convert_siemens.is_siemens( read_dicom_directory(test_data.SIEMENS_ANATOMICAL)) assert not convert_siemens.is_siemens( read_dicom_directory(test_data.GE_ANATOMICAL)) assert not convert_siemens.is_siemens( read_dicom_directory(test_data.GENERIC_ANATOMICAL)) assert not convert_siemens.is_siemens( read_dicom_directory(test_data.HITACHI_ANATOMICAL))
def _get_vendor(dicom_input): """ This function will check the dicom headers to see which type of series it is Possibilities are fMRI, DTI, Anatomical (if no clear type is found anatomical is used) """ # check if it is siemens frmi if convert_siemens.is_siemens(dicom_input): print('Found manufacturer: SIEMENS') return Vendor.SIEMENS # check if it is ge frmi if convert_ge.is_ge(dicom_input): print('Found manufacturer: GE') return Vendor.GE # check if it is ge frmi if convert_philips.is_philips(dicom_input): print('Found manufacturer: PHILIPS') return Vendor.PHILIPS # check if it is siemens dti print('WARNING: Assuming generic vendor conversion (ANATOMICAL)') return Vendor.GENERIC
def anonymize_directory(input_directory, output_directory=None): if output_directory is None: output_directory = input_directory study_uid = pydicom.uid.generate_uid() series_uid = pydicom.uid.generate_uid() date = datetime.datetime.now().strftime("%Y%m%d") time = datetime.datetime.now().strftime("%H%M%S.000000") fields_to_keep = { 'SpecificCharacterSet': None, 'ImageType': None, 'AcquisitionMatrix': None, 'SOPClassUID': None, 'SOPInstanceUID': None, # Will be replaced by file-unique UID 'StudyDate': date, 'SeriesDate': date, 'AcquisitionDate': date, 'ContentDate': date, 'StudyTime': time, 'AcquisitionTime': time, 'AcquisitionNumber': None, 'Modality': None, 'Manufacturer': None, 'ManufacturersModelName': None, 'PatientName': 'dicom2nifti', 'PatientID': 'dicom2nifti', 'PatientsBirthDate': date, 'PatientsSex': None, 'PatientsAge': '0Y', 'PatientPosition': None, 'ScanningSequence': None, 'SequenceVariant': None, 'MRAcquisitionType': None, 'SequenceName': 'dicom2nifti', 'RepetitionTime': None, 'EchoTime': None, 'InversionTime': None, 'DeviceSerialNumber': '1234', 'StudyInstanceUID': study_uid, 'SeriesInstanceUID': series_uid, 'StudyID': 'dicom2nifti', 'SeriesNumber': None, 'InstanceNumber': None, 'ImagePositionPatient': None, 'ImageOrientationPatient': None, 'SliceLocation': None, 'PhotometricInterpretation': None, 'Rows': None, 'Columns': None, 'PixelSpacing': None, 'BitsAllocated': None, 'BitsStored': None, 'HighBit': None, 'RescaleSlope': None, 'RescaleIntercept': None, 'PixelRepresentation': None, 'NumberOfFrames': None, 'SamplesPerPixel': None, 'SpacingBetweenSlices': None, # Pixel Data must be specified with hex code as it will not work for compressed dicoms (0x7fe0, 0x0010): None } if is_philips(read_dicom_directory(input_directory)): philips_fields = { (0x2001, 0x100a): None, (0x2001, 0x1003): None, (0x2001, 0x105f): None, (0x2005, 0x100d): None, (0x2005, 0x100e): None, (0x2005, 0x10b0): None, (0x2005, 0x10b1): None, (0x2005, 0x10b2): None, (0x0018, 0x9087): None, (0x0018, 0x9089): None, (0x5200, 0x9230): None, 'SharedFunctionalGroupsSequence': None } fields_to_keep.update(philips_fields) if is_siemens(read_dicom_directory(input_directory)): siemens_fields = { (0x0019, 0x100c): None, (0x0029, 0x1020): None, (0x0051, 0x100b): None, (0x0019, 0x100e): None } fields_to_keep.update(siemens_fields) if is_ge(read_dicom_directory(input_directory)): ge_fields = { (0x0020, 0x9056): None, (0x0020, 0x9057): None, (0x0043, 0x1039): None, (0x0019, 0x10bb): None, (0x0019, 0x10bc): None, (0x0019, 0x10bd): None } fields_to_keep.update(ge_fields) _anonymize_files(input_directory, output_directory, fields_to_keep)