pyFM.FMN.FMN¶
- class pyFM.FMN.FMN(meshlist, maps_dict=None)¶
Functional Map Network Class
- Parameters:
meshlist (list) – list of TriMesh objects
maps_dict (dict, optional) – dictionnary of functional maps between each pair of meshes. Keys are (i,j) with i,j indices of the meshes in the list.
- __init__(meshlist, maps_dict=None)¶
Methods
__init__
(meshlist[, maps_dict])compute_3cycle_weights
([M])Compute per-cycle costs and per-edge costs for icsm optimization.
compute_Amat
()Compute matrix A for icsm weights optimization.
compute_CCLB
(m[, verbose])Compute the Canonical Consistent Latent Basis CCLB from the CLB.
compute_CLB
([equals_id, verbose])Computes the Consistent Latent Basis CLB using the quadratic form associated to the problem.
compute_W
([M, verbose])Computes the quadratic form for Consistent Latent Basis (CLB) computation.
compute_maps
(M[, complete])Convert pointwise maps into Functional Maps of size M.
compute_p2p
([complete, n_jobs])Computes vertex to vertex maps for each (directed) edge using the factorization of functional maps CCLB.
compute_subsample
([size, geodesic, verbose])Subsample vertices on each shape using farthest point sampling.
extract_3_cycles
()Extract all 3-cycles from the graph in a list of 3-uple (i,j,k)
get_CSD
(i)Returns the Characterisic Shape Difference operators CSD for mesh i
get_LB
(i[, complete])Returns the latent basis LB for mesh i
get_cycle_weight
(cycle[, M])Given a cycle (i,j,k), compute its cost using the functional maps.
optimize_icsm
([verbose])Solves the linear problem for icsm weights computation $min w^{top} x$ s.t.
set_isometries
([M])For each edge (i,j), if (j,i) is also an edge then, the corresponding functional maps are set as transpose of each other chosing the closest to orthogonal of both.
set_maps
(maps_dict[, verbose])Set the edges of the graph with maps.
set_subsample
(subsample)Set subsamples an all shapes in the network
set_weights
([weights, weight_type, verbose])Set weights for each edge in the graph
zoomout_iteration
(cclb_size, M_init, M_final)Performs an iteration of Consistent Zoomout refinement
zoomout_refine
([nit, step, subsample, ...])Refines the functional maps using Consistent Zoomout refinement
Attributes
M
Return the current shared dimension for functional maps (which are square matrices).
m_cclb
Return the dimension of the Canonical Consistent Latent Basis
n_meshes
- property M¶
Return the current shared dimension for functional maps (which are square matrices).
If not specified, returns the sized 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) – dictionnary, key (i,j) gives functional map FM between mesh i and j. FM can be of different size depending on the edge
- set_subsample(subsample)¶
Set subsamples an all shapes in the network
- Parameters:
subsample – (n, size) array of indices of vertices to subsample on each shape
- compute_subsample(size=1000, geodesic=False, verbose=False)¶
Subsample vertices on each shape using farthest point sampling. Store in an (n,size) array of indices
- Parameters:
size (int) – number of vertices to subsample on each shape
- set_weights(weights=None, weight_type='icsm', verbose=False)¶
Set weights for each edge in the graph
- Parameters:
weights (sparse) – (n,n) matrix. If not specified, sets weights according to ‘weight_type’ argument
weight_type – ‘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.
- set_isometries(M=None)¶
For each edge (i,j), if (j,i) is also an edge then, the corresponding functional maps are set as transpose of each other chosing the closest to orthogonal of both.
Since this modifies the maps, icsm weights are deleted
- Parameters:
M (int) – dimension with wich to compare the functional maps. If None, uses the current self.M
- compute_W(M=None, verbose=False)¶
Computes the quadratic form for Consistent Latent Basis (CLB) computation.
- Parameters:
M (int, optional) – size of the functional maps to use, uses projection of FM on this dimension. If not specified, used the size of the first found functional map
- compute_CLB(equals_id=False, verbose=False)¶
Computes the Consistent Latent Basis CLB using the quadratic form associated to the problem. The first M vectors for each basis are computed in order.
- Parameters:
equals_id (bool) – If False, the sum of Y.T@Y are expected to give n*Id. If True, the sum of Y.T@Y are expected to give Id.
- compute_CCLB(m, verbose=True)¶
Compute the Canonical Consistent Latent Basis CCLB from the CLB.
- Parameters:
m (int) – size of the CCLB to compute.
- get_CSD(i)¶
Returns the Characterisic Shape Difference operators CSD for mesh i
- Parameters:
i (int) – index of the mesh on which to returns the two CSD
- Returns:
CSD_a (np.ndarray) – (m,m) array of area CSD expressed in the Latent Space
CSD_c (np.ndarray) – (m,m) array of conformal CSD expressed in the Latent Space
- get_LB(i, complete=True)¶
Returns the latent basis LB for mesh i
- Parameters:
i (int) – index of the mesh on which to returns the LB
complete (bool) – If False, only computes values on the self.subsample[i] vertices
- Returns:
latent_basis – (n_i,m) latent basis on mesh i
- Return type:
np.ndarray
- compute_p2p(complete=True, n_jobs=1)¶
Computes vertex to vertex maps for each (directed) edge using the factorization of functional maps CCLB. Only maps related to existing edges are computed. Vertex to vertex maps are saved in a dictionnary the same way as functional maps, although their direction are reversed.
- Parameters:
complete (bool) – If False, uses self.subsample to obtain pointwise maps between subsamples of vertices for each shape
- compute_maps(M, complete=True)¶
Convert pointwise maps into Functional Maps of size M.
- Parameters:
M (int) – size of the functional map to compute
- extract_3_cycles()¶
Extract all 3-cycles from the graph in a list of 3-uple (i,j,k)
- compute_Amat()¶
Compute matrix A for icsm weights optimization. Binary matrix telling which edge belongs to which cycle. Uses the arbitraty edge ordering createede in the self.set_maps method
- 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 Id map) Edge weight is the inverse of the sum of all weights of the cycles the edge belongs to.
- Parameters:
M (int) – Dimension of functional maps to use. If None, uses self.M
- optimize_icsm(verbose=False)¶
Solves the linear problem for icsm weights computation \(\min w^{\top} x\) s.t. \(A x \geq C_{\gamma}\) and \(x \geq 0\)
Edges which are not part of a cycle are given 0-weigths
- Returns:
opt_weights – (n_edges,) (positive) weights for each edge.
- Return type:
np.ndarray
- get_cycle_weight(cycle, M=None)¶
Given a cycle (i,j,k), compute its cost 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 – 3-uple with node indices creating a cycle
M (int) – Dimension of functional maps to use. If None use 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=1, equals_id=False, complete=False)¶
Performs an iteration of Consistent Zoomout refinement
- Parameters:
cclb_size – size of the CCLB to compute
M_init – initial dimension of maps
M_final – dimension at the end of the iteration
isometric – whether to use the reduced space strategy of ConsistentZoomout-iso
weight_type – ‘icsm’ or ‘adjacency’, type of weights to use
equals_id – Whether the CLB optimization uses Id or n*Id as a constraint
complete –
- If vertex-to-vertex and functional maps should be computed with all vertices
instead of the subsampling.
- zoomout_refine(nit=10, step=1, subsample=1000, isometric=True, weight_type='icsm', M_init=None, cclb_ratio=0.9, n_jobs=1, equals_id=False, verbose=False)¶
Refines the functional maps using Consistent Zoomout refinement
- Parameters:
nit – number of zoomout iterations
step – dimension increase at each iteration
subsample – size of vertices subsample. If set to 0 or None, all vertices are used.
isometric – whether to use the reduced space strategy of ConsistentZoomout-iso
weight_type – ‘icsm’ or ‘adjacency’, type of weights to use
M_init – original size of functional maps. If None, uses self.M
cclb_ratio – size of CCLB as a ratio of the current dimension M
equals_id – Whether the CLB optimization uses Id or n*Id as a constraint