# encoding: utf-8
# module dipy.align.parzenhist
# from C:\Users\xukai\Downloads\发票2\venv\Lib\site-packages\dipy\align\parzenhist.cp311-win_amd64.pyd
# by generator 1.147
# no doc

# imports
import builtins as __builtins__ # <module 'builtins' (built-in)>
import numpy as np # C:\Users\xukai\Downloads\发票2\venv\Lib\site-packages\numpy\__init__.py
import numpy.random as random # C:\Users\xukai\Downloads\发票2\venv\Lib\site-packages\numpy\random\__init__.py
import dipy.align.vector_fields as vf # C:\Users\xukai\Downloads\发票2\venv\Lib\site-packages\dipy\align\vector_fields.cp311-win_amd64.pyd

# functions

def compute_parzen_mi(*args, **kwargs): # real signature unknown
    """
    Computes the mutual information and its gradient (if requested)
    
        Parameters
        ----------
        joint : array, shape (nbins, nbins)
            the joint intensity distribution
        joint_gradient : array, shape (nbins, nbins, n)
            the gradient of the joint distribution w.r.t. the transformation
            parameters
        smarginal : array, shape (nbins,)
            the marginal intensity distribution of the static image
        mmarginal : array, shape (nbins,)
            the marginal intensity distribution of the moving image
        mi_gradient : array, shape (n,)
            the buffer in which to write the gradient of the mutual information.
            If None, the gradient is not computed
    """
    pass

def cubic_spline(*args, **kwargs): # real signature unknown
    """
    Evaluates the cubic spline at a set of values
    
        Parameters
        ----------
        x : array, shape (n)
            input values
    """
    pass

def cubic_spline_derivative(*args, **kwargs): # real signature unknown
    """
    Evaluates the cubic spline derivative at a set of values
    
        Parameters
        ----------
        x : array, shape (n)
            input values
    """
    pass

def sample_domain_regular(k, shape, grid2world, sigma): # real signature unknown; restored from __doc__
    """
    Take floor(total_voxels/k) samples from a (2D or 3D) grid
    
        The sampling is made by taking all pixels whose index (in lexicographical
        order) is a multiple of k. Each selected point is slightly perturbed by
        adding a realization of a normally distributed random variable and then
        mapped to physical space by the given grid-to-space transform.
    
        The lexicographical order of a pixels in a grid of shape (a, b, c) is
        defined by assigning to each voxel position (i, j, k) the integer index
    
        F((i, j, k)) = i * (b * c) + j * (c) + k
    
        and sorting increasingly by this index.
    
        Parameters
        ----------
        k : int
            the sampling rate, as described before
        shape : array, shape (dim,)
            the shape of the grid to be sampled
        grid2world : array, shape (dim+1, dim+1)
            the grid-to-space transform
        sigma : float
            the standard deviation of the Normal random distortion to be applied
            to the sampled points
    
        Returns
        -------
        samples : array, shape (total_pixels//k, dim)
            the matrix whose rows are the sampled points
    
        Examples
        --------
        >>> from dipy.align.parzenhist import sample_domain_regular
        >>> import dipy.align.vector_fields as vf
        >>> shape = np.array((10, 10), dtype=np.int32)
        >>> sigma = 0
        >>> dim = len(shape)
        >>> grid2world = np.eye(dim+1)
        >>> n = shape[0]*shape[1]
        >>> k = 2
        >>> samples = sample_domain_regular(k, shape, grid2world, sigma)
        >>> (samples.shape[0], samples.shape[1]) == (n//k, dim)
        True
        >>> isamples = np.array(samples, dtype=np.int32)
        >>> indices = (isamples[:, 0] * shape[1] + isamples[:, 1])
        >>> len(set(indices)) == len(indices)
        True
        >>> (indices%k).sum()
        0
    """
    pass

def __pyx_unpickle_Enum(*args, **kwargs): # real signature unknown
    pass

# classes

