# encoding: utf-8
# module dipy.tracking.vox2track
# from C:\Users\xukai\Downloads\发票2\venv\Lib\site-packages\dipy\tracking\vox2track.cp311-win_amd64.pyd
# by generator 1.147
"""
This module contains the parts of dipy.tracking.utils that need to be
implemented in cython.
"""

# 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

# functions

def streamline_mapping(streamlines, affine=None, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    """
    Creates a mapping from voxel indices to streamlines.
    
        Returns a dictionary where each key is a 3d voxel index and the associated
        value is a list of the streamlines that pass through that voxel.
    
        Parameters
        ----------
        streamlines : sequence
            A sequence of streamlines.
        affine : array_like (4, 4), optional
            The mapping from voxel coordinates to streamline coordinates.
            The streamline values are assumed to be in voxel coordinates.
            IE ``[0, 0, 0]`` is the center of the first voxel and the voxel size
            is ``[1, 1, 1]``.
        mapping_as_streamlines : bool, optional, False by default
            If True voxel indices map to lists of streamline objects. Otherwise
            voxel indices map to lists of integers.
    
        Returns
        -------
        mapping : defaultdict(list)
            A mapping from voxel indices to the streamlines that pass through that
            voxel.
    
        Examples
        --------
        >>> streamlines = [np.array([[0., 0., 0.],
        ...                          [1., 1., 1.],
        ...                          [2., 3., 4.]]),
        ...                np.array([[0., 0., 0.],
        ...                          [1., 2., 3.]])]
        >>> mapping = streamline_mapping(streamlines, affine=np.eye(4))
        >>> mapping[0, 0, 0]
        [0, 1]
        >>> mapping[1, 1, 1]
        [0]
        >>> mapping[1, 2, 3]
        [1]
        >>> mapping.get((3, 2, 1), 'no streamlines')
        'no streamlines'
        >>> mapping = streamline_mapping(streamlines, affine=np.eye(4),
        ...                              mapping_as_streamlines=True)
        >>> mapping[1, 2, 3][0] is streamlines[1]
        True
    """
    pass

def track_counts(vs, vox_dim, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    """
    Counts of points in `tracks` that pass through voxels in volume
    
        We find whether a point passed through a track by rounding the mm
        point values to voxels.  For a track that passes through a voxel more
        than once, we only record counts and elements for the first point in
        the line that enters the voxel.
    
        Parameters
        ----------
        tracks : sequence
           sequence of T tracks.  One track is an ndarray of shape (N, 3), where N
           is the number of points in that track, and ``tracks[t][n]`` is the n-th
           point in the t-th track.  Points are of form x, y, z in *voxel mm*
           coordinates. That is, if ``i, j, k`` is the possibly non-integer voxel
           coordinate of the track point, and `vox_sizes` are 3 floats giving voxel
           sizes of dimensions 0, 1, 2 respectively, then the voxel mm coordinates
           ``x, y, z`` are simply ``i * vox_sizes[0], j * vox_sizes[1], k *
           vox_sizes[2]``.  This convention derives from trackviz.  To pass in
           tracks as voxel coordinates, just pass ``vox_sizes=(1, 1, 1)`` (see
           below).
        vol_dims : sequence length 3
           volume dimensions in voxels, x, y, z.
        vox_sizes : optional, sequence length 3
           voxel sizes in mm.  Default is (1,1,1)
        return_elements : {True, False}, optional
           If True, also return object array with one list per voxel giving
           track indices and point indices passing through the voxel (see
           below)
    
        Returns
        -------
        tcs : ndarray shape `vol_dim`
           An array where entry ``tcs[x, y, z]`` is the number of tracks
           that passed through voxel at voxel coordinate x, y, z
        tes : ndarray dtype np.object, shape `vol_dim`
           If `return_elements` is True, we also return an object array with
           one object per voxel. The objects at each voxel are a list of
           integers, where the integers are the indices of the track that
           passed through the voxel.
    
        Examples
        --------
        Imagine you have a volume (voxel) space of dimension ``(10,20,30)``.
        Imagine you had voxel coordinate tracks in ``vs``.  To just fill an array
        with the counts of how many tracks pass through each voxel:
    
        >>> vox_track0 = np.array([[0, 0, 0], [1.1, 2.2, 3.3], [2.2, 4.4, 6.6]])
        >>> vox_track1 = np.array([[0, 0, 0], [0, 0, 1], [0, 0, 2]])
        >>> vs = (vox_track0, vox_track1)
        >>> vox_dim = (10, 20, 30) # original voxel array size
        >>> tcs = track_counts(vs, vox_dim, (1, 1, 1), False)
        >>> tcs.shape
        (10, 20, 30)
        >>> tcs[0, 0, 0:4]
        array([2, 1, 1, 0])
        >>> tcs[1, 2, 3], tcs[2, 4, 7]
        (1, 1)
    
        You can also use the routine to count into larger-than-voxel boxes.  To do
        this, increase the voxel size and decrease the ``vox_dim`` accordingly:
    
        >>> tcs=track_counts(vs, (10/2., 20/2., 30/2.), (2,2,2), False)
        >>> tcs.shape
        (5, 10, 15)
        >>> tcs[1,1,2], tcs[1,2,3]
        (1, 1)
    """
    pass

def _mapping_to_voxel(affine): # reliably restored by inspect
    """
    Inverts affine and returns a mapping so voxel coordinates. This
        function is an implementation detail and only meant to be used with
        ``_to_voxel_coordinates``.
    
        Parameters
        ----------
        affine : array_like (4, 4)
            The mapping from voxel indices, [i, j, k], to real world coordinates.
            The inverse of this mapping is used unless `affine` is None.
    
        Returns
        -------
        lin_T : array (3, 3)
            Transpose of the linear part of the mapping to voxel space, (ie
            ``inv(affine)[:3, :3].T``)
        offset : array or scalar
            Offset part of the mapping (ie, ``inv(affine)[:3, 3]``) + ``.5``. The
            half voxel shift is so that truncating the result of this mapping
            will give the correct integer voxel coordinate.
    
        Raises
        ------
        ValueError
            If both affine and voxel_size are None.
    """
    pass

def _streamlines_in_mask(*args, **kwargs): # real signature unknown
    """
    Filters streamlines based on whether or not they pass through a ROI,
        using a line-based algorithm for compressed streamlines.
    
        This function is private because it's supposed to be called only by
        tracking.utils.target_line_based.
    
        Parameters
        ----------
        streamlines : sequence
            A sequence of streamlines.
        mask : array-like (uint8)
            A mask used as a target. Non-zero values are considered to be within
            the target region.
        lin_T : array (3, 3)
            Transpose of the linear part of the mapping to voxel space. Obtained
            with `_mapping_to_voxel`.
        offset : array or scalar
            Mapping to voxel space. Obtained with `_mapping_to_voxel`.
    
        Returns
        -------
        in_mask : 1D array of bool (uint8), one for each streamline.
            0 if passing through mask, 1 otherwise
            (2 for single-point streamline)
    """
    pass

def _to_voxel_coordinates(streamline, lin_T, offset): # reliably restored by inspect
    """
    Applies a mapping from streamline coordinates to voxel_coordinates,
        raises an error for negative voxel values.
    """
    pass

def _voxel2streamline(*args, **kwargs): # real signature unknown
    """
    Maps voxels to streamlines and streamlines to voxels, for setting up
        the LiFE equations matrix
    
        Parameters
        ----------
        sl : list
            A collection of streamlines, each n by 3, with n being the number of
            nodes in the fiber.
    
        unique_idx : array.
           The unique indices in the streamlines
    
        Returns
        -------
        v2f, v2fn : tuple of dicts
    
        The first dict in the tuple answers the question: Given a voxel (from
        the unique indices in this model), which fibers pass through it?
    
        The second answers the question: Given a streamline, for each voxel that
        this streamline passes through, which nodes of that streamline are in that
        voxel?
    """
    pass

def __pyx_unpickle_Enum(*args, **kwargs): # real signature unknown
    pass

# no classes
# variables with complex values

__loader__ = None # (!) real value is '<_frozen_importlib_external.ExtensionFileLoader object at 0x000001867D409410>'

__spec__ = None # (!) real value is "ModuleSpec(name='dipy.tracking.vox2track', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x000001867D409410>, origin='C:\\\\Users\\\\xukai\\\\Downloads\\\\??2\\\\venv\\\\Lib\\\\site-packages\\\\dipy\\\\tracking\\\\vox2track.cp311-win_amd64.pyd')"

__test__ = {
    'streamline_mapping (line 77)': "Creates a mapping from voxel indices to streamlines.\n\n    Returns a dictionary where each key is a 3d voxel index and the associated\n    value is a list of the streamlines that pass through that voxel.\n\n    Parameters\n    ----------\n    streamlines : sequence\n        A sequence of streamlines.\n    affine : array_like (4, 4), optional\n        The mapping from voxel coordinates to streamline coordinates.\n        The streamline values are assumed to be in voxel coordinates.\n        IE ``[0, 0, 0]`` is the center of the first voxel and the voxel size\n        is ``[1, 1, 1]``.\n    mapping_as_streamlines : bool, optional, False by default\n        If True voxel indices map to lists of streamline objects. Otherwise\n        voxel indices map to lists of integers.\n\n    Returns\n    -------\n    mapping : defaultdict(list)\n        A mapping from voxel indices to the streamlines that pass through that\n        voxel.\n\n    Examples\n    --------\n    >>> streamlines = [np.array([[0., 0., 0.],\n    ...                          [1., 1., 1.],\n    ...                          [2., 3., 4.]]),\n    ...                np.array([[0., 0., 0.],\n    ...                          [1., 2., 3.]])]\n    >>> mapping = streamline_mapping(streamlines, affine=np.eye(4))\n    >>> mapping[0, 0, 0]\n    [0, 1]\n    >>> mapping[1, 1, 1]\n    [0]\n    >>> mapping[1, 2, 3]\n    [1]\n    >>> mapping.get((3, 2, 1), 'no streamlines')\n    'no streamlines'\n    >>> mapping = streamline_mapping(streamlines, affine=np.eye(4),\n    ...                              mapping_as_streamlines=True)\n    >>> mapping[1, 2, 3][0] is streamlines[1]\n    True\n\n    ",
    'track_counts (line 329)': ' Counts of points in `tracks` that pass through voxels in volume\n\n    We find whether a point passed through a track by rounding the mm\n    point values to voxels.  For a track that passes through a voxel more\n    than once, we only record counts and elements for the first point in\n    the line that enters the voxel.\n\n    Parameters\n    ----------\n    tracks : sequence\n       sequence of T tracks.  One track is an ndarray of shape (N, 3), where N\n       is the number of points in that track, and ``tracks[t][n]`` is the n-th\n       point in the t-th track.  Points are of form x, y, z in *voxel mm*\n       coordinates. That is, if ``i, j, k`` is the possibly non-integer voxel\n       coordinate of the track point, and `vox_sizes` are 3 floats giving voxel\n       sizes of dimensions 0, 1, 2 respectively, then the voxel mm coordinates\n       ``x, y, z`` are simply ``i * vox_sizes[0], j * vox_sizes[1], k *\n       vox_sizes[2]``.  This convention derives from trackviz.  To pass in\n       tracks as voxel coordinates, just pass ``vox_sizes=(1, 1, 1)`` (see\n       below).\n    vol_dims : sequence length 3\n       volume dimensions in voxels, x, y, z.\n    vox_sizes : optional, sequence length 3\n       voxel sizes in mm.  Default is (1,1,1)\n    return_elements : {True, False}, optional\n       If True, also return object array with one list per voxel giving\n       track indices and point indices passing through the voxel (see\n       below)\n\n    Returns\n    -------\n    tcs : ndarray shape `vol_dim`\n       An array where entry ``tcs[x, y, z]`` is the number of tracks\n       that passed through voxel at voxel coordinate x, y, z\n    tes : ndarray dtype np.object, shape `vol_dim`\n       If `return_elements` is True, we also return an object array with\n       one object per voxel. The objects at each voxel are a list of\n       integers, where the integers are the indices of the track that\n       passed through the voxel.\n\n    Examples\n    --------\n    Imagine you have a volume (voxel) space of dimension ``(10,20,30)``.\n    Imagine you had voxel coordinate tracks in ``vs``.  To just fill an array\n    with the counts of how many tracks pass through each voxel:\n\n    >>> vox_track0 = np.array([[0, 0, 0], [1.1, 2.2, 3.3], [2.2, 4.4, 6.6]])\n    >>> vox_track1 = np.array([[0, 0, 0], [0, 0, 1], [0, 0, 2]])\n    >>> vs = (vox_track0, vox_track1)\n    >>> vox_dim = (10, 20, 30) # original voxel array size\n    >>> tcs = track_counts(vs, vox_dim, (1, 1, 1), False)\n    >>> tcs.shape\n    (10, 20, 30)\n    >>> tcs[0, 0, 0:4]\n    array([2, 1, 1, 0])\n    >>> tcs[1, 2, 3], tcs[2, 4, 7]\n    (1, 1)\n\n    You can also use the routine to count into larger-than-voxel boxes.  To do\n    this, increase the voxel size and decrease the ``vox_dim`` accordingly:\n\n    >>> tcs=track_counts(vs, (10/2., 20/2., 30/2.), (2,2,2), False)\n    >>> tcs.shape\n    (5, 10, 15)\n    >>> tcs[1,1,2], tcs[1,2,3]\n    (1, 1)\n    ',
}

