spateo.tdr.widgets#

Submodules#

Package Contents#

Classes#

DataSampler

This module loads and retains the data pairs (X, Y) and delivers the batches of them to the DeepInterpolation

DeepInterpolation

A

Base class for all neural network modules.

B

Base class for all neural network modules.

SineLayer

As discussed above, we aim to provide each sine nonlinearity with activations that are standard

h

Base class for all neural network modules.

MainFlow

Base class for all neural network modules.

NLPCA

This is a global solver for principal curves that uses neural networks.

Functions#

ElPiGraph_tree(→ Tuple[numpy.ndarray, numpy.ndarray])

Generate a principal elastic tree.

Principal_Curve(→ Tuple[numpy.ndarray, numpy.ndarray])

This is the global module that contains principal curve and nonlinear principal component analysis algorithms that

SimplePPT_tree(→ Tuple[numpy.ndarray, numpy.ndarray])

Generate a simple principal tree.

changes_along_branch(→ Tuple[Union[pyvista.DataSet, ...)

Find the closest tree node to any point in the model.

changes_along_line(, center, ...)

changes_along_shape(model[, spatial_key, key_added, ...])

map_gene_to_branch(model, tree, key[, nodes_key, inplace])

Find the closest principal tree node to any point in the model through KDTree.

map_points_to_branch(model, nodes[, spatial_key, ...])

Find the closest principal tree node to any point in the model through KDTree.

interactive_box_clip(→ pyvista.MultiBlock)

Pick the interested part of a model using a 3D box widget. Only one model can be generated.

interactive_rectangle_clip(→ pyvista.MultiBlock)

Pick the interested part of a model using a 2D rectangle widget.

deep_intepretation(→ anndata.AnnData)

Learn a continuous mapping from space to gene expression pattern with the deep neural net model.

get_X_Y_grid(→ Tuple[numpy.ndarray, numpy.ndarray, ...)

Prepare the X (spatial coordinates), Y (gene expression) and grid points for the kernel or deep model.

kernel_interpolation(→ anndata.AnnData)

Learn a continuous mapping from space to gene expression pattern with the Kernel method (sparseVFC).

cell_directions(→ Optional[List[anndata.AnnData]])

Obtain the optimal mapping relationship and developmental direction between cells for samples between continuous developmental stages.

morphofield(, inplace, ...)

Calculating and predicting the vector field during development by the Kernel method (sparseVFC).

morphofield_acceleration(→ Optional[anndata.AnnData])

Calculate acceleration for each cell with the reconstructed vector field function.

morphofield_curl(→ Optional[anndata.AnnData])

Calculate curl for each cell with the reconstructed vector field function.

morphofield_curvature(→ Optional[anndata.AnnData])

Calculate curvature for each cell with the reconstructed vector field function.

morphofield_divergence(→ Optional[anndata.AnnData])

Calculate divergence for each cell with the reconstructed vector field function.

morphofield_jacobian(→ Optional[anndata.AnnData])

Calculate jacobian for each cell with the reconstructed vector field function.

morphofield_torsion(→ Optional[anndata.AnnData])

Calculate torsion for each cell with the reconstructed vector field function.

morphofield_velocity(→ Optional[anndata.AnnData])

Calculate the velocity for each cell with the reconstructed vector field function.

morphofield_X(, **kwargs) → dict)

Calculating and predicting the vector field during development by the Kernel method (sparseVFC).

morphopath(→ Optional[anndata.AnnData])

Prediction of cell developmental trajectory based on reconstructed vector field.

model_morphology(→ Dict[str, Union[float, Any]])

Return the basic morphological characteristics of model,

pc_KDE(→ Union[pyvista.PolyData, pyvista.UnstructuredGrid])

Calculate the kernel density of a 3D point cloud model.

weighted_mean(x, weights)

weighted_mad()

Mean absolute difference (weighted)

weighted_mse()

Mean squared error (weighted)

weighted_cosine_distance()

Cosine similarity (weighted)

mad()

Mean absolute difference

mse()

Mean squared error

cosine_distance()

Cosine similarity

interactive_pick(→ pyvista.MultiBlock)

Add a checkbox button widget to pick the desired groups through the interactive window and output the picked groups.

overlap_mesh_pick(→ pyvista.PolyData)

Pick the intersection between two mesh models.

overlap_pc_pick(→ [pyvista.PolyData, pyvista.PolyData])

Pick the point cloud inside the mesh model and point cloud outside the mesh model.

overlap_pick(main_mesh, other_mesh[, main_pc, other_pc])

Add a checkbox button widget to pick the desired groups through the interactive window and output the picked groups.

three_d_pick(→ pyvista.MultiBlock)

Pick the desired groups.

interactive_slice(→ pyvista.MultiBlock)

Create a slice of the input dataset along a specified axis or

three_d_slice(, center, ...)

Create many slices of the input dataset along a specified axis or

DDRTree(X[, maxIter, sigma, gamma, eps, dim, Lambda, ...])

This function is a pure Python implementation of the DDRTree algorithm.

cal_ncenter(ncells[, ncells_limit])

interpolate_model(model, source[, source_key, radius, ...])

Interpolate over source to port its data onto the current object using various kernels.

spateo.tdr.widgets.ElPiGraph_tree(X: numpy.ndarray, NumNodes: int = 50, **kwargs) Tuple[numpy.ndarray, numpy.ndarray][source]#

Generate a principal elastic tree. Reference: Albergante et al. (2020), Robust and Scalable Learning of Complex Intrinsic Dataset Geometry via ElPiGraph.

Parameters
X

DxN, data matrix list.

NumNodes

The number of nodes of the principal graph. Use a range of 10 to 100 for ElPiGraph approach.

**kwargs

Other parameters used in elpigraph.computeElasticPrincipalTree. For details, please see: https://github.com/j-bac/elpigraph-python/blob/master/elpigraph/_topologies.py

Returns

The nodes in the principal tree. edges: The edges between nodes in the principal tree.

Return type

nodes

spateo.tdr.widgets.Principal_Curve(X: numpy.ndarray, NumNodes: int = 50, scale_factor: Union[int, float] = 1, **kwargs) Tuple[numpy.ndarray, numpy.ndarray][source]#

This is the global module that contains principal curve and nonlinear principal component analysis algorithms that work to optimize a line over an entire dataset. Reference: Chen et al. (2016), Constraint local principal curve: Concept, algorithms and applications.

Parameters
X

DxN, data matrix list.

NumNodes

Number of nodes for the construction layers. Defaults to 25. The more complex the curve, the higher this number should be.

scale_factor

**kwargs

Other parameters used in global algorithms. For details, please see: https://github.com/artusoma/prinPy/blob/master/prinpy/glob.py

Returns

The nodes in the principal tree. edges: The edges between nodes in the principal tree.

Return type

nodes

spateo.tdr.widgets.SimplePPT_tree(X: numpy.ndarray, NumNodes: int = 50, **kwargs) Tuple[numpy.ndarray, numpy.ndarray][source]#

Generate a simple principal tree. Reference: Mao et al. (2015), SimplePPT: A simple principal tree algorithm, SIAM International Conference on Data Mining.

Parameters
X

DxN, data matrix list.

NumNodes

The number of nodes of the principal graph. Use a range of 100 to 2000 for PPT approach.

**kwargs

Other parameters used in simpleppt.ppt. For details, please see: https://github.com/LouisFaure/simpleppt/blob/main/simpleppt/ppt.py

Returns

The nodes in the principal tree. edges: The edges between nodes in the principal tree.

Return type

nodes

spateo.tdr.widgets.changes_along_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], spatial_key: Optional[str] = None, map_key: Union[str, list] = None, nodes_key: str = 'nodes', key_added: str = 'tree', label: str = 'tree', rd_method: Literal[ElPiGraph, SimplePPT, PrinCurve] = 'ElPiGraph', NumNodes: int = 50, color: str = 'gainsboro', inplace: bool = False, **kwargs) Tuple[Union[pyvista.DataSet, pyvista.PolyData, pyvista.UnstructuredGrid], pyvista.PolyData, float][source]#

