pyFM.FMN.FMN.FMN

class pyFM.FMN.FMN.FMN(meshlist, maps_dict=None)

Bases: object

Functional Map Network.

Parameters:
  • meshlist (list) – List of TriMesh objects.

  • maps_dict (dict, optional) – Dictionary of functional maps between each pair of meshes. Keys are (i, j) with i, j indices of the meshes in the list.

property n_meshes

Return the number of meshes (nodes) in the network.

Returns:

n_meshes – Number of meshes in the network.

Return type:

int

property M

Return the current shared dimension for functional maps (which are square matrices).

If not specified, returns the size of the first found map.

Returns:

M – Size of the functional maps.

Return type:

int

property m_cclb

Return the dimension of the Canonical Consistent Latent Basis.

Returns:

m – Size of the CCLB.

Return type:

int

set_maps(maps_dict, verbose=False)

Set the edges of the graph with maps.

Saves extra information about the edges.

Parameters:
  • maps_dict (dict) – Dictionary where key (i, j) gives the functional map FM between mesh i and j. FM can be of different size depending on the edge.

  • verbose (bool, optional) – Whether to print information about the edges being set.

Returns:

self – The current object, with edges set.

Return type:

FMN

set_subsample(subsample)

Set the subsample of vertices on all shapes in the network.

Parameters:

subsample ((n, size) np.ndarray) – Array of indices of vertices to subsample on each shape.

Returns:

self – The current object, with the subsample set.

Return type:

FMN

compute_subsample(size=1000, geodesic=False, verbose=False)

Subsample vertices on each shape using farthest point sampling.

Store the result in an (n, size) array of indices.

Parameters:
  • size (int) – Number of vertices to subsample on each shape.

  • geodesic (bool, optional) – Whether to use geodesic distances for farthest point sampling.

  • verbose (bool, optional) – Whether to print information during computation.

Returns:

The subsample is stored in self.subsample in place.

Return type:

None

set_weights(weights=None, weight_type='icsm', verbose=False)

Set weights for each edge in the graph.

Parameters:
  • weights ((n, n) sparse matrix, optional) – Matrix of edge weights. If not specified, sets weights according to the weight_type argument.

  • weight_type (str, optional) – ‘icsm’ | ‘adjacency’. If weights is not specified, computes weights according to the Consistent Zoomout adaptation of icsm or using the adjacency matrix of the graph.

  • verbose (bool, optional) – Whether to print information during computation.

Returns:

self – The current object, with weights set.

Return type:

FMN

set_isometries(M=None)

Symmetrize functional maps of reciprocal edges.

For each edge (i, j), if (j, i) is also an edge, the corresponding functional maps are set as the transpose of each other, choosing the closest to orthogonal of both.

Since this modifies the maps, icsm weights are deleted.

Parameters:

M (int, optional) – Dimension with which to compare the functional maps. If None, uses the current self.M.

Returns:

The maps are modified in place and map-dependent attributes reset.

Return type:

None

compute_W(M=None, verbose=False)

Compute the quadratic form for Consistent Latent Basis (CLB) computation.

Parameters:
  • M (int, optional) – Size of the functional maps to use; uses the projection of each FM on this dimension. If not specified, uses the size of the first found functional map.

  • verbose (bool, optional) – Whether to print information during computation.

Returns:

The quadratic form is stored in self.W in place.

Return type:

None

compute_CLB(equals_id=False, verbose=False)

Compute the Consistent Latent Basis (CLB) using the quadratic form.

The first M vectors for each basis are computed in order.

Parameters:
  • equals_id (bool, optional) – If False, the sum of Y.T @ Y is expected to give n * Id. If True, the sum of Y.T @ Y is expected to give Id.

  • verbose (bool, optional) – Whether to print information during computation.

Returns:

The CLB is stored in self.CLB in place.

Return type:

None

compute_CCLB(m, verbose=True)

Compute the Canonical Consistent Latent Basis (CCLB) from the CLB.

Parameters:
  • m (int) – Size of the CCLB to compute.

  • verbose (bool, optional) – Whether to print information during computation.

Returns:

self – The current object, with the CCLB computed.

Return type:

FMN

get_CSD(i)

Return the Characteristic Shape Difference (CSD) operators for mesh i.

Parameters:

i (int) – Index of the mesh on which to return the two CSD.

Returns:

  • CSD_a ((m, m) np.ndarray) – Area-based CSD expressed in the latent space.

  • CSD_c ((m, m) np.ndarray) – Conformal CSD expressed in the latent space.

get_LB(i, complete=True)

Return the latent basis (LB) for mesh i.

Parameters:
  • i (int) – Index of the mesh on which to return the LB.

  • complete (bool, optional) – If False, only computes values on the self.subsample[i] vertices.

Returns:

latent_basis – Latent basis on mesh i.

Return type:

(n_i, m) np.ndarray

compute_p2p(complete=True, n_jobs=None)

