Esempio n. 1
0
 def test_anatomical_implicit(self):
     tmp_output_dir = tempfile.mkdtemp()
     try:
         settings.disable_validate_multiframe_implicit()
         results = convert_philips.dicom_to_nifti(read_dicom_directory(
             test_data.PHILIPS_ENHANCED_ANATOMICAL_IMPLICIT),
             os.path.join(tmp_output_dir, 'test.nii.gz'))
         assert_compare_nifti(results['NII_FILE'],
                              ground_thruth_filenames(test_data.PHILIPS_ENHANCED_ANATOMICAL_IMPLICIT)[0])
         self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))
         settings.enable_validate_multiframe_implicit()
     finally:
         shutil.rmtree(tmp_output_dir)
Esempio n. 2
0
 def test_anatomical_implicit(self):
     tmp_output_dir = tempfile.mkdtemp()
     try:
         settings.disable_validate_multiframe_implicit()
         results = convert_philips.dicom_to_nifti(
             read_dicom_directory(
                 test_data.PHILIPS_ENHANCED_ANATOMICAL_IMPLICIT),
             os.path.join(tmp_output_dir, 'test.nii.gz'))
         assert compare_nifti(
             results['NII_FILE'],
             ground_thruth_filenames(
                 test_data.PHILIPS_ENHANCED_ANATOMICAL_IMPLICIT)[0]) is True
         settings.enable_validate_multiframe_implicit()
     finally:
         shutil.rmtree(tmp_output_dir)
def main():
    test_data_directory = os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'tests',
        'data')
    print(test_data_directory)
    for root, dir_names, _ in os.walk(test_data_directory):
        settings.disable_validate_multiframe_implicit()
        # New directory
        for dir_name in dir_names:
            dir_path = os.path.join(root, dir_name)
            if subdir_count(dir_path) > 0:
                continue  # not processing because not lowest level of directory
            logging.info(dir_path)
            output_file = dir_path + '_ground_truth.nii.gz'
            reoriented_file = dir_path + '_ground_truth_reoriented.nii.gz'
            # noinspection PyBroadException
            try:
                generate_ground_truth(dir_path, output_file, reoriented_file)
            except:  # explicitly capturing everything here
                pass
Esempio n. 4
0
def main():
    for root, dir_names, _ in os.walk(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                                                   'dicom2nifti',
                                                   'tests',
                                                   'data')):
        settings.disable_validate_multiframe_implicit()
        # New directory
        for dir_name in dir_names:
            dir_path = os.path.join(root, dir_name)
            if subdir_count(dir_path) > 0:
                continue  # not processing because not lowest level of directory
            print(dir_path)
            output_file = dir_path + '_ground_truth.nii.gz'
            reoriented_file = dir_path + '_ground_truth_reoriented.nii.gz'
            # noinspection PyBroadException
            try:
                dicom2nifti.dicom_series_to_nifti(dir_path, output_file, False)
                image_reorientation.reorient_image(output_file, reoriented_file)
            except:  # explicitly capturing everything here
                pass
def main():
    test_data_directory = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
                                       'tests',
                                       'data')
    print(test_data_directory)
    for root, dir_names, _ in os.walk(test_data_directory):
        settings.disable_validate_multiframe_implicit()
        # New directory
        for dir_name in dir_names:
            dir_path = os.path.join(root, dir_name)
            if subdir_count(dir_path) > 0:
                continue  # not processing because not lowest level of directory
            logging.info(dir_path)
            output_file = dir_path + '_ground_truth.nii.gz'
            reoriented_file = dir_path + '_ground_truth_reoriented.nii.gz'
            # noinspection PyBroadException
            try:
                generate_ground_truth(dir_path, output_file, reoriented_file)
            except:  # explicitly capturing everything here
                pass