Find the closest tree node to any point in the model.

Parameters
model

A reconstructed model.

spatial_key

If spatial_key is None, the spatial coordinates are in model.points, otherwise in model[spatial_key].

map_key

The key in model that corresponds to the gene expression.

nodes_key

The key that corresponds to the coordinates of the nodes in the tree.

key_added

The key that corresponds to tree label.

label

The label of tree model.

rd_method

The method of constructing a tree.

NumNodes

Number of nodes for the tree model.

color

Color to use for plotting tree model.

inplace

Updates model in-place.

Returns

Updated model if inplace is True. tree_model: A three-dims principal tree model. tree_length: The length of the tree model.

Return type

model

spateo.tdr.widgets.changes_along_line(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], key: Union[str, list] = None, n_points: int = 100, vec: Union[tuple, list] = (1, 0, 0), center: Union[tuple, list] = None) Tuple[numpy.ndarray, numpy.ndarray, pyvista.MultiBlock, pyvista.MultiBlock][source]#
spateo.tdr.widgets.changes_along_shape(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], spatial_key: Optional[str] = None, key_added: Optional[str] = 'rd_spatial', dim: int = 2, inplace: bool = False, **kwargs)[source]#
spateo.tdr.widgets.map_gene_to_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], tree: pyvista.PolyData, key: Union[str, list], nodes_key: Optional[str] = 'nodes', inplace: bool = False)[source]#

Find the closest principal tree node to any point in the model through KDTree.

Parameters
model

A reconstructed model contains the gene expression label.

tree

A three-dims principal tree model contains the nodes label.

key

The key that corresponds to the gene expression.

nodes_key

The key that corresponds to the coordinates of the nodes in the tree.

inplace

Updates tree model in-place.

Returns

tree.point_data[key], the gene expression array.

Return type

A tree, which contains the following properties

spateo.tdr.widgets.map_points_to_branch(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], nodes: numpy.ndarray, spatial_key: Optional[str] = None, key_added: Optional[str] = 'nodes', inplace: bool = False, **kwargs)[source]#

Find the closest principal tree node to any point in the model through KDTree.

Parameters
model

A reconstructed model.

nodes

The nodes in the principal tree.

spatial_key

The key that corresponds to the coordinates of the point in the model. If spatial_key is None, the coordinates are model.points.

key_added

The key under which to add the nodes labels.

inplace

Updates model in-place.

kwargs

Other parameters used in scipy.spatial.KDTree.

Returns

model.point_data[key_added], the nodes labels array.

Return type

A model, which contains the following properties

spateo.tdr.widgets.interactive_box_clip(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: str = 'groups', invert: bool = False) pyvista.MultiBlock[source]#

Pick the interested part of a model using a 3D box widget. Only one model can be generated.

Parameters
model

Reconstructed 3D model.

key

The key under which are the labels.

invert

Flag on whether to flip/invert the pick.

Returns

A MultiBlock that contains all models you picked.

Return type

picked_model

spateo.tdr.widgets.interactive_rectangle_clip(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: str = 'groups', invert: bool = False, bg_model=None) pyvista.MultiBlock[source]#

