baby.training.tracker.BudTrainer¶
- class baby.training.tracker.BudTrainer(props_file=None, **kwargs)¶
Bases:
BudTracker
- Props_file
File where generated property table will be saved
- Kwargs
Additional arguments passed onto the parent Tracker; pixel_size is especially useful.
- Attributes
- a_ind
- ma_ind
- props
- props_file
- x_ind
- y_ind
Methods
calc_feats_from_mask
(masks[, feats2use, ...])Calculate feature ndarray from ndarray of cell masks
calc_mother_bud_stats
(p_budneck, p_bud, masks)---
calc_trapfeats
(basefeats)Calculate trap-based features using basic ones. :basefeats: (n basic outfeats) 1-D array with features outputed by skimage.measure.regionprops_table.
generate_property_table
(data, flattener[, ...])Generates properties table that gets used for training
get_rpoints
(feats, d, m)Draw a rectangle in the budneck of cells
predict_mother_bud
(p_budneck, p_bud, masks)---
scale_feats
(feats, pixel_size)input
explore_hyperparams
get_outfeats
load_model
performance
plot_PR
save_model
set_named_ids
- __init__(props_file=None, **kwargs)¶
Methods
__init__
([props_file])calc_feats_from_mask
(masks[, feats2use, ...])Calculate feature ndarray from ndarray of cell masks
calc_mother_bud_stats
(p_budneck, p_bud, masks)---
calc_trapfeats
(basefeats)Calculate trap-based features using basic ones. :basefeats: (n basic outfeats) 1-D array with features outputed by skimage.measure.regionprops_table.
explore_hyperparams
([hyper_param_target])generate_property_table
(data, flattener[, ...])Generates properties table that gets used for training
get_outfeats
([feats2use])get_rpoints
(feats, d, m)Draw a rectangle in the budneck of cells
load_model
(path, fname)performance
()plot_PR
()predict_mother_bud
(p_budneck, p_bud, masks)---
save_model
(filename)scale_feats
(feats, pixel_size)input
set_named_ids
()Attributes
a_ind
ma_ind
props
props_file
x_ind
y_ind
- calc_feats_from_mask(masks: ndarray, feats2use: Optional[Tuple[str]] = None, trapfeats: Optional[Tuple[str]] = None, scale: Optional[bool] = True, pixel_size: Optional[float] = None)¶
Calculate feature ndarray from ndarray of cell masks — input
- Masks
ndarray (ncells, x_size, y_size), typically dtype bool
- Feats2use
list of strings with the feature properties to extract. If it is None it uses the ones set in self.feats2use.
- Trapfeats
List of str with additional features to use calculated immediately after basic features.
- Scale
bool, if True scales mask to a defined pixel_size.
- Pixel_size
float, used to rescale the object features.
returns
(ncells, nfeats) ndarray of features for input masks
- calc_mother_bud_stats(p_budneck, p_bud, masks, feats=None)¶
—
input
- P_budneck
2d ndarray (size_x, size_y) giving the probability that a pixel corresponds to a bud neck
- P_bud
2d ndarray (size_x, size_y) giving the probability that a pixel corresponds to a bud
- Masks
3d ndarray (ncells, size_x, size_y)
- Feats
ndarray (ncells, nfeats)
NB: ASSUMES FEATS HAVE ALREADY BEEN NORMALISED!
returns
- N2darray
2d ndarray (ncells x ncells, n_feats) specifying, for each pair of cells in the masks array, the features used for mother-bud pair prediction (as per ‘feats2use’)
- calc_trapfeats(basefeats)¶
Calculate trap-based features using basic ones. :basefeats: (n basic outfeats) 1-D array with features outputed by
skimage.measure.regionprops_table
- requires
self.aind self.aweights self.xind self.yind self.trapfeats
returns (ntrapfeats) 1-D array with
- generate_property_table(data: Iterable, flattener: SegmentationFlattening, val_data=None)¶
Generates properties table that gets used for training
- Data
List or generator of baby.training.SegExample tuples
- Flattener
Instance of a baby.preprocessing.SegmentationFlattening object describing the targets of the CNN in data
- get_rpoints(feats, d, m)¶
Draw a rectangle in the budneck of cells —
NB: ASSUMES FEATS HAVE ALREADY BEEN NORMALISED!
input
feats: 2d ndarray (ncells, nfeats)
returns
r_points: 2d ndarray (2,4) with the coordinates of the rectangle corner
- predict_mother_bud(p_budneck, p_bud, masks, feats=None)¶
—
input
- P_budneck
2d ndarray (size_x, size_y) giving the probability that a pixel corresponds to a bud neck
- P_bud
2d ndarray (size_x, size_y) giving the probability that a pixel corresponds to a bud
- Masks
3d ndarray (ncells, size_x, size_y)
- Feats
ndarray (ncells, nfeats)
returns
- N2darray
2d ndarray (ncells, ncells) giving probability that a cell (row) is a mother to another cell (column)
- scale_feats(feats: ndarray, pixel_size: float)¶
input
- Feats
np.ndarray (ncells * nfeatures)
- Pixel_size
float Value used to normalise the images.
returns Rescaled list of feature values