nmrglue.segmentation
segmentation - functions to perform segmentation of NMR spectrum.
This modules is imported as nmrglue.segmentation and can be called as such.
Low-Level Functions
These functions are typically not used directly by users. They are called by
high level functions. Developers and user who want to segment spectra will
be interested in these functions.
-
nmrglue.analysis.segmentation.neighbors(pt, shape, diag=False)
Generate a list of all neightbors to a point
Parameters:
- pt Index of the point to find neighbors of.
- shape Shape of the region
- diag True to include diagonal neightbors, False not to.
-
nmrglue.analysis.segmentation.valid_pt(pt, shape)
- Determind if point is valid in a given shaped array
-
nmrglue.analysis.segmentation.find_downward(data, pt, thres, diag=False)
Find points downward-connected to pt in data.
Parameters:
- data 2D array of data
- pt Starting point, top of peak, tuple.
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Return: list of indicies of downward connected nodes.
-
nmrglue.analysis.segmentation.find_all_downward(data, thres, diag=False)
Find all downward-connected segments in data
Parameters:
- data Array of data
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Returns: (centers,segments)
- centers List of indicies of local maximum in each segment
- segments List of all points in a given segment
-
nmrglue.analysis.segmentation.map_downward(data, thres, diag=False, map_dtype='u2')
Create a map of downward-connected segments of data above threshold
Parameters:
- data Array of data
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
- map_dtype Dtype of map.
Returns: map
map is an array of integers indicating segments. 0 represents noise,1 the
first segment, 2 the second, etc. The index value of these regions
can be found using np.where
-
nmrglue.analysis.segmentation.mark_dmap(mdata, map, pt, mark, diag)
Mark downward-connected region on segment map starting at node pt
Parameters:
- mdata Masked data array
- map Array mapping out segments
- pt Index of starting node
- mark Integer to mark map with.
Returns nothing but modified mdata mask and map
-
nmrglue.analysis.segmentation.find_upward(data, pt, thres, diag=False)
Find points upward-connected to pt in data.
Parameters:
- data 2D array of data
- pt Starting point, bottom of peak, tuple.
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Return: list of indicies of upward connected nodes.
-
nmrglue.analysis.segmentation.find_all_upward(data, thres, diag=False)
Find all upward-connected segments in data
Parameters:
- data Array of data
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Returns: (centers,segments)
- centers List of indicies of local minima in each segment
- segments List of all points in a given segment
-
nmrglue.analysis.segmentation.map_upward(data, thres, diag=False, map_dtype='u2')
Create a map of upward-connected segments of data below threshold
Parameters:
- data Array of data
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
- map_dtype Dtype of map.
Returns: map
map is an array of integers indicating segments. 0 represents noise,1 the
first segment, 2 the second, etc. The index value of these regions
can be found using np.where
-
nmrglue.analysis.segmentation.mark_umap(mdata, map, pt, mark, diag)
Mark upward-connected region on segment map starting at node pt
Parameters:
- mdata Masked data array
- map Array mapping out segments
- pt Index of starting node
- mark Integer to mark map with.
Returns nothing but modified mdata mask and map
-
nmrglue.analysis.segmentation.find_connected(data, pt, thres, diag=False)
Find points connected to pt in data.
Parameters:
- data 2D array of data
- pt Starting point, (top of peak).
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Return: list of indicies of downward connected nodes.
-
nmrglue.analysis.segmentation.find_all_connected(data, thres, diag=False)
Find all connected segments in data
Parameters:
- data Array of data
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Returns: (centers,segments)
- centers List of indicies of local maximum in each segment
- segments List of all points in a given segment
-
nmrglue.analysis.segmentation.map_connected(data, thres, diag=False, map_dtype='u2')
Create a map of connected segments of data above threshold
Parameters:
- data Array of data
- thres Threshold, below this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
- map_dtype Dtype of map.
Returns: map
map is an array of integers indicating segments. 0 represents noise,1 the
first segment, 2 the second, etc. The index value of these regions
can be found using np.where
-
nmrglue.analysis.segmentation.mark_cmap(mdata, map, pt, mark, diag)
Mark connected region on segment map starting at node pt
Parameters:
- mdata Masked data array
- map Array mapping out segments
- pt Index of starting node
- mark Integer to mark map with.
Returns nothing but modified mdata mask and map
-
nmrglue.analysis.segmentation.find_nconnected(data, pt, thres, diag=False)
Find points connected to pt in data below threshold.
Parameters:
- data 2D array of data
- pt Starting point, (top of peak).
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Return: list of indicies of connected nodes.
-
nmrglue.analysis.segmentation.find_all_nconnected(data, thres, diag=False)
Find all connected segments in data below threshold.
Parameters:
- data Array of data
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
Returns: (centers,segments)
- centers List of indicies of local maximum in each segment
- segments List of all points in a given segment
-
nmrglue.analysis.segmentation.map_nconnected(data, thres, diag=False, map_dtype='u2')
Create a map of connected segments of data below threshold
Parameters:
- data Array of data
- thres Threshold, above this nodes are considered noise.
- diag True or False to include diagonal neighbors in connection.
- map_dtype Dtype of map.
Returns: map
map is an array of integers indicating segments. 0 represents noise,1 the
first segment, 2 the second, etc. The index value of these regions
can be found using np.where
-
nmrglue.analysis.segmentation.mark_nmap(mdata, map, pt, mark, diag)
Mark negatively connected region on segment map starting at node pt
Parameters:
- mdata Masked data array
- map Array mapping out segments
- pt Index of starting node
- mark Integer to mark map with.
Returns nothing but modified mdata mask and map