Pick the interested part of a model using a 2D rectangle widget. Multiple models can be generated at the same time.

Parameters
model

Reconstructed 3D model.

key

The key under which are the labels.

invert

Flag on whether to flip/invert the pick.

bg_model

A visualization-only background model to help clip our target model.

Returns

A MultiBlock that contains all models you picked.

Return type

picked_model

class spateo.tdr.widgets.DataSampler(path_to_data: Union[str, None] = None, data: Union[anndata.AnnData, dict, None] = None, skey: str = 'spatial', ekey: str = 'M_s', wkey: Union[str, None] = None, normalize_data: bool = False, number_of_random_samples: str = 'all', weighted: bool = False)[source]#

Bases: object

This module loads and retains the data pairs (X, Y) and delivers the batches of them to the DeepInterpolation module upon calling. The module can load tha data from a .mat file. The file must contain two 2D matrices X and Y with equal rows.

X: The spatial coordinates of each cell / binning / segmentation. Y: The expression values at the corresponding coordinates X.

generate_batch(batch_size: int, sample_subset_indices: str = 'all')#

Generate random batches of the given size “batch_size” from the (X, Y) sample pairs.

Parameters
batch_size

If the batch_size is set to “all”, all the samples will be returned.

sample_subset_indices

This argument is used when you want to further subset the samples (based on the factors such as quality of the samples). If set to “all”, it means it won’t filter out samples based on their qualities.

class spateo.tdr.widgets.DeepInterpolation(model: types.ModuleType, data_sampler: object, sirens: bool = False, enforce_positivity: bool = False, loss_function: Union[Callable, None] = weighted_mse(), smoothing_factor: Union[float, None] = True, stability_factor: Union[float, None] = True, load_model_from_buffer: bool = False, buffer_path: str = 'model_buffer/', hidden_features: int = 256, hidden_layers: int = 3, first_omega_0: float = 30.0, hidden_omega_0: float = 30.0, **kwargs)[source]#
high2low(high_batch)#
low2high(low_batch)#
predict(input_x=None, to_numpy=True)#
train(max_iter: int, data_batch_size: int, autoencoder_batch_size: int, data_lr: float, autoencoder_lr: float, sample_fraction: float = 1, iter_per_sample_update: Union[int, None] = None)#

The training method for the DeepInterpolation model object

Parameters
max_iter

The maximum iteration the network will be trained.

data_batch_size

The size of the data sample batches to be generated in each iteration.

autoencoder_batch_size

The size of the auto-encoder training batches to be generated in each iteration. Must be no greater than batch_size. .

data_lr

The learning rate for network training.

autoencoder_lr

The learning rate for network training the auto-encoder. Will have no effect if network_dim equal data_dim.

sample_fraction

The best sample fraction to be filtered out of the velocity samples.

iter_per_sample_update

The frequency of updating the subset of best samples (in terms of per iterations). Will have no effect if velocity_sample_fraction and time_course_sample_fraction are set to 1.

save()#
load()#
class spateo.tdr.widgets.A(network_dim, data_dim, hidden_features=256, hidden_layers=1, activation_function=torch.nn.functional.leaky_relu)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables
training : bool

Boolean represents whether this module is in training or evaluation mode.

forward(inp)#
class spateo.tdr.widgets.B(network_dim, data_dim, hidden_features=256, hidden_layers=3, activation_function=torch.nn.functional.leaky_relu)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables
training : bool

Boolean represents whether this module is in training or evaluation mode.

forward(inp)#
class spateo.tdr.widgets.SineLayer(in_features, out_features, bias=True, is_first=False, omega_0=30.0)[source]#

Bases: torch.nn.Module

As discussed above, we aim to provide each sine nonlinearity with activations that are standard normal distributed, except in the case of the first layer, where we introduced a factor ω0 that increased the spatial frequency of the first layer to better match the frequency spectrum of the signal. However, we found that the training of SIREN can be accelerated by leveraging a factor ω0 in all layers of the SIREN, by factorizing the weight matrix W as W = Wˆ ∗ ω0, choosing. This keeps the distribution of activations constant, but boosts gradients to the weight matrix Wˆ by the factor ω0 while leaving gradients w.r.t. the input of the sine neuron unchanged

init_weights()#
forward(input)#
forward_with_intermediate(input)#
class spateo.tdr.widgets.h(input_network_dim, output_network_dim, hidden_features=256, hidden_layers=3, sirens=False, first_omega_0=30.0, hidden_omega_0=30.0)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables
training : bool

Boolean represents whether this module is in training or evaluation mode.

forward(inp)#
class spateo.tdr.widgets.MainFlow(h, A=None, B=None, enforce_positivity=False)[source]#

Bases: torch.nn.Module

Base class for all neural network modules.

Your models should also subclass this class.

Modules can also contain other Modules, allowing to nest them in a tree structure. You can assign the submodules as regular attributes:

import torch.nn as nn
import torch.nn.functional as F

