How to use the brainspace.vtk_interface.decorators.wrap_input function in brainspace

To help you get started, we’ve selected a few brainspace examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MICA-MNI / BrainSpace / brainspace / vtk_interface / pipeline.py View on Github external
@wrap_input(0, 1)
def connect(ftr0, ftr1, port0=0, port1=0, add_conn=False):
    """Connection of two filters.

    Connects the output port `port0` of filter `ftr0` with the input port
    `port1` of filter `ftr1`.

    Parameters
    ----------
    ftr0 : vtkAlgorithm, vtkDataSet, BSAlgorithm or BSDataSet
        The input filter. May be a filter or dataset.
    ftr1 : vtkAlgorithm or BSAlgorithm
        The output filter.
    port0 : int, optional
        Output port of `ftr0`. Not used if `ftr0` is a dataset. Default is 0.
    port1 : int, optional
        Input port of `ftr1`. Default is 0.
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_operations.py View on Github external
@wrap_input(0)
def _surface_selection(surf, array_name, low=-np.inf, upp=np.inf,
                       use_cell=False, keep=True):
    """Selection of points or cells meeting some thresholding criteria.

    Parameters
    ----------
    surf : vtkPolyData or BSPolyData
        Input surface.
    array_name : str or ndarray
        Array used to perform selection.
    low : float or -np.inf
        Lower threshold. Default is -np.inf.
    upp : float or np.inf
        Upper threshold. Default is +np.inf.
    use_cell : bool, optional
        If True, apply selection to cells. Otherwise, use points.
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_elements.py View on Github external
@wrap_input(0)
def get_cells(surf):
    """Get surface cells.

    Parameters
    ----------
    surf : vtkDataSet or BSDataSet
        Input surface.

    Returns
    -------
    cells : ndarray, shape (n_cells, nd)
        Array of cells. The value of nd depends on the topology. If vertex
        (nd=1), line (nd=2) or poly (nd=3). Each element is a point id.

    Raises
    ------
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_operations.py View on Github external
@wrap_input(0)
def downsample_with_parcellation(surf, labeling, name='parcel',
                                 check_connected=True):
    """ Downsample surface according to the labeling.

    Such that, each parcel centroid is used as a point in the new donwsampled
    surface. Connectivity is based on neighboring parcels.

    Parameters
    ----------
    surf : vtkPolyData or BSPolyData
        Input surface.
    labeling : str or 1D ndarray
        Array of labels used to perform the downsampling. If str, it must be an
        array in the PointData attributes of `surf`.
    name : str, optional
        Name of the downsampled parcellation appended to the PointData of the
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_elements.py View on Github external
@wrap_input(0)
def get_point2cell_connectivity(surf, mask=None, dtype=np.uint8):
    """Get point to cell connectivity.

    Parameters
    ----------
    surf : vtkDataSet or BSDataSet
        Input surface.
    mask : 1D ndarray, optional
        Binary mask. If specified, only get points within the mask.
        Default is None.
    dtype : dtype, optional
        Data type. Default is uint8.

    Returns
    -------
    output : sparse matrix, shape (n_points, n_cells)
github MICA-MNI / BrainSpace / brainspace / vtk_interface / io_support / gifti_support.py View on Github external
@wrap_input(0)
def _write_gifti(pd, opth):
    # TODO: what about pointdata?
    from nibabel.gifti.gifti import GiftiDataArray

    if not pd.has_only_triangle:
        raise ValueError('GIFTI writer only accepts triangles.')

    points = GiftiDataArray(data=pd.Points, intent=INTENT_POINTS)
    cells = GiftiDataArray(data=pd.GetCells2D(), intent=INTENT_CELLS)
    # if data is not None:
    #     data_array = GiftiDataArray(data=data, intent=INTENT_POINTDATA)
    #     gii = nb.gifti.GiftiImage(darrays=[points, cells, data_array])
    # else:
    g = nb.gifti.GiftiImage(darrays=[points, cells])
    nb.save(g, opth)
github MICA-MNI / BrainSpace / brainspace / vtk_interface / pipeline.py View on Github external
@wrap_input(0)
def to_data(ftr, port=0):
    """Extract data from filter.

    Parameters
    ----------
    ftr : vtkAlgorithm or :class:`.BSAlgorithm`
        Input filter.
    port : int, optional
        Port to get data from. When port is -1, refers to all ports.
        Default is 0.

    Returns
    -------
    data : BSDataObject or list of BSDataObject
        Returns the output of the filter. If port is -1 and number of output
        ports > 1, then return list of outputs.
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_elements.py View on Github external
@wrap_input(0)
def get_point2edge_connectivity(surf, mask=None, dtype=np.uint8):
    """Get point to edge connectivity.

    Parameters
    ----------
    surf : vtkDataSet or BSDataSet
        Input surface.
    mask : 1D ndarray, optional
        Binary mask. If specified, only use points within the mask.
        Default is None.
    dtype : dtype, optional
        Data type. Default is uint8.

    Returns
    -------
    output : sparse matrix, shape (n_points, n_edges)
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_creation.py View on Github external
@wrap_input(0)
def to_lines(surf):
    """Convert all cells in PolyData to lines.

    Parameters
    ----------
    surf : vtkPolyData or BSPolyData
        Input surface.

    Returns
    -------
    output : BSPolyData
        PolyData with lines.

    See Also
    --------
    :func:`to_vertex`
github MICA-MNI / BrainSpace / brainspace / mesh / mesh_elements.py View on Github external
@wrap_input(0)
def get_cell2edge_connectivity(surf, mask=None, dtype=np.uint8):
    """Get cell to edge connectivity.

    Parameters
    ----------
    surf : vtkDataSet or BSDataSet
        Input surface.
    mask : 1D ndarray, optional
        Binary mask. If specified, only use points within the mask.
        Default is None.
    dtype : dtype, optional
        Data type. Default is uint8.

    Returns
    -------
    output : sparse matrix, shape (n_cells, n_edges)