def _is_valid_imaging_dicom(dicom_header): """ Function will do some basic checks to see if this is a valid imaging dicom """ # if it is philips and multiframe dicom then we assume it is ok try: if convert_philips.is_philips([dicom_header]): if convert_philips.is_multiframe_dicom([dicom_header]): return True if "SeriesInstanceUID" not in dicom_header: return False if "InstanceNumber" not in dicom_header: return False if "ImageOrientationPatient" not in dicom_header or len(dicom_header.ImageOrientationPatient) < 6: return False if "ImagePositionPatient" not in dicom_header or len(dicom_header.ImagePositionPatient) < 3: return False # for all others if there is image position patient we assume it is ok if Tag(0x0020, 0x0037) not in dicom_header: return False return True except (KeyError, AttributeError): return False
def are_imaging_dicoms(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) :param dicom_input: directory with dicom files or a list of dicom objects """ # if it is philips and multiframe dicom then we assume it is ok if convert_philips.is_philips(dicom_input): if convert_philips.is_multiframe_dicom(dicom_input): return True # for all others if there is image position patient we assume it is ok header = dicom_input[0] return Tag(0x0020, 0x0037) in header
def test_is_multiframe_dicom(self): assert convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_ENHANCED_DTI)) assert not convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_DTI)) assert convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_ENHANCED_ANATOMICAL)) assert not convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_ANATOMICAL)) assert convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_ENHANCED_FMRI)) assert not convert_philips.is_multiframe_dicom( read_dicom_directory(test_data.PHILIPS_FMRI))