Inheritance diagram for nipy.neurospin.graph.field:
Field processing (smoothing, morphology) routines. Here, a field is defined as arrays [eA,eB,eD,vF] where. (eA,eB,eC) define a graph and vF a dunction defined on the edges of the graph Author: Bertrand Thirion (INRIA Futurs, Orsay, France), 2004-2006.
Bases: nipy.neurospin.graph.graph.WeightedGraph
Methods
| Parameters: | V (int >0) the number of vertices of the graph : edges=None: the edge array of the graph : weights=None: the asociated weights array : field=None: the field data itself : |
|---|
Creates the Minimum Spanning Tree self using Kruskal’s algo. efficient is self is sparse
| Returns: | K: WeightedGraph instance :
|
|---|
Creates the Minimum Spanning Tree self using Kruskal’s algo. efficient is self is sparse
| Returns: | K: WeightedGraph instance :
|
|---|
label = self.Voronoi_Labelling(seed) performs a voronoi labelling of the graph
| Parameters: | seed array of shape (nseeds), type (np.int), :
|
|---|---|
| Returns: | - labels : array of shape (self.V) the labelling of the vertices fixme: how is dealt the case of diconnected graph ? : |
Defines the graph as the Voronoi diagram (VD) that links the seeds. The VD is defined using the sample points.
| Parameters: | seeds: array of shape (self.V,dim) : samples: array of shape (nsamples,dim) : |
|---|
returns the sum of weighted degree of graph self
| Parameters: | c (int): side selection :
|
|---|---|
| Returns: | wd : array of shape (self.V),
|
Create the adjacency matrix of self
| Returns: | A : an ((self.V*self.V),np.double) array
|
|---|
Returns an array of labels corresponding to the different connex components of the graph.
| Returns: | label: array of shape(self.V), labelling of the vertices : |
|---|
Extraction of the graphe cliques these are defined using replicator dynamics equations
| Returns: | - cliques: array of shape (self.V), type (np.int) :
|
|---|
Morphological closing of the field data. self.field is changed
| Parameters: | nbiter=1 : the number of iterations required |
|---|
performs a voronoi parcellation of the field starting from the input seed
| Parameters: | seed: int array of shape(p), the input seeds : |
|---|---|
| Returns: | label: The resulting labelling of the data : Fixme : what happens if there are several ccs in the graph ? |
watershed analysis of the field. Note that bassins are found aound each maximum (and not minimum as conventionally)
| Parameters: | th is a threshold so that only values above th are considered : by default, th = -infty (numpy) : |
|---|---|
| Returns: | idx: array of shape (nbassins) :
depth: array of shape (nbassins) :
major: array of shape (nbassins) :
label : array of shape (self.V)
|
self.cut_redudancies() Remove possibly redundant edges: if an edge (ab) is present twice in the edge matrix, only the first instance in kept. The weights are processed accordingly
| Returns: | - E(int): the number of edges, self.E : |
|---|
returns the degree of the graph vertices
| Returns: | rdegree: array of shape self.V, the right degree : ldegree: array of shape self.V, the left degree : |
|---|
diffusion of a field of data in the weighted graph structure Note that this changes self.field
| Parameters: | nbiter=1: the number of iterations required :
Note : The process is run for all the dimensions of the field |
|---|
returns all the [graph] geodesic distances starting from seed it is mandatory that the graph weights are non-negative
| Parameters: | seed (int, >-1,<self.V) or array of shape(p) :
|
|---|---|
| Returns: | dg: array of shape (self.V) , :
|
Morphological dimlation of the field data. self.field is changed
| Parameters: | nbiter=1 : the number of iterations required |
|---|
set the graph to be the eps-nearest-neighbours graph of the data
| Parameters: | X array of shape (self.V) or (self.V,p) :
eps=1. (float), the neighborhood width : |
|---|---|
| Returns: | self.E the number of edges of the resulting graph : |
Compute all the geodesic distances starting from seeds it is mandatory that the graph weights are non-negative
| Parameters: | seed= None: array of shape (nbseed), type np.int :
|
|---|---|
| Returns: | dg array of shape (nbseed,self.V) :
|
set the graph to be the topological neighbours graph of the thre-dimensional coordinate set xyz, in the k-connectivity scheme
| Parameters: | xyz: array of shape (self.V,3) and type np.int, : k = 18: the number of neighbours considered. (6,18 or 26) : |
|---|---|
| Returns: | E(int): the number of edges of self : |
sets the edges of self according to the adjacency matrix M
| Parameters: | M: array of shape(sef.V,self.V) : |
|---|
Geodesic k-means algorithms: i.e. obtention of clusters that are topologically connected and minimally variable concerning the information of self.field
| Parameters: | seeds= None : array of shape (p)
labels= None array of shape(self.V) initial labels :
maxiter=100, int: maximal number of iterations : eps=1.e-4, float : :
|
|---|---|
| Returns: | seeds: array of shape (p) the final seeds : label : array of shape (self.V) the resulting field label J: inertia value : |
Look for the local maxima of one dimension (refdim) of self.field
| Parameters: | refdim (int) the field dimension over which the maxima are looked after : th = -np.infty (float,optional) :
|
|---|---|
| Returns: | idx: array of shape (nmax) :
depth: array of shape (nmax) :
|
E = knn(X,k) set the graph to be the k-nearest-neighbours graph of the data
| Parameters: | X array of shape (self.V) or (self.V,p) :
k=1 : is the number of neighbours considered |
|---|---|
| Returns: | - self.E (int): the number of edges of the resulting graph : |
| Returns: | the left incidence matrix of self :
|
|---|
Look for all the local maxima of a field
| Parameters: | refdim (int) field dimension over which the maxima are looked after : |
|---|---|
| Returns: | depth: array of shape (nmax) :
|
Returns the indexes of the vertices within the main cc
| Returns: | idx: array of shape (sizeof main cc) : |
|---|
makes self the MST of the array X
| Parameters: | X: an array of shape (self.V,dim) :
|
|---|---|
| Returns: | tl (float) the total length of the mst : |
Normalize the graph according to the index c Normalization means that the sum of the edges values that go into or out each vertex must sum to 1
| Parameters: | c=0 in {0,1,2}, optional: index that designates the way :
|
|---|
Morphological opening of the field data. self.field is changed
| Parameters: | nbiter=1 : the number of iterations required |
|---|
Removes all the edges for which valid==0
| Parameters: | valid, an array of shape (self.E) : |
|---|
Removes trivial edges, i.e. edges that are (vv)-like self.weights and self.E are corrected accordingly
| Returns: | - self.E (int): The number of edges : |
|---|
Reorder the graph according to the index c
| Parameters: | c=0 in {0,1,2}, index that designates the array :
|
|---|
| Returns: | the right incidence matrix of self :
|
|---|
Compute the weights of the graph as the distances between the corresponding rows of X, which represents an embdedding of self
| Parameters: | X array of shape (self.V, edim), :
|
|---|
Compute the weights of the graph as a gaussian function of the dinstance between the corresponding rows of X, which represents an embdedding of self
| Parameters: | X array of shape (self.V,dim) :
sigma=0, float : the parameter of the gaussian function |
|---|
| Parameters: | weights : an array of shape(self.V), edges weights |
|---|
a = self.show(X=None) plots the current graph in 2D
| Parameters: | X=None, array of shape (self.V,2) :
ax: ax handle, optional : |
|---|---|
| Returns: | ax: axis handle : |
Returns a subfield of self, with only the vertices such that valid >0
| Parameters: | valid: array of shape (self.V), :
|
|---|---|
| Returns: | F: Field instance, :
|
Creates a subgraph with the vertices for which valid>0 and with the correponding set of edges
| Parameters: | valid array of shape (self.V): nonzero for vertices to be retained : |
|---|---|
| Returns: | G WeightedGraph instance, the desired subgraph of self : |
analysis of the level sets of the field: Bifurcations are defined as changes in the topology in the level sets when the level (threshold) is varied This can been thought of as a kind of Morse analysis
| Parameters: | th=-np.infty (float) :
|
|---|---|
| Returns: | idx: array of shape (nlsets) :
height: array of shape (nlsets) :
parents: array of shape (nlsets) :
label: array of shape (self.V) :
|
converts the graph to a neighboring system The neighboring system is nothing but a (sparser) representation of the edge matrix
| Returns: | ci, ne, we: arrays of shape (self.V+1), (self.E), (self.E) :
|
|---|
Ward’s clustering of self
| Parameters: | nbcluster: int, :
|
|---|---|
| Returns: | label: array of shape (self.V) :
J (float): the resulting inertia : |