Compute vertex-to-vertex maps for each (directed) edge from the CCLB.

Uses the factorization of functional maps through the CCLB. Only maps related to existing edges are computed. Vertex-to-vertex maps are saved in a dictionary the same way as functional maps, although their direction is reversed.

Parameters:
  • complete (bool, optional) – If False, uses self.subsample to obtain pointwise maps between subsamples of vertices for each shape.

  • n_jobs (int, optional) – Number of parallel jobs. None (default) decides automatically.

Returns:

The pointwise maps are stored in self.p2p in place.

Return type:

None

compute_maps(M, complete=True)

Convert pointwise maps into functional maps of size M.

Parameters:
  • M (int) – Size of the functional map to compute.

  • complete (bool, optional) – If False and a subsample is set, uses the subsample of vertices to convert the pointwise maps.

Returns:

The functional maps are stored in self.maps in place and map-dependent attributes are reset.

Return type:

None

extract_3_cycles()

Extract all 3-cycles from the graph as a list of 3-tuples (i, j, k).

Returns:

The cycles are stored in self.cycles in place.

Return type:

None

compute_Amat()

Compute matrix A for icsm weights optimization.

Binary matrix telling which edge belongs to which cycle. Uses the arbitrary edge ordering created in the self.set_maps method.

Returns:

The matrix is stored in self.A (as a sparse matrix) and the indices of edges in a cycle in self.A_sub, in place.

Return type:

None

compute_3cycle_weights(M=None)

Compute per-cycle costs and per-edge costs for icsm optimization.

Cycle weights are given by the self.get_cycle_weight method (deviation from the identity map). Each edge weight is the inverse of the sum of all weights of the cycles the edge belongs to.

Parameters:

M (int, optional) – Dimension of functional maps to use. If None, uses self.M.

Returns:

Cycle weights are stored in self.cycle_weight and edge weights in self.edge_weights, in place.

Return type:

None

optimize_icsm(verbose=False)

Solve the linear problem for icsm weights computation.

Solves \(\min w^{\top} x\) subject to \(A x \geq C_{\gamma}\) and \(x \geq 0\). Edges which are not part of a cycle are given zero weights.

Parameters:

verbose (bool, optional) – Whether to print information during optimization.

Returns:

opt_weights – (positive) weights for each edge.

Return type:

(n_edges,) np.ndarray

get_cycle_weight(cycle, M=None)

Compute the cost of a cycle (i, j, k) using the functional maps.

Cost is given as the maximum deviation to the identity map when going through the complete cycle (3 possibilities).

Parameters:
  • cycle (tuple) – 3-tuple with node indices creating a cycle.

  • M (int, optional) – Dimension of functional maps to use. If None, uses self.M.

Returns:

cost – Cost of the cycle.

Return type:

float

zoomout_iteration(cclb_size, M_init, M_final, isometric=True, weight_type='icsm', n_jobs=None, equals_id=False, complete=False)

Perform an iteration of Consistent Zoomout refinement.

Parameters:
  • cclb_size (int) – Size of the CCLB to compute.

  • M_init (int) – Initial dimension of maps.

  • M_final (int) – Dimension at the end of the iteration.

  • isometric (bool, optional) – Whether to use the reduced space strategy of ConsistentZoomout-iso.

  • weight_type (str, optional) – ‘icsm’ or ‘adjacency’, type of weights to use.

  • n_jobs (int, optional) – Number of parallel jobs. None (default) decides automatically.

  • equals_id (bool, optional) – Whether the CLB optimization uses Id or n * Id as a constraint.

  • complete (bool, optional) – Whether vertex-to-vertex and functional maps should be computed with all vertices instead of the subsampling.

Returns:

The maps are refined in place.

Return type:

None

zoomout_refine(nit=10, step=1, subsample=1000, isometric=True, weight_type='icsm', M_init=None, cclb_ratio=0.9, n_jobs=None, equals_id=False, verbose=False)

Refine the functional maps using Consistent Zoomout refinement.

Parameters:
  • nit (int, optional) – Number of zoomout iterations.

  • step (int, optional) – Dimension increase at each iteration.

  • subsample (int or np.ndarray, optional) – Size of vertices subsample. If set to 0 or None, all vertices are used.

  • isometric (bool, optional) – Whether to use the reduced space strategy of ConsistentZoomout-iso.

  • weight_type (str, optional) – ‘icsm’ or ‘adjacency’, type of weights to use.

  • M_init (int, optional) – Original size of functional maps. If None, uses self.M.

  • cclb_ratio (float, optional) – Size of CCLB as a ratio of the current dimension M.

  • n_jobs (int, optional) – Number of parallel jobs. None (default) decides automatically.

  • equals_id (bool, optional) – Whether the CLB optimization uses Id or n * Id as a constraint.

  • verbose (bool, optional) – Whether to print information during refinement.

Returns:

The maps are refined in place.

Return type:

None