class ParzenJointHistogram(object):
    # no doc
    def bin_index(self, *args, **kwargs): # real signature unknown
        """
        Bin index associated with the given normalized intensity
        
                The return value is an integer in [padding, nbins - 1 - padding]
        
                Parameters
                ----------
                xnorm : float
                    intensity value normalized to the range covered by the histogram
        
                Returns
                -------
                bin : int
                    the bin index associated with the given normalized intensity
        """
        pass

    def bin_normalize_moving(self, *args, **kwargs): # real signature unknown
        """
        Maps intensity x to the range covered by the moving histogram
        
                If the input intensity is in [self.mmin, self.mmax] then the normalized
                intensity will be in [self.padding, self.nbins - self.padding]
        
                Parameters
                ----------
                x : float
                    the intensity to be normalized
        
                Returns
                -------
                xnorm : float
                    normalized intensity to the range covered by the moving histogram
        """
        pass

    def bin_normalize_static(self, *args, **kwargs): # real signature unknown
        """
        Maps intensity x to the range covered by the static histogram
        
                If the input intensity is in [self.smin, self.smax] then the normalized
                intensity will be in [self.padding, self.nbins - self.padding]
        
                Parameters
                ----------
                x : float
                    the intensity to be normalized
        
                Returns
                -------
                xnorm : float
                    normalized intensity to the range covered by the static histogram
        """
        pass

    def setup(self, *args, **kwargs): # real signature unknown
        """
        Compute histogram settings to store the PDF of input images
        
                Parameters
                ----------
                static : array
                    static image
                moving : array
                    moving image
                smask : array
                    mask of static object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    If None, the behaviour is equivalent to smask=ones_like(static)
                mmask : array
                    mask of moving object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    If None, the behaviour is equivalent to mmask=ones_like(static)
        """
        pass

    def update_gradient_dense(self, *args, **kwargs): # real signature unknown
        """
        Computes the Gradient of the joint PDF w.r.t. transform parameters
        
                Computes the vector of partial derivatives of the joint histogram
                w.r.t. each transformation parameter.
        
                The gradient is stored in self.joint_grad.
        
                Parameters
                ----------
                theta : array, shape (n,)
                    parameters of the transformation to compute the gradient from
                transform : instance of Transform
                    the transformation with respect to whose parameters the gradient
                    must be computed
                static : array, shape (S, R, C)
                    static image
                moving : array, shape (S, R, C)
                    moving image
                grid2world : array, shape (4, 4)
                    we assume that both images have already been sampled at a common
                    grid. This transform must map voxel coordinates of this common grid
                    to physical coordinates of its corresponding voxel in the moving
                    image. For example, if the moving image was sampled on the static
                    image's grid (this is the typical setting) using an aligning
                    matrix A, then
        
                    (1) grid2world = A.dot(static_affine)
        
                    where static_affine is the transformation mapping static image's
                    grid coordinates to physical space.
        
                mgradient : array, shape (S, R, C, 3)
                    the gradient of the moving image
                smask : array, shape (S, R, C), optional
                    mask of static object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    The default is None, indicating all voxels are considered.
                mmask : array, shape (S, R, C), optional
                    mask of moving object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    The default is None, indicating all voxels are considered.
        """
        pass

    def update_gradient_sparse(self, *args, **kwargs): # real signature unknown
        """
        Computes the Gradient of the joint PDF w.r.t. transform parameters
        
                Computes the vector of partial derivatives of the joint histogram
                w.r.t. each transformation parameter.
        
                The list of intensities `sval` and `mval` are assumed to be sampled
                from the static and moving images, respectively, at the same
                physical points. Of course, the images may not be perfectly aligned
                at the moment the sampling was performed. The resulting  gradient
                corresponds to the paired intensities according to the alignment at the
                moment the images were sampled.
        
                The gradient is stored in self.joint_grad.
        
                Parameters
                ----------
                theta : array, shape (n,)
                    parameters to compute the gradient at
                transform : instance of Transform
                    the transformation with respect to whose parameters the gradient
                    must be computed
                sval : array, shape (m,)
                    sampled intensities from the static image at sampled_points
                mval : array, shape (m,)
                    sampled intensities from the moving image at sampled_points
                sample_points : array, shape (m, 3)
                    coordinates (in physical space) of the points the images were
                    sampled at
                mgradient : array, shape (m, 3)
                    the gradient of the moving image at the sample points
        """
        pass

    def update_pdfs_dense(self, *args, **kwargs): # real signature unknown
        """
        Computes the Probability Density Functions of two images
        
                The joint PDF is stored in self.joint. The marginal distributions
                corresponding to the static and moving images are computed and
                stored in self.smarginal and self.mmarginal, respectively.
        
                Parameters
                ----------
                static : array, shape (S, R, C)
                    static image
                moving : array, shape (S, R, C)
                    moving image
                smask : array, shape (S, R, C)
                    mask of static object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    If None, ones_like(static) is used as mask.
                mmask : array, shape (S, R, C)
                    mask of moving object being registered (a binary array with 1's
                    inside the object of interest and 0's along the background).
                    If None, ones_like(moving) is used as mask.
        """
        pass

    def update_pdfs_sparse(self, *args, **kwargs): # real signature unknown
        """
        Computes the Probability Density Functions from a set of samples
        
                The list of intensities `sval` and `mval` are assumed to be sampled
                from the static and moving images, respectively, at the same
                physical points. Of course, the images may not be perfectly aligned
                at the moment the sampling was performed. The resulting  distributions
                corresponds to the paired intensities according to the alignment at the
                moment the images were sampled.
        
                The joint PDF is stored in self.joint. The marginal distributions
                corresponding to the static and moving images are computed and
                stored in self.smarginal and self.mmarginal, respectively.
        
                Parameters
                ----------
                sval : array, shape (n,)
                    sampled intensities from the static image at sampled_points
                mval : array, shape (n,)
                    sampled intensities from the moving image at sampled_points
        """
        pass

    def __init__(self, *args, **kwargs): # real signature unknown
        """
        Computes joint histogram and derivatives with Parzen windows
        
                Base class to compute joint and marginal probability density
                functions and their derivatives with respect to a transform's
                parameters. The smooth histograms are computed by using Parzen
                windows [Parzen62] with a cubic spline kernel, as proposed by
                Mattes et al. [Mattes03]. This implementation is not tied to any
                optimization (registration) method, the idea is that
                information-theoretic matching functionals (such as Mutual
                Information) can inherit from this class to perform the low-level
                computations of the joint intensity distributions and its gradient
                w.r.t. the transform parameters. The derived class can then compute
                the similarity/dissimilarity measure and gradient, and finally
                communicate the results to the appropriate optimizer.
        
                Parameters
                ----------
                nbins : int
                    the number of bins of the joint and marginal probability density
                    functions (the actual number of bins of the joint PDF is nbins**2)
        
                References
                ----------
                [Parzen62] E. Parzen. On the estimation of a probability density
                           function and the mode. Annals of Mathematical Statistics,
                           33(3), 1065-1076, 1962.
                [Mattes03] Mattes, D., Haynor, D. R., Vesselle, H., Lewellen, T. K.,
                           & Eubank, W. PET-CT image registration in the chest using
                           free-form deformations. IEEE Transactions on Medical
                           Imaging, 22(1), 120-8, 2003.
        
                Notes
                -----
                We need this class in cython to allow _joint_pdf_gradient_dense_2d and
                _joint_pdf_gradient_dense_3d to use a nogil Jacobian function (obtained
                from an instance of the Transform class), which allows us to evaluate
                Jacobians at all the sampling points (maybe the full grid) inside a
                nogil loop.
        
                The reason we need a class is to encapsulate all the parameters related
                to the joint and marginal distributions.
        """
        pass

    __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """list of weak references to the object (if defined)"""


    __dict__ = None # (!) real value is "mappingproxy({'__module__': 'dipy.align.parzenhist', '__init__': <cyfunction ParzenJointHistogram.__init__ at 0x0000020137215220>, 'setup': <cyfunction ParzenJointHistogram.setup at 0x00000201372152F0>, 'bin_normalize_static': <cyfunction ParzenJointHistogram.bin_normalize_static at 0x00000201372153C0>, 'bin_normalize_moving': <cyfunction ParzenJointHistogram.bin_normalize_moving at 0x0000020137215490>, 'bin_index': <cyfunction ParzenJointHistogram.bin_index at 0x0000020137215630>, 'update_pdfs_dense': <cyfunction ParzenJointHistogram.update_pdfs_dense at 0x0000020137215700>, 'update_pdfs_sparse': <cyfunction ParzenJointHistogram.update_pdfs_sparse at 0x00000201372157D0>, 'update_gradient_dense': <cyfunction ParzenJointHistogram.update_gradient_dense at 0x00000201372158A0>, 'update_gradient_sparse': <cyfunction ParzenJointHistogram.update_gradient_sparse at 0x0000020137215970>, '__dict__': <attribute '__dict__' of 'ParzenJointHistogram' objects>, '__weakref__': <attribute '__weakref__' of 'ParzenJointHistogram' objects>, '__doc__': None})"


