wf_psf.utils.graph_utils module
- class wf_psf.utils.graph_utils.GraphBuilder(obs_data, obs_pos, obs_weights, n_comp, n_eigenvects=None, n_iter=3, ea_gridsize=10, distances=None, auto_run=True, verbose=2)[source]
Bases:
object
GraphBuilder class.
This class computes the necessary quantities for RCA’s graph constraint.
- Parameters:
obs_data (numpy.ndarray) – Observed data.
obs_pos (numpy.ndarray) – Corresponding positions.
obs_weights (numpy.ndarray) – Corresponding per-pixel weights.
n_comp (int) – Number of RCA components.
n_eigenvects (int) – Maximum number of eigenvectors to consider per \((e,a)\) couple. Default is
None
; if not provided, all eigenvectors will be considered, which can lead to a poor selection of graphs, especially when data is undersampled. Ignored ifVT
andalpha
are provided.n_iter (int) – How many alternations should there be when optimizing over \(e\) and \(a\). Default is 3.
ea_gridsize (int) – How fine should the logscale grid of \((e,a)\) values be. Default is 10.
distances (numpy.ndarray) – Pairwise distances for all positions. Default is
None
; if not provided, will be computed from given positions.auto_run (bool) – Whether to immediately build the graph quantities. Default is
True
.
Methods
gen_eigenvects
(mat)Compute input matrix's eigenvectors.
pick_emax
([epsilon])Pick maximum value for
e
parameter.select_params
(R, e_range, a_range)Select best graph parameters.
- gen_eigenvects(mat)[source]
Compute input matrix’s eigenvectors.
Keep only the
n_eigenvects
associated with the smallest eigenvalues.
- pick_emax(epsilon=1e-15)[source]
Pick maximum value for
e
parameter.From now, we fix the maximum \(e\) to 1 and ignore the old procedure that was giving values that were too big.
Old procedure: Select maximum value of \(e\) for the greedy search over set of \((e,a)\) couples, so that the graph is still fully connected.
- select_params(R, e_range, a_range)[source]
Select best graph parameters.
Select \((e,a)\) parameters and best eigenvector for current \(R_i\) matrix.
- Parameters:
R (numpy.ndarray) – Current \(R_i\) matrix (as defined in RCA paper (Ngole et al.), sect. 5.5.3.)
e_range (numpy.ndarray) – List of \(e\) values to be tested.
a_range (numpy.ndarray) – List of \(a\) values to be tested.
- wf_psf.utils.graph_utils.gen_Pea(distances, e, a)[source]
Compute the graph Laplacian for a given set of parameters.
- Parameters:
distances (numpy.ndarray) – Array of pairwise distances
e (float) – Exponent to which the pairwise distances should be raised.
a (float) – Constant multiplier along Laplacian’s diagonal.
- Returns:
Pea – Graph laplacian.
- Return type:
Notes
Computes \(P_{e,a}\) matrix for given
e
,a
couple. See Equations (16-17) in RCA paper (Ngole et al.). Watch out with thee
parameter as it plays a vital role in the graph definition as it is a parameter of the distance that defines the graph’s weights.
- wf_psf.utils.graph_utils.select_vstar(eigenvects, R, weights)[source]
Pick best eigenvector from a set of \((e,a)\).
i.e., solve (35) from RCA paper (Ngole et al.).
- Parameters:
eigenvects (numpy.ndarray) – Array of eigenvects to be tested over.
R (numpy.ndarray) – \(R_i\) matrix.
weights (numpy.ndarray) – Entry-wise weights for \(R_i\).