예제 #1
0
    def test_validate_slicecount_disabled(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            self.assertRaises(ConversionValidationError,
                              dicom_to_nifti,
                              read_dicom_directory(test_data.FAILING_SLICECOUNT),
                              os.path.join(tmp_output_dir, 'test.nii.gz'))
            dicom2nifti.disable_validate_slicecount()
            dicom_to_nifti(read_dicom_directory(test_data.FAILING_SLICECOUNT),
                           os.path.join(tmp_output_dir, 'test.nii.gz'))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #2
0
    def test_validate_slicecount_disabled(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            self.assertRaises(
                ConversionValidationError, dicom_to_nifti,
                read_dicom_directory(test_data.FAILING_SLICECOUNT),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            dicom2nifti.disable_validate_slicecount()
            dicom_to_nifti(read_dicom_directory(test_data.FAILING_SLICECOUNT),
                           os.path.join(tmp_output_dir, 'test.nii.gz'))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #3
0
    def test_not_a_volume(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            settings.disable_validate_orthogonal()
            with self.assertRaises(ConversionError) as exception:
                convert_generic.dicom_to_nifti(read_dicom_directory(test_data.FAILING_NOTAVOLUME),
                                               os.path.join(tmp_output_dir, 'test.nii.gz'))
            self.assertEqual(str(exception.exception),
                             'NOT_A_VOLUME')

        finally:
            settings.enable_validate_orthogonal()
            shutil.rmtree(tmp_output_dir)
예제 #4
0
    def test_not_a_volume(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            settings.disable_validate_orthogonal()
            with self.assertRaises(ConversionError) as exception:
                convert_generic.dicom_to_nifti(
                    read_dicom_directory(test_data.FAILING_NOTAVOLUME),
                    os.path.join(tmp_output_dir, 'test.nii.gz'))
            self.assertEqual(str(exception.exception), 'NOT_A_VOLUME')

        finally:
            settings.enable_validate_orthogonal()
            shutil.rmtree(tmp_output_dir)
예제 #5
0
    def test_anatomical(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            results = convert_generic.dicom_to_nifti(read_dicom_directory(test_data.GE_ANATOMICAL),
                                                     None)
            self.assertTrue(results.get('NII_FILE') is None)
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

            results = convert_generic.dicom_to_nifti(read_dicom_directory(test_data.GE_ANATOMICAL),
                                                     os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(results['NII_FILE'],
                                        ground_thruth_filenames(test_data.GE_ANATOMICAL)[0])
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #6
0
    def test_validate_orientation_disabled(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            dicom2nifti.disable_validate_orthogonal()  # this will also fail on this data
            dicom2nifti.disable_validate_slice_increment()  # this will also fail on this data
            dicom2nifti.disable_validate_slicecount()
            self.assertRaises(ConversionValidationError,
                              dicom_to_nifti,
                              read_dicom_directory(test_data.FAILING_ORIENTATION),
                              os.path.join(tmp_output_dir, 'test.nii.gz'))
            dicom2nifti.disable_validate_orientation()
            dicom_to_nifti(read_dicom_directory(test_data.FAILING_ORIENTATION),
                           os.path.join(tmp_output_dir, 'test.nii.gz'))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #7
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for philips images.
    As input philips images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: file path to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert common.is_philips(dicom_input)

    if common.is_multiframe_dicom(dicom_input):
        _assert_explicit_vr(dicom_input)
        logger.info('Found multiframe dicom')
        if _is_multiframe_4d(dicom_input):
            logger.info('Found sequence type: MULTIFRAME 4D')
            return _multiframe_to_nifti(dicom_input, output_file)

        if _is_multiframe_anatomical(dicom_input):
            logger.info('Found sequence type: MULTIFRAME ANATOMICAL')
            return _multiframe_to_nifti(dicom_input, output_file)
    else:
        logger.info('Found singleframe dicom')
        grouped_dicoms = _get_grouped_dicoms(dicom_input)
        if _is_singleframe_4d(dicom_input):
            logger.info('Found sequence type: SINGLEFRAME 4D')
            return _singleframe_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for hitachi images.
    As input hitachi images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: file path to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert common.is_hitachi(dicom_input)

    # remove duplicate slices based on position and data
    dicom_input = convert_generic.remove_duplicate_slices(dicom_input)

    # remove localizers based on image type
    dicom_input = convert_generic.remove_localizers_by_imagetype(dicom_input)

    # remove_localizers based on image orientation (only valid if slicecount is validated)
    dicom_input = convert_generic.remove_localizers_by_orientation(dicom_input)

    # TODO add validations and conversion for DTI and fMRI once testdata is available

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #9
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: the filepath to the output nifti file
    :param dicom_input: list with dicom objects
    """
    assert common.is_ge(dicom_input)

    # remove duplicate slices based on position and data
    dicom_input = convert_generic.remove_duplicate_slices(dicom_input)

    # remove localizers based on image type
    dicom_input = convert_generic.remove_localizers_by_imagetype(dicom_input)

    # remove_localizers based on image orientation (only valid if slicecount is validated)
    dicom_input = convert_generic.remove_localizers_by_orientation(dicom_input)

    logger.info('Reading and sorting dicom files')
    grouped_dicoms = _get_grouped_dicoms(dicom_input)

    if _is_4d(grouped_dicoms):
        logger.info('Found sequence type: 4D')
        return _4d_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #10
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for philips images.
    As input philips images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: file path to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert is_philips(dicom_input)

    if is_multiframe_dicom(dicom_input):
        _assert_explicit_vr(dicom_input)
        logger.info('Found multiframe dicom')
        if _is_multiframe_4d(dicom_input):
            logger.info('Found sequence type: MULTIFRAME 4D')
            return _multiframe_to_nifti(dicom_input, output_file)

        if _is_multiframe_anatomical(dicom_input):
            logger.info('Found sequence type: MULTIFRAME ANATOMICAL')
            return _multiframe_to_nifti(dicom_input, output_file)
    else:
        logger.info('Found singleframe dicom')
        grouped_dicoms = _get_grouped_dicoms(dicom_input)
        if _is_singleframe_4d(dicom_input):
            logger.info('Found sequence type: SINGLEFRAME 4D')
            return _singleframe_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #11
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion function for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    :param output_file: filepath to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert common.is_siemens(dicom_input)

    # remove duplicate slices based on position and data
    dicom_input = convert_generic.remove_duplicate_slices(dicom_input)

    # remove localizers based on image type
    dicom_input = convert_generic.remove_localizers_by_imagetype(dicom_input)

    # remove_localizers based on image orientation (only valid if slicecount is validated)
    dicom_input = convert_generic.remove_localizers_by_orientation(dicom_input)

    if _is_4d(dicom_input):
        logger.info('Found sequence type: MOSAIC 4D')
        return _mosaic_4d_to_nifti(dicom_input, output_file)

    grouped_dicoms = _classic_get_grouped_dicoms(dicom_input)
    if _is_classic_4d(grouped_dicoms):
        logger.info('Found sequence type: CLASSIC 4D')
        return _classic_4d_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #12
0
    def test_validate_orientation_disabled(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            dicom2nifti.disable_validate_orthogonal(
            )  # this will also fail on this data
            dicom2nifti.disable_validate_slice_increment(
            )  # this will also fail on this data
            dicom2nifti.disable_validate_slicecount()
            self.assertRaises(
                ConversionValidationError, dicom_to_nifti,
                read_dicom_directory(test_data.FAILING_ORIENTATION),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            dicom2nifti.disable_validate_orientation()
            dicom_to_nifti(read_dicom_directory(test_data.FAILING_ORIENTATION),
                           os.path.join(tmp_output_dir, 'test.nii.gz'))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #13
0
    def test_anatomical(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            results = convert_generic.dicom_to_nifti(read_dicom_directory(test_data.GE_ANATOMICAL),
                                                     os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert compare_nifti(results['NII_FILE'],
                                 ground_thruth_filenames(test_data.GE_ANATOMICAL)[0]) is True

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #14
0
def dicom_array_to_nifti(dicom_list, output_file, reorient_nifti=True):
    """ Converts dicom single series (see pydicom) to nifty, mimicking SPM

    Examples: See unit test


    will return a dictionary containing
    - the NIFTI under key 'NIFTI'
    - the NIFTI file path under 'NII_FILE'
    - the BVAL file path under 'BVAL_FILE' (only for dti)
    - the BVEC file path under 'BVEC_FILE' (only for dti)

    IMPORTANT:
    If no specific sequence type can be found it will default to anatomical and try to convert.
    You should check that the data you are trying to convert is supported by this code

    Inspired by http://nipy.sourceforge.net/nibabel/dicom/spm_dicom.html
    Inspired by http://code.google.com/p/pydicom/source/browse/source/dicom/contrib/pydicom_series.py

    :param reorient_nifti: if True the nifti affine and data will be updated so the data is stored LAS oriented
    :param output_file: file path to write to
    :param dicom_list: list with uncompressed dicom objects as read by pydicom
    """
    # copy files so we can can modify without altering the original
    if not are_imaging_dicoms(dicom_list):
        raise ConversionValidationError('NON_IMAGING_DICOM_FILES')

    vendor = _get_vendor(dicom_list)

    if vendor == Vendor.GENERIC:
        results = convert_generic.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.SIEMENS:
        results = convert_siemens.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.GE:
        results = convert_ge.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.PHILIPS:
        results = convert_philips.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.HITACHI:
        results = convert_hitachi.dicom_to_nifti(dicom_list, output_file)
    else:
        raise ConversionValidationError("UNSUPPORTED_DATA")

    # do image reorientation if needed
    if reorient_nifti or settings.resample:
        results['NII'] = image_reorientation.reorient_image(
            results['NII'], results['NII_FILE'])

    # resampling needs to be after reorientation
    if settings.resample:
        if not common.is_orthogonal_nifti(results['NII']):
            results['NII'] = resample.resample_single_nifti(
                results['NII'], results['NII_FILE'])

    return results
예제 #15
0
    def test_anatomical(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            results = convert_generic.dicom_to_nifti(
                read_dicom_directory(test_data.GE_ANATOMICAL), None)
            self.assertTrue(results.get('NII_FILE') is None)
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

            results = convert_generic.dicom_to_nifti(
                read_dicom_directory(test_data.GE_ANATOMICAL),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(
                results['NII_FILE'],
                ground_thruth_filenames(test_data.GE_ANATOMICAL)[0])
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

        finally:
            shutil.rmtree(tmp_output_dir)
예제 #16
0
def dicom_array_to_nifti(dicom_list, output_file, reorient_nifti=True):
    """ Converts dicom single series (see pydicom) to nifty, mimicking SPM

    Examples: See unit test


    will return a dictionary containing
    - the NIFTI under key 'NIFTI'
    - the NIFTI file path under 'NII_FILE'
    - the BVAL file path under 'BVAL_FILE' (only for dti)
    - the BVEC file path under 'BVEC_FILE' (only for dti)

    IMPORTANT:
    If no specific sequence type can be found it will default to anatomical and try to convert.
    You should check that the data you are trying to convert is supported by this code

    Inspired by http://nipy.sourceforge.net/nibabel/dicom/spm_dicom.html
    Inspired by http://code.google.com/p/pydicom/source/browse/source/dicom/contrib/pydicom_series.py

    :param reorient_nifti: if True the nifti affine and data will be updated so the data is stored LAS oriented
    :param output_file: file path to write to
    :param dicom_list: list with uncompressed dicom objects as read by pydicom
    """
    # copy files so we can can modify without altering the original
    if not are_imaging_dicoms(dicom_list):
        raise ConversionValidationError('NON_IMAGING_DICOM_FILES')

    vendor = _get_vendor(dicom_list)
    if vendor == Vendor.GENERIC:
        results = convert_generic.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.SIEMENS:
        results = convert_siemens.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.GE:
        results = convert_ge.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.PHILIPS:
        results = convert_philips.dicom_to_nifti(dicom_list, output_file)
    elif vendor == Vendor.HITACHI:
        results = convert_hitachi.dicom_to_nifti(dicom_list, output_file)
    else:
        raise ConversionValidationError("UNSUPPORTED_DATA")

    # do image reorientation if needed
    if reorient_nifti or settings.resample:
        image_reorientation.reorient_image(results['NII_FILE'], results['NII_FILE'])

    # resampling needs to be after reorientation
    if settings.resample:
        if not common.is_orthogonal_nifti(results['NII_FILE']):
            resample.resample_single_nifti(results['NII_FILE'])

    return results
예제 #17
0
def dicom_to_nifti(dicom_input, output_file):
    """
    This is the main dicom to nifti conversion fuction for hitachi images.
    As input hitachi images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: file path to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert is_hitachi(dicom_input)

    # TODO add validations and conversion for DTI and fMRI once testdata is available

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #18
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for philips images.
    As input philips images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: file path to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert common.is_philips(dicom_input)

    # remove duplicate slices based on position and data
    dicom_input = convert_generic.remove_duplicate_slices(dicom_input)

    # remove localizers based on image type
    dicom_input = convert_generic.remove_localizers_by_imagetype(dicom_input)

    # remove_localizers based on image orientation (only valid if slicecount is validated)
    dicom_input = convert_generic.remove_localizers_by_orientation(dicom_input)

    # if no dicoms remain raise exception
    if not dicom_input:
        raise ConversionValidationError('TOO_FEW_SLICES/LOCALIZER')

    if common.is_multiframe_dicom(dicom_input):
        _assert_explicit_vr(dicom_input)
        logger.info('Found multiframe dicom')
        if _is_multiframe_4d(dicom_input):
            logger.info('Found sequence type: MULTIFRAME 4D')
            return _multiframe_to_nifti(dicom_input, output_file)

        if _is_multiframe_anatomical(dicom_input):
            logger.info('Found sequence type: MULTIFRAME ANATOMICAL')
            return _multiframe_to_nifti(dicom_input, output_file)
    else:
        logger.info('Found singleframe dicom')
        grouped_dicoms = _get_grouped_dicoms(dicom_input)
        if _is_singleframe_4d(dicom_input):
            logger.info('Found sequence type: SINGLEFRAME 4D')
            return _singleframe_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #19
0
    def test_single_slice(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            settings.disable_validate_slicecount()

            results = convert_generic.dicom_to_nifti(
                read_dicom_directory(test_data.GE_ANATOMICAL_SINGLE_SLICE),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(
                results['NII_FILE'],
                ground_thruth_filenames(
                    test_data.GE_ANATOMICAL_SINGLE_SLICE)[0])
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

        finally:
            settings.enable_validate_slicecount()
            shutil.rmtree(tmp_output_dir)
예제 #20
0
    def test_inconsistent_slice_increment_resampling(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            settings.disable_validate_orthogonal()
            settings.disable_validate_slice_increment()
            settings.enable_resampling()
            settings.set_resample_padding(0)
            settings.set_resample_spline_interpolation_order(1)
            results = convert_generic.dicom_to_nifti(read_dicom_directory(test_data.FAILING_SLICEINCREMENT_2),
                                                     os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(results['NII_FILE'],
                                 ground_thruth_filenames(test_data.FAILING_SLICEINCREMENT_2)[0])
            self.assertTrue(isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

        finally:
            settings.disable_resampling()
            settings.enable_validate_slice_increment()
            settings.enable_validate_orientation()
            shutil.rmtree(tmp_output_dir)
예제 #21
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: the filepath to the output nifti file
    :param dicom_input: list with dicom objects
    """
    assert common.is_ge(dicom_input)

    logger.info('Reading and sorting dicom files')
    grouped_dicoms = _get_grouped_dicoms(dicom_input)

    if _is_4d(grouped_dicoms):
        logger.info('Found sequence type: 4D')
        return _4d_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #22
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion fuction for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    Examples: See unit test

    :param output_file: the filepath to the output nifti file
    :param dicom_input: list with dicom objects
    """
    assert common.is_ge(dicom_input)

    logger.info('Reading and sorting dicom files')
    grouped_dicoms = _get_grouped_dicoms(dicom_input)

    if _is_4d(grouped_dicoms):
        logger.info('Found sequence type: 4D')
        return _4d_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #23
0
def dicom_to_nifti(dicom_input, output_file):
    """
    This is the main dicom to nifti conversion function for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    :param output_file: filepath to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert is_siemens(dicom_input)

    if _is_4d(dicom_input):
        print('Found sequence type: MOSAIC 4D')
        return _mosaic_4d_to_nifti(dicom_input, output_file)

    grouped_dicoms = _classic_get_grouped_dicoms(dicom_input)
    if _is_classic_4d(grouped_dicoms):
        print('Found sequence type: CLASSIC 4D')
        return _classic_4d_to_nifti(grouped_dicoms, output_file)

    print('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #24
0
def dicom_to_nifti(dicom_input, output_file=None):
    """
    This is the main dicom to nifti conversion function for ge images.
    As input ge images are required. It will then determine the type of images and do the correct conversion

    :param output_file: filepath to the output nifti
    :param dicom_input: directory with dicom files for 1 scan
    """

    assert common.is_siemens(dicom_input)

    if _is_4d(dicom_input):
        logger.info('Found sequence type: MOSAIC 4D')
        return _mosaic_4d_to_nifti(dicom_input, output_file)

    grouped_dicoms = _classic_get_grouped_dicoms(dicom_input)
    if _is_classic_4d(grouped_dicoms):
        logger.info('Found sequence type: CLASSIC 4D')
        return _classic_4d_to_nifti(grouped_dicoms, output_file)

    logger.info('Assuming anatomical data')
    return convert_generic.dicom_to_nifti(dicom_input, output_file)
예제 #25
0
    def test_inconsistent_slice_increment_resampling(self):
        tmp_output_dir = tempfile.mkdtemp()
        try:
            settings.disable_validate_orthogonal()
            settings.disable_validate_slice_increment()
            settings.enable_resampling()
            settings.set_resample_padding(0)
            settings.set_resample_spline_interpolation_order(1)
            results = convert_generic.dicom_to_nifti(
                read_dicom_directory(test_data.FAILING_SLICEINCREMENT_2),
                os.path.join(tmp_output_dir, 'test.nii.gz'))
            assert_compare_nifti(
                results['NII_FILE'],
                ground_thruth_filenames(test_data.FAILING_SLICEINCREMENT_2)[0])
            self.assertTrue(
                isinstance(results['NII'], nibabel.nifti1.Nifti1Image))

        finally:
            settings.disable_resampling()
            settings.enable_validate_slice_increment()
            settings.enable_validate_orientation()
            shutil.rmtree(tmp_output_dir)