# variables with complex values

__loader__ = None # (!) real value is '<_frozen_importlib_external.ExtensionFileLoader object at 0x000002017FD6BB10>'

__spec__ = None # (!) real value is "ModuleSpec(name='dipy.align.parzenhist', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x000002017FD6BB10>, origin='C:\\\\Users\\\\xukai\\\\Downloads\\\\??2\\\\venv\\\\Lib\\\\site-packages\\\\dipy\\\\align\\\\parzenhist.cp311-win_amd64.pyd')"

__test__ = {
    'sample_domain_regular (line 1292)': ' Take floor(total_voxels/k) samples from a (2D or 3D) grid\n\n    The sampling is made by taking all pixels whose index (in lexicographical\n    order) is a multiple of k. Each selected point is slightly perturbed by\n    adding a realization of a normally distributed random variable and then\n    mapped to physical space by the given grid-to-space transform.\n\n    The lexicographical order of a pixels in a grid of shape (a, b, c) is\n    defined by assigning to each voxel position (i, j, k) the integer index\n\n    F((i, j, k)) = i * (b * c) + j * (c) + k\n\n    and sorting increasingly by this index.\n\n    Parameters\n    ----------\n    k : int\n        the sampling rate, as described before\n    shape : array, shape (dim,)\n        the shape of the grid to be sampled\n    grid2world : array, shape (dim+1, dim+1)\n        the grid-to-space transform\n    sigma : float\n        the standard deviation of the Normal random distortion to be applied\n        to the sampled points\n\n    Returns\n    -------\n    samples : array, shape (total_pixels//k, dim)\n        the matrix whose rows are the sampled points\n\n    Examples\n    --------\n    >>> from dipy.align.parzenhist import sample_domain_regular\n    >>> import dipy.align.vector_fields as vf\n    >>> shape = np.array((10, 10), dtype=np.int32)\n    >>> sigma = 0\n    >>> dim = len(shape)\n    >>> grid2world = np.eye(dim+1)\n    >>> n = shape[0]*shape[1]\n    >>> k = 2\n    >>> samples = sample_domain_regular(k, shape, grid2world, sigma)\n    >>> (samples.shape[0], samples.shape[1]) == (n//k, dim)\n    True\n    >>> isamples = np.array(samples, dtype=np.int32)\n    >>> indices = (isamples[:, 0] * shape[1] + isamples[:, 1])\n    >>> len(set(indices)) == len(indices)\n    True\n    >>> (indices%k).sum()\n    0\n    ',
}