class Model(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(1, 20, 5)
        self.conv2 = nn.Conv2d(20, 20, 5)

    def forward(self, x):
        x = F.relu(self.conv1(x))
        return F.relu(self.conv2(x))

Submodules assigned in this way will be registered, and will have their parameters converted too when you call to(), etc.

Note

As per the example above, an __init__() call to the parent class must be made before assignment on the child.

Variables
training : bool

Boolean represents whether this module is in training or evaluation mode.

forward(t, x, freeze=None)#
spateo.tdr.widgets.deep_intepretation(adata: Optional[anndata.AnnData] = None, genes: Optional[List] = None, X: Optional[numpy.ndarray] = None, Y: Optional[numpy.ndarray] = None, NX: Optional[numpy.ndarray] = None, grid_num: List = [50, 50, 50], **kwargs) anndata.AnnData[source]#

Learn a continuous mapping from space to gene expression pattern with the deep neural net model.

Parameters
adata

AnnData object that contains spatial (numpy.ndarray) in the obsm attribute.

genes

Gene list whose interpolate expression across space needs to learned. If Y is provided, genes will only be used to retrive the gene annotation info.

X

The spatial coordinates of each data point.

Y

The gene expression of the corresponding data point.

NX

The spatial coordinates of new data point. If NX is None, generate new points based on grid_num.

grid_num

Number of grid to generate. Default is 50 for each dimension. Must be non-negative.

**kwargs

Additional parameters that will be passed to the training step of the deep neural net.

Returns

an anndata object that has interpolated expression. The row of the adata object is a grid point within the convex hull formed by the input data points while each column corresponds a gene whose expression values are interpolated.

Return type

interp_adata

spateo.tdr.widgets.get_X_Y_grid(adata: Optional[anndata.AnnData] = None, genes: Optional[List] = None, X: Optional[numpy.ndarray] = None, Y: Optional[numpy.ndarray] = None, grid_num: List = [50, 50, 50]) Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray][source]#

Prepare the X (spatial coordinates), Y (gene expression) and grid points for the kernel or deep model.

Parameters
adata

AnnData object that contains spatial (numpy.ndarray) in the obsm attribute.

genes

Gene list whose interpolate expression across space needs to learned. If Y is provided, genes will only be used to retrive the gene annotation info.

X

The spatial coordinates of each data point.

Y

The gene expression of the corresponding data point.

grid_num

Number of grid to generate. Default is 50 for each dimension. Must be non-negative.

Returns

spatial coordinates. Y: gene expression of the associated spatial coordinates. Grid: grid points formed with the input spatial coordinates. grid_in_hull: A list of booleans indicates whether the current grid points is within the convex hull formed by

the input data points.

Return type

X

spateo.tdr.widgets.kernel_interpolation(adata: Optional[anndata.AnnData] = None, genes: Optional[List] = None, X: Optional[numpy.ndarray] = None, Y: Optional[numpy.ndarray] = None, NX: Optional[numpy.ndarray] = None, grid_num: List = [50, 50, 50], lambda_: float = 0.02, lstsq_method: str = 'scipy', **kwargs) anndata.AnnData[source]#

Learn a continuous mapping from space to gene expression pattern with the Kernel method (sparseVFC).

Parameters
adata

AnnData object that contains spatial (numpy.ndarray) in the obsm attribute.

genes

Gene list whose interpolate expression across space needs to learned. If Y is provided, genes will only be used to retrive the gene annotation info.

X

The spatial coordinates of each data point.

Y

The gene expression of the corresponding data point.

NX

The spatial coordinates of new data point. If NX is None, generate new points based on grid_num.

grid_num

Number of grid to generate. Default is 50 for each dimension. Must be non-negative.

lambda

Represents the trade-off between the goodness of data fit and regularization. Larger Lambda_ put more weights on regularization.

lstsq_method

The name of the linear least square solver, can be either ‘scipy` or douin.

**kwargs

Additional parameters that will be passed to SparseVFC function.

Returns

an anndata object that has interpolated expression. The row of the adata object is a grid point within the convex hull formed by the input data points while each column corresponds a gene whose expression values are interpolated.

Return type

interp_adata

spateo.tdr.widgets.cell_directions(adatas: List[anndata.AnnData], layer: str = 'X', genes: Optional[Union[list, numpy.ndarray]] = None, spatial_key: str = 'align_spatial', key_added: str = 'mapping', alpha: float = 0.001, numItermax: int = 200, numItermaxEmd: int = 100000, dtype: str = 'float32', device: str = 'cpu', keep_all: bool = False, inplace: bool = True, **kwargs) Optional[List[anndata.AnnData]][source]#

Obtain the optimal mapping relationship and developmental direction between cells for samples between continuous developmental stages.

Parameters
adatas

AnnData object of samples from continuous developmental stages.

layer

If 'X', uses .X to calculate dissimilarity between spots, otherwise uses the representation given by .layers[layer].

genes

Genes used for calculation. If None, use all common genes for calculation.

spatial_key

The key in .obsm that corresponds to the spatial coordinate of each cell.

.uns. : The key that will be used for the vector field key in

key_added

The key that will be used in .obsm.

  • X_{key_added}-The X_{key_added} that will be used for the coordinates of the cell that maps optimally in the next stage.

  • V_{key_added}-The V_{key_added} that will be used for the cell developmental directions.

alpha

Alignment tuning parameter. Note: 0 <= alpha <= 1.

When alpha = 0 only the gene expression data is taken into account, while when alpha =1 only the spatial coordinates are taken into account.

numItermax

Max number of iterations for cg during FGW-OT.

numItermaxEmd

Max number of iterations for emd during FGW-OT.

dtype

The floating-point number type. Only float32 and float64.

device

Equipment used to run the program. You can also set the specified GPU for running. E.g.: '0'

keep_all

Whether to retain all the optimal relationships obtained only based on the pi matrix, If keep_all is False, the optimal relationships obtained based on the pi matrix and the nearest coordinates.

inplace

Whether to copy adata or modify it inplace.

**kwargs

Additional parameters that will be passed to pairwise_align function.

Returns

An AnnData object is updated/copied with the X_{key_added} and V_{key_added} in the .obsm attribute.

spateo.tdr.widgets.morphofield(adata: anndata.AnnData, spatial_key: str = 'align_spatial', V_key: str = 'V_mapping', key_added: str = 'VecFld_morpho', NX: Optional[numpy.ndarray] = None, grid_num: Optional[List[int]] = None, M: int = 100, lambda_: float = 0.02, lstsq_method: str = 'scipy', min_vel_corr: float = 0.8, restart_num: int = 10, restart_seed: Union[List[int], Tuple[int], numpy.ndarray] = (0, 100, 200, 300, 400), inplace: bool = True, **kwargs) Optional[anndata.AnnData][source]#

Calculating and predicting the vector field during development by the Kernel method (sparseVFC).

Parameters
adata

AnnData object that contains the cell coordinates of the two states after alignment.

spatial_key

The key from the .obsm that corresponds to the spatial coordinates of each cell.

V_key

The key from the .obsm that corresponds to the developmental direction of each cell.

key_added

The key that will be used for the vector field key in .uns.

NX

The spatial coordinates of new data point. If NX is None, generate new points based on grid_num.

grid_num

The number of grids in each dimension for generating the grid velocity. Default is [50, 50, 50].

M

The number of basis functions to approximate the vector field.

lambda

Represents the trade-off between the goodness of data fit and regularization. Larger Lambda_ put more weights on regularization.

lstsq_method

The name of the linear least square solver, can be either 'scipy' or 'douin'.

min_vel_corr

The minimal threshold for the cosine correlation between input velocities and learned velocities to consider as a successful vector field reconstruction procedure. If the cosine correlation is less than this threshold and restart_num > 1, restart_num trials will be attempted with different seeds to reconstruct the vector field function. This can avoid some reconstructions to be trapped in some local optimal.

restart_num

The number of retrials for vector field reconstructions.

restart_seed

A list of seeds for each retrial. Must be the same length as restart_num or None.

inplace

Whether to copy adata or modify it inplace.

**kwargs

Additional parameters that will be passed to SparseVFC function.

Returns

An AnnData object is updated/copied with the key_added dictionary in the .uns attribute.

The key_added dictionary which contains:

X: Current state. valid_ind: The indices of cells that have finite velocity values. X_ctrl: Sample control points of current state. ctrl_idx: Indices for the sampled control points. Y: Velocity estimates in delta t. beta: Parameter of the Gaussian Kernel for the kernel matrix (Gram matrix). V: Prediction of velocity of X. C: Finite set of the coefficients for the P: Posterior probability Matrix of inliers. VFCIndex: Indexes of inliers found by sparseVFC. sigma2: Energy change rate. grid: Grid of current state. grid_V: Prediction of velocity of the grid. iteration: Number of the last iteration. tecr_vec: Vector of relative energy changes rate comparing to previous step. E_traj: Vector of energy at each iteration. method: The method of learning vector field. Here method == ‘sparsevfc’.

Here the most important results are X, V, grid and grid_V.

X: Cell coordinates of the current state. V: Developmental direction of the X. grid: Grid coordinates of current state. grid_V: Prediction of developmental direction of the grid.

spateo.tdr.widgets.morphofield_acceleration(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'acceleration', method: str = 'analytical', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate acceleration for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the acceleration key in .obs and .obsm.

method

The method that will be used for calculating acceleration field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating acceleration while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing acceleration. 'analytical' method is much more efficient.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs and .obsm attribute.

The key_added in the .obs which contains acceleration. The key_added in the .obsm which contains acceleration vectors.

spateo.tdr.widgets.morphofield_curl(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'curl', method: str = 'analytical', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate curl for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the torsion key in .obs.

method

The method that will be used for calculating torsion field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating torsion while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing torsion. 'analytical' method is much more efficient.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs and .obsm attribute.

The key_added in the .obs which contains magnitude of curl. The key_added in the .obsm which contains curl vectors.

spateo.tdr.widgets.morphofield_curvature(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'curvature', formula: int = 2, method: str = 'analytical', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate curvature for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the curvature key in .obs and .obsm.

formula

Which formula of curvature will be used, there are two formulas, so formula can be either {1, 2}. By default it is 2 and returns both the curvature vectors and the norm of the curvature. The formula one only gives the norm of the curvature.

method

The method that will be used for calculating curvature field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating curvature while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing curvature. 'analytical' method is much more efficient.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs and .obsm attribute.

The key_added in the .obs which contains curvature. The key_added in the .obsm which contains curvature vectors.

spateo.tdr.widgets.morphofield_divergence(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'divergence', method: str = 'analytical', vectorize_size: Optional[int] = 1000, inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate divergence for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the acceleration key in .obs and .obsm.

method

The method that will be used for calculating acceleration field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating acceleration while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing acceleration. 'analytical' method is much more efficient.

vectorize_size

vectorize_size is used to control the number of samples computed in each vectorized batch.

  • If vectorize_size = 1, there’s no vectorization whatsoever.

  • If vectorize_size = None, all samples are vectorized.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs attribute.

The key_added in the .obs which contains divergence.

spateo.tdr.widgets.morphofield_jacobian(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'jacobian', method: str = 'analytical', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate jacobian for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the jacobian key in .obs and .obsm.

method

The method that will be used for calculating jacobian field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating jacobian while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing jacobian. 'analytical' method is much more efficient.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs and .uns attribute.

The key_added in the .obs which contains jacobian. The key_added in the .uns which contains jacobian tensor.

spateo.tdr.widgets.morphofield_torsion(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'torsion', method: str = 'analytical', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate torsion for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the torsion key in .obs and .obsm.

method

The method that will be used for calculating torsion field, either 'analytical' or 'numerical'.

'analytical' method uses the analytical expressions for calculating torsion while 'numerical' method uses numdifftools, a numerical differentiation tool, for computing torsion. 'analytical' method is much more efficient.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obs and .uns attribute.

The key_added in the .obs which contains torsion. The key_added in the .uns which contains torsion matrix.

spateo.tdr.widgets.morphofield_velocity(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'velocity', inplace: bool = True) Optional[anndata.AnnData][source]#

Calculate the velocity for each cell with the reconstructed vector field function.

Parameters
adata

AnnData object that contains the reconstructed vector field.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key that will be used for the velocity key in .obsm.

inplace

Whether to copy adata or modify it inplace.

Returns

An AnnData object is updated/copied with the key_added in the .obsm attribute which contains velocities.

spateo.tdr.widgets.morphofield_X(X: numpy.ndarray, V: numpy.ndarray, NX: Optional[numpy.ndarray] = None, grid_num: Optional[List[int]] = None, M: int = 100, lambda_: float = 0.02, lstsq_method: str = 'scipy', min_vel_corr: float = 0.8, restart_num: int = 10, restart_seed: Union[List[int], Tuple[int], numpy.ndarray] = (0, 100, 200, 300, 400), **kwargs) dict[source]#

Calculating and predicting the vector field during development by the Kernel method (sparseVFC).

Parameters
X

The spatial coordinates of each cell.

V

The developmental direction of each cell.

NX

The spatial coordinates of new data point (grid). If NX is None, generate grid based on grid_num.

grid_num

The number of grids in each dimension for generating the grid velocity. Default is [50, 50, 50].

M

The number of basis functions to approximate the vector field.

lambda

Represents the trade-off between the goodness of data fit and regularization. Larger Lambda_ put more weights on regularization.

lstsq_method

The name of the linear least square solver, can be either 'scipy' or 'douin'.

min_vel_corr

The minimal threshold for the cosine correlation between input velocities and learned velocities to consider as a successful vector field reconstruction procedure. If the cosine correlation is less than this threshold and restart_num > 1, restart_num trials will be attempted with different seeds to reconstruct the vector field function. This can avoid some reconstructions to be trapped in some local optimal.

restart_num

The number of retrials for vector field reconstructions.

restart_seed

A list of seeds for each retrial. Must be the same length as restart_num or None.

**kwargs

Additional parameters that will be passed to SparseVFC function.

Returns

X: Current state.

valid_ind: The indices of cells that have finite velocity values. X_ctrl: Sample control points of current state. ctrl_idx: Indices for the sampled control points. Y: Velocity estimates in delta t. beta: Parameter of the Gaussian Kernel for the kernel matrix (Gram matrix). V: Prediction of velocity of X. C: Finite set of the coefficients for the P: Posterior probability Matrix of inliers. VFCIndex: Indexes of inliers found by sparseVFC. sigma2: Energy change rate. grid: Grid of current state. grid_V: Prediction of velocity of the grid. iteration: Number of the last iteration. tecr_vec: Vector of relative energy changes rate comparing to previous step. E_traj: Vector of energy at each iteration. method: The method of learning vector field. Here method == ‘sparsevfc’.

Here the most important results are X, V, grid and grid_V.

X: Cell coordinates of the current state. V: Developmental direction of the X. grid: Grid coordinates of current state. grid_V: Prediction of developmental direction of the grid.

Return type

A dictionary which contains

spateo.tdr.widgets.morphopath(adata: anndata.AnnData, vf_key: str = 'VecFld_morpho', key_added: str = 'fate_morpho', layer: str = 'X', direction: str = 'forward', interpolation_num: int = 250, t_end: Optional[Union[int, float]] = None, average: bool = False, cores: int = 1, inplace: bool = True, **kwargs) Optional[anndata.AnnData][source]#

Prediction of cell developmental trajectory based on reconstructed vector field.

Parameters
adata

AnnData object that contains the reconstructed vector field function in the .uns attribute.

vf_key

The key in .uns that corresponds to the reconstructed vector field.

key_added

The key under which to add the dictionary Fate (includes t and prediction keys).

layer

Which layer of the data will be used for predicting cell fate with the reconstructed vector field function.

direction

The direction to predict the cell fate. One of the forward, backward or both string.

interpolation_num

The number of uniformly interpolated time points.

t_end

The length of the time period from which to predict cell state forward or backward over time.

average

The method to calculate the average cell state at each time step, can be one of origin or trajectory. If origin used, the average expression state from the init_cells will be calculated and the fate prediction is based on this state. If trajectory used, the average expression states of all cells predicted from the vector field function at each time point will be used. If average is False, no averaging will be applied.

cores

Number of cores to calculate path integral for predicting cell fate. If cores is set to be > 1, multiprocessing will be used to parallel the fate prediction.

inplace

Whether to copy adata or modify it inplace.

**kwargs

Additional parameters that will be passed into the fate function.

Returns

An AnnData object is updated/copied with the key_added dictionary in the .uns attribute.

The key_added dictionary which contains:

t: The time at which the cell state are predicted. prediction: Predicted cells states at different time points. Row order corresponds to the element order in

t. If init_states corresponds to multiple cells, the expression dynamics over time for each cell is concatenated by rows. That is, the final dimension of prediction is (len(t) * n_cells, n_features). n_cells: number of cells; n_features: number of genes or number of low dimensional embeddings. Of note, if the average is set to be True, the average cell state at each time point is calculated for all cells.

spateo.tdr.widgets.model_morphology(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], pc: Optional[PolyData or UnstructuredGrid] = None) Dict[str, Union[float, Any]][source]#

Return the basic morphological characteristics of model, including model volume, model surface area, volume / surface area ratio,etc.

Parameters
model

A reconstructed surface model or volume model.

pc

A point cloud representing the number of cells.

Returns

A dictionary containing the following model morphological features:

morphology[‘Length(x)’]: Length (x) of model. morphology[‘Width(y)’]: Width (y) of model. morphology[‘Height(z)’]: Height (z) of model. morphology[‘Surface_area’]: Surface area of model. morphology[‘Volume’]: Volume of model. morphology[‘V/SA_ratio’]: Volume / surface area ratio of model; morphology[‘cell_density’]: Cell density of model.

Return type

morphology

spateo.tdr.widgets.pc_KDE(pc: pyvista.PolyData, key_added: str = 'kde', kernel: str = 'gaussian', bandwidth: float = 1.0, colormap: Union[str, list, dict] = 'hot_r', alphamap: Union[float, list, dict] = 1.0, inplace: bool = False) Union[pyvista.PolyData, pyvista.UnstructuredGrid][source]#

Calculate the kernel density of a 3D point cloud model.

Parameters
pc

A point cloud model.

key_added

The key under which to add the labels.

kernel

The kernel to use. Available kernel are: * ‘gaussian’ * ‘tophat’ * ‘epanechnikov’ * ‘exponential’ * ‘linear’ * ‘cosine’

bandwidth

The bandwidth of the kernel.

colormap

Colors to use for plotting pcd. The default colormap is ‘hot_r’.

alphamap

The opacity of the colors to use for plotting pcd. The default alphamap is 1.0.

inplace

Updates model in-place.

Returns

Reconstructed 3D point cloud, which contains the following properties:

pc[key_added], the kernel density.

Return type

pc

spateo.tdr.widgets.weighted_mean(x, weights)[source]#
spateo.tdr.widgets.weighted_mad()[source]#

Mean absolute difference (weighted)

spateo.tdr.widgets.weighted_mse()[source]#

Mean squared error (weighted)

spateo.tdr.widgets.weighted_cosine_distance()[source]#

Cosine similarity (weighted)

spateo.tdr.widgets.mad()[source]#

Mean absolute difference

spateo.tdr.widgets.mse()[source]#

Mean squared error

spateo.tdr.widgets.cosine_distance()[source]#

Cosine similarity

spateo.tdr.widgets.interactive_pick(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: str = 'groups', checkbox_size: int = 27, label_size: int = 12) pyvista.MultiBlock[source]#

Add a checkbox button widget to pick the desired groups through the interactive window and output the picked groups.

Parameters
model

Reconstructed 3D model.

key

The key under which are the groups.

checkbox_size

The size of the button in number of pixels.

label_size

The font size of the checkbox labels.

Returns

A MultiBlock that contains all models you picked.

spateo.tdr.widgets.overlap_mesh_pick(mesh1: pyvista.PolyData, mesh2: pyvista.PolyData) pyvista.PolyData[source]#

Pick the intersection between two mesh models.

Parameters
mesh1

Reconstructed 3D mesh model.

mesh2

Reconstructed 3D mesh model.

Returns

The intersection mesh model.

Return type

select_mesh

spateo.tdr.widgets.overlap_pc_pick(pc: pyvista.PolyData, mesh: pyvista.PolyData) [pyvista.PolyData, pyvista.PolyData][source]#

Pick the point cloud inside the mesh model and point cloud outside the mesh model.

Parameters
pc

Reconstructed 3D point cloud model corresponding to mesh.

mesh

Reconstructed 3D mesh model.

Returns

Point cloud inside the mesh model. outside_pc: Point cloud outside the mesh model.

Return type

inside_pc

spateo.tdr.widgets.overlap_pick(main_mesh: pyvista.PolyData, other_mesh: pyvista.PolyData, main_pc: Optional[pyvista.PolyData] = None, other_pc: Optional[pyvista.PolyData] = None)[source]#

Add a checkbox button widget to pick the desired groups through the interactive window and output the picked groups.

Parameters
main_mesh

Reconstructed 3D mesh model.

other_mesh

Reconstructed 3D mesh model.

main_pc

Reconstructed 3D point cloud model corresponding to main_mesh.

other_pc

Reconstructed 3D point cloud model corresponding to other_mesh.

Returns

A MultiBlock that contains all models you picked.

spateo.tdr.widgets.three_d_pick(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: str = 'groups', picked_groups: Union[str, list] = None) pyvista.MultiBlock[source]#

Pick the desired groups.

spateo.tdr.widgets.interactive_slice(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid, pyvista.MultiBlock], key: str = 'groups', method: Literal[interactive_slice.axis, orthogonal] = 'axis', axis: Literal[x, y, z] = 'x') pyvista.MultiBlock[source]#

Create a slice of the input dataset along a specified axis or create three orthogonal slices through the dataset on the three cartesian planes.

Parameters
model

Reconstructed 3D model.

key

The key under which are the labels.

method

The methods of slicing a model. Available method are: * ‘axis’: Create a slice of the input dataset along a specified axis. * ‘orthogonal’: Create three orthogonal slices through the dataset on the three cartesian planes.

axis

The axis to generate the slices along. Only works when method is ‘axis’.

Returns

A MultiBlock that contains all models you sliced.

Return type

sliced_model

spateo.tdr.widgets.three_d_slice(model: Union[pyvista.PolyData, pyvista.UnstructuredGrid], method: Literal[three_d_slice.axis, orthogonal, three_d_slice.line] = 'axis', n_slices: int = 10, axis: Literal[x, y, z] = 'x', vec: Union[tuple, list] = (1, 0, 0), center: Union[tuple, list] = None) Union[pyvista.PolyData, Tuple[pyvista.MultiBlock, pyvista.MultiBlock, pyvista.PolyData]][source]#

Create many slices of the input dataset along a specified axis or create three orthogonal slices through the dataset on the three cartesian planes or slice a model along a vector direction perpendicularly.

Parameters
model

Reconstructed 3D model.

method

The methods of slicing a model. Available method are: * ‘axis’: Create many slices of the input dataset along a specified axis. * ‘orthogonal’: Create three orthogonal slices through the dataset on the three cartesian planes.

This method is usually used interactively without entering a position which slices are taken.

  • ’line’: Slice a model along a vector direction perpendicularly.

n_slices

The number of slices to create along a specified axis. Only works when method is ‘axis’ or ‘line’.

axis

The axis to generate the slices along. Only works when method is ‘axis’.

vec

The vector direction. Only works when method is ‘line’.

center

A 3-length sequence specifying the position which slices are taken. Defaults to the center of the model.

Returns

If method is ‘axis’ or ‘orthogonal’, return a MultiBlock that contains all models you sliced; else return a tuple that contains line model, all models you sliced and intersections of slices model and line model.

class spateo.tdr.widgets.NLPCA[source]#

Bases: object

This is a global solver for principal curves that uses neural networks. .. attribute:: None

fit(data: numpy.ndarray, epochs: int = 500, nodes: int = 25, lr: float = 0.01, verbose: int = 0)#

This method creates a model and will fit it to the given m x n dimensional data.

Parameters
data

A numpy array of shape (m,n), where m is the number of points and n is the number of dimensions.

epochs

Number of epochs to train neural network, defaults to 500.

nodes

Number of nodes for the construction layers. Defaults to 25. The more complex the curve, the higher this number should be.

lr

Learning rate for backprop. Defaults to .01

verbose

Verbose = 0 mutes the training text from Keras. Defaults to 0.

project(data: numpy.ndarray) Tuple[numpy.ndarray, numpy.ndarray]#

The project function will project the points to the curve generated by the fit function. Given back is the projection index of the original data and a sorted version of the original data.

Parameters
data

m x n array to project to the curve

Returns

A one-dimension array that contains the projection index for each point in data. all_sorted: A m x n+1 array that contains data sorted by its projection index, along with the index.

Return type

proj

create_model(num_dim: int, nodes: int, lr: float)#

Creates a tf model.

Parameters
num_dim

How many dimensions the input space is

nodes

How many nodes for the construction layers

lr

Learning rate of backpropigation

Returns

Keras Model

Return type

model (object)

spateo.tdr.widgets.DDRTree(X: numpy.ndarray, maxIter: int = 20, sigma: Union[int, float] = 0.001, gamma: Union[int, float] = 10, eps: int = 0, dim: int = 2, Lambda: Union[int, float] = 1.0, ncenter: Optional[int] = None)[source]#

This function is a pure Python implementation of the DDRTree algorithm.

Parameters
X

DxN, data matrix list.

maxIter

Maximum iterations.

eps

Relative objective difference.

dim

Reduced dimension.

Lambda

Regularization parameter for inverse graph embedding.

sigma

Bandwidth parameter.

gamma

Regularization parameter for k-means.

ncenter

number of nodes allowed in the regularization graph

Returns

A tuple of Z, Y, stree, R, W, Q, C, objs

W is the orthogonal set of d (dimensions) linear basis vector Z is the reduced dimension space stree is the smooth tree graph embedded in the low dimension space Y represents latent points as the center of

spateo.tdr.widgets.cal_ncenter(ncells, ncells_limit=100)[source]#
spateo.tdr.widgets.interpolate_model(model, source, source_key: Union[str, list] = None, radius: Optional[float] = None, N: Optional[int] = None, kernel: Literal[shepard, gaussian, linear] = 'shepard', where: Literal[point_data, cell_data] = 'cell_data', nullStrategy: Literal[0, 1, 2] = 1, nullValue: Union[int, float] = 0)[source]#

Interpolate over source to port its data onto the current object using various kernels.

Parameters
model

Model that require interpolation.

source

A data source that provides coordinates and data. Usually a point cloud object.

source_key

Which data to migrate to the model object. If source_key is None, migrate all to the model object.

radius

Set the radius of the point cloud. If you are generating a Gaussian distribution, then this is the standard deviation for each of x, y, and z.

N

Specify the number of points for the source object to hold. If N (number of the closest points to use) is set then radius value is ignored.

kernel

The kernel of interpolation kernel. Available kernels are: * shepard: vtkShepardKernel is an interpolation kernel that uses the method of Shepard to perform

interpolation. The weights are computed as 1/r^p, where r is the distance to a neighbor point within the kernel radius R; and p (the power parameter) is a positive exponent (typically p=2).

  • gaussian: vtkGaussianKernel is an interpolation kernel that simply returns the weights for all

    points found in the sphere defined by radius R. The weights are computed as: exp(-(s*r/R)^2) where r is the distance from the point to be interpolated to a neighboring point within R. The sharpness s simply affects the rate of fall off of the Gaussian.

  • linear: vtkLinearKernel is an interpolation kernel that averages the contributions of all points in

    the basis.

where

The location where the data is stored in the model.

nullStrategy

Specify a strategy to use when encountering a “null” point during the interpolation process.

Null points occur when the local neighborhood(of nearby points to interpolate from) is empty.

  • Case 0: an output array is created that marks points as being valid (=1) or null (invalid =0), and

    the nullValue is set as well

  • Case 1: the output data value(s) are set to the provided nullValue

  • Case 2: simply use the closest point to perform the interpolation.

nullValue

see above.

Returns

Interpolated model.

Return type

interpolated_model