# Path: dicom2nifti/exceptions.py
# class ConversionValidationError(Exception):
#     """
#     Custom error type to distinguish between know validations and script errors
#     """
# 
#     def __init__(self, message):
#         # Call the base class constructor with the parameters it needs
#         super(ConversionValidationError, self).__init__(message)
# 
# class ConversionError(Exception):
#     """
#     Custom error type to distinguish between know validations and script errors
#     """
# 
#     def __init__(self, message):
#         # Call the base class constructor with the parameters it needs
#         super(ConversionError, self).__init__(message)


import dicom2nifti.compressed_dicom as compressed_dicom
import os
import struct
import logging
import numpy
import dicom2nifti.settings
from pydicom.tag import Tag
from dicom2nifti.exceptions import ConversionValidationError, ConversionError
    if diff_z >= diff_x and diff_z >= diff_y:
        return dicom_input_sorted_z


def validate_slice_increment(dicoms):
    """
    Validate that the distance between all slices is equal (or very close to)

    :param dicoms: list of dicoms
    """

    # if only one slice we do not need to run the checks
    if len(dicoms) == 1:
        return

    first_image_position = numpy.array(dicoms[0].ImagePositionPatient)
    previous_image_position = numpy.array(dicoms[1].ImagePositionPatient)

    increment = first_image_position - previous_image_position
    for dicom_ in dicoms[2:]:
        current_image_position = numpy.array(dicom_.ImagePositionPatient)
        current_increment = previous_image_position - current_image_position
        if not numpy.allclose(increment, current_increment, rtol=0.05, atol=0.1):
            logger.warning('Slice increment not consistent through all slices')
            logger.warning('---------------------------------------------------------')
            logger.warning('%s %s' % (previous_image_position, increment))
            logger.warning('%s %s' % (current_image_position, current_increment))
            if 'InstanceNumber' in dicom_:
                logger.warning('Instance Number: %s' % dicom_.InstanceNumber)
            logger.warning('---------------------------------------------------------')

# Path: dicom2nifti/exceptions.py
# class ConversionValidationError(Exception):
#     """
#     Custom error type to distinguish between know validations and script errors
#     """
# 
#     def __init__(self, message):
#         # Call the base class constructor with the parameters it needs
#         super(ConversionValidationError, self).__init__(message)
# 
# class ConversionError(Exception):
#     """
#     Custom error type to distinguish between know validations and script errors
#     """
# 
#     def __init__(self, message):
#         # Call the base class constructor with the parameters it needs
#         super(ConversionError, self).__init__(message)


# Path: dicom2nifti/common.py
import dicom2nifti.compressed_dicom as compressed_dicom
import os
import struct
import logging
import numpy
import dicom2nifti.settings
from pydicom.tag import Tag
from dicom2nifti.exceptions import ConversionValidationError, ConversionError

    if diff_z >= diff_x and diff_z >= diff_y:
        return dicom_input_sorted_z


def validate_slice_increment(dicoms):
    """
    Validate that the distance between all slices is equal (or very close to)

    :param dicoms: list of dicoms
    """

    # if only one slice we do not need to run the checks
    if len(dicoms) == 1:
        return

    first_image_position = numpy.array(dicoms[0].ImagePositionPatient)
    previous_image_position = numpy.array(dicoms[1].ImagePositionPatient)

    increment = first_image_position - previous_image_position
    for dicom_ in dicoms[2:]:
        current_image_position = numpy.array(dicom_.ImagePositionPatient)
        current_increment = previous_image_position - current_image_position
        if not numpy.allclose(increment, current_increment, rtol=0.05, atol=0.1):
            logger.warning('Slice increment not consistent through all slices')
            logger.warning('---------------------------------------------------------')
            logger.warning('%s %s' % (previous_image_position, increment))
            logger.warning('%s %s' % (current_image_position, current_increment))
            if 'InstanceNumber' in dicom_:
                logger.warning('Instance Number: %s' % dicom_.InstanceNumber)
            logger.warning('---------------------------------------------------------')

            raise ConversionValidationError('SLICE_INCREMENT_INCONSISTENT')