o
    i                  	   @   s   d Z ddlmZ ddlmZ zddlZW n	 ey   Y nw ddlm	Z	 ddl
mZ ddlmZmZmZmZmZmZ ddlmZmZmZm Z!m"Z#m$Z%m&Z'm(Z)m*Z+ d	e,d
dddfddZ-eeeeeee%e+dZ.eeee!e#e'e)dZ/de0defddZ1dS )z2Utility functions used in the pixel data handlers.    )	byteorder)AnyN)config)warn_and_log)apply_color_lutapply_modality_lutapply_voi_lut	apply_voiapply_windowingconvert_color_space)	expand_ybr422get_expected_lengthget_image_pixel_idsget_j2k_parametersget_nr_frames	pack_bitspixel_dtypereshape_pixel_arrayunpack_bitsis_little_endiannumpy_dtypeznp.dtypereturnc                 C   s*   | du rt d| tdkkr|dS |S )a  Return a :class:`numpy.dtype` corrected for system and :class:`Dataset`
    endianness.

    .. deprecated:: 3.0

        This function will be removed in v4.0.

    Parameters
    ----------
    is_little_endian : bool
        The endianness of the affected :class:`~pydicom.dataset.Dataset`.
    numpy_dtype : numpy.dtype
        The numpy data type used for the *Pixel Data* without considering
        endianness.

    Raises
    ------
    ValueError
        If `is_little_endian` is ``None``, e.g. not initialized.

    Returns
    -------
    numpy.dtype
        The numpy data type used for the *Pixel Data* without considering
        endianness.
    NzMDataset attribute 'is_little_endian' has to be set before writing the datasetlittleS)
ValueErrorr   newbyteorder)r   r    r   V/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/pydicom/pixel_data_handlers/util.py_dtype_corrected_for_endianness&   s   
r   )r   r   r   r	   r
   r   r   r   )r   r   r   r   r   r   r   namec                 C   s   | t v rtjsd|  d}t|t t |  S | tv r,tjs,d|  d}t|t t|  S | dkr<tjs<d}t|t tS tdtd| )NziThe 'pydicom.pixel_data_handlers' module will be removed in v4.0, please use 'from pydicom.pixels import z	' insteadzoThe 'pydicom.pixel_data_handlers' module will be removed in v4.0, please use 'from pydicom.pixels.utils import dtype_corrected_for_endiannesszJ'dtype_corrected_for_endianness' is deprecated and will be removed in v4.0zmodule z has no attribute )	_DEPRECATEDr   _use_futurer   DeprecationWarning_DEPRECATED_UTILr   AttributeError__name__)r   msgr   r   r   __getattr__d   s(   


r(   )2__doc__sysr   typingr   numpynpImportErrorpydicomr   pydicom.miscr   pydicom.pixels.processingr   _apply_color_lutr   _apply_modality_lutr   _apply_voi_lutr	   
_apply_voir
   _apply_windowingr   _convert_color_spacepydicom.pixels.utilsr   _expand_ybr422r   _get_expected_lengthr   _get_image_pixel_idsr   _get_j2k_parametersr   _get_nr_framesr   
_pack_bitsr   _pixel_dtyper   _reshape_pixel_arrayr   _unpack_bitsboolr   r!   r$   strr(   r   r   r   r   <module>   sJ    ,
*