decode.evaluation package#
Submodules#
decode.evaluation.evaluation module#
- class decode.evaluation.evaluation.DistanceEvaluation[source]#
Bases:
object
A small wrapper calss that holds distance evaluations and accepts sets of emitters as inputs.
- forward(tp, tp_match)[source]#
- Parameters:
tp (
EmitterSet
) – true positivestp_match (
EmitterSet
) – matching ground truths
- Returns:
RMSE lateral rmse_ax: RMSE axial rmse_vol: RMSE volumetric mad_lat: MAD lateral mad_ax: MAD axial mad_vol: MAD volumetric
- Return type:
rmse_lat
- class decode.evaluation.evaluation.SMLMEvaluation(seg_eval=<decode.evaluation.evaluation.SegmentationEvaluation object>, dist_eval=<decode.evaluation.evaluation.DistanceEvaluation object>, weighted_eval=<decode.evaluation.evaluation.WeightedErrors object>)[source]#
Bases:
object
Just a wrapper class to combine things into one.
- alpha_ax = 0.5#
- alpha_lat = 1#
- descriptors = {'dx_red_mu': 'CRLB normalised bias in x', 'dx_red_sig': 'CRLB normalised error in x', 'dy_red_mu': 'CRLB normalised bias in y', 'dy_red_sig': 'CRLB normalised error in y', 'dz_red_mu': 'CRLB normalised bias in z', 'dz_red_sig': 'CRLB normalised error in z', 'jac': 'Jaccard Index', 'mad_ax': 'Mean average distance axial', 'mad_lat': 'Mean average distance lateral', 'mad_vol': 'Mean average distance in 3D', 'pred': 'Precision', 'rec': 'Recall', 'rmse_ax': 'RMSE axial', 'rmse_lat': 'RMSE lateral', 'rmse_vol': 'RMSE volumetric'}#
- property effcy_ax#
- property effcy_lat#
- property effcy_vol#
- forward(tp, fp, fn, p_ref)[source]#
Evaluate sets of emitters by all available metrics.
- Parameters:
tp – true positives
fp – false positives
fn – false negatives
p_ref – true positive references (i.e. the ground truth that has been matched to tp)
- Returns:
A namedtuple of floats containing
prec (float): Precision
rec (float): Recall
jac (float): Jaccard
f1 (float): F1-Score
effcy_lat (float): Efficiency lateral
effcy_ax (float): Efficiency axial
effcy_vol (float): Efficiency volumetric
rmse_lat (float): RMSE lateral
rmse_ax (float): RMSE axial
rmse_vol (float): RMSE volumetric
mad_lat (float): MAD lateral
mad_ax (float): MAD axial
mad_vol (float): MAD volumetric
- Return type:
namedtuple
- class decode.evaluation.evaluation.SegmentationEvaluation[source]#
Bases:
object
Wrapper class that holds all segementation evaluations in one place.
- forward(tp, fp, fn)[source]#
Forward emitters through evaluation.
- Parameters:
tp (
EmitterSet
) – true positivesfp (
EmitterSet
) – false positivesfn (
EmitterSet
) – false negatives
- Returns:
precision value rec (float): recall value jac (float): jaccard value f1 (float): f1 score value
- Return type:
prec (float)
- class decode.evaluation.evaluation.WeightedErrors(mode, reduction)[source]#
Bases:
object
Weighted deviations.
- forward(tp, ref, plot=False, axes=None)[source]#
- Parameters:
tp (EmitterSet) – true positives
ref (EmitterSet) – matching ground truth
plot (bool) – plot histograms
axes (list,tuple) – axis to which to plot the histograms
- Return type:
namedtuple
Returns:
- static plot_error(dxyz, dphot, dbg, axes=None)[source]#
Plot the histograms
- Parameters:
dxyz (torch.Tensor) – weighted err in xyz, N x 3
dphot (torch.Tensor) – weighted err in phot, N
dbg (torch.Tensor) – weighted err in bg, N
axes (tuple of axes,None) – axes to which to plot to, tuple of size 6 or None
- Returns:
axes
- reduction#
Sanity check
decode.evaluation.match_emittersets module#
- class decode.evaluation.match_emittersets.EmitterMatcher[source]#
Bases:
ABC
Abstract emitter matcher class.
- abstract forward(output, target)[source]#
All implementations shall implement this forward method which takes output and reference set of emitters and outputs true positives, false positives, false negatives and matching ground truth (matched to the true positives).
- Parameters:
output (
EmitterSet
) – output set of emitterstarget (
EmitterSet
) – reference set of emitters
- Return type:
MatchResult
- Returns:
(emitter.EmitterSet, emitter.EmitterSet, emitter.EmitterSet, emitter.EmitterSet)
tp: true positives
fp: false positives
fn: false negatives
tp_match: ground truths that have been matched to the true positives
- class decode.evaluation.match_emittersets.GreedyHungarianMatching(*, match_dims, dist_ax=None, dist_lat=None, dist_vol=None)[source]#
Bases:
EmitterMatcher
- Parameters:
match_dims (
int
) – match in 2D or 3Ddist_lat (
Optional
[float
]) – lateral tolerance radiusdist_ax (
Optional
[float
]) – axial tolerance thresholddist_vol (
Optional
[float
]) – volumetric tolerance radius
- dist_vol#
Sanity checks
- filter(xyz_out, xyz_tar)[source]#
Filter kernel to rule out unwanted matches. Batch implemented, i.e. input can be 2 or 3 dimensional, where the latter dimensions are the dimensions of interest.
- Parameters:
xyz_out – output coordinates, shape :math: (B x) N x 3
xyz_tar – target coordinates, shape :math: (B x) M x 3
- Returns:
boolean of size (B x) N x M
- Return type:
filter_mask (torch.Tensor)
decode.evaluation.metric module#
- decode.evaluation.metric.efficiency(jac, rmse, alpha)[source]#
Calculate Efficiency following Sage et al. 2019, superres fight club
- Parameters:
jac (float) – jaccard index 0-1
rmse (float) –
alpha (float) – alpha value
- Returns:
efficiency 0-1
- Return type:
effcy (float)
- decode.evaluation.metric.precision_recall_jaccard(tp, fp, fn)[source]#
Calculates precision, recall, jaccard index and f1 score
- Parameters:
tp (
int
) – number of true positivesfp (
int
) – number of false positivesfn (
int
) – number of false negatives
- Returns:
precision value 0-1 recall (float): recall value 0-1 jaccard (float): jaccard index 0-1 f1 (float): f1 score 0-1
- Return type:
precision (float)
- decode.evaluation.metric.rmse_mad_dist(xyz_0, xyz_1)[source]#
Calculate RMSE and mean absolute distance.
- Parameters:
xyz_0 (
Tensor
) – coordinates of set 0,xyz_1 (
Tensor
) – coordinates of set 1
- Returns:
RMSE lateral rmse_ax (float): RMSE axial rmse_vol (float): RMSE volumetric mad_lat (float): Mean Absolute Distance lateral mad_ax (float): Mean Absolute Distance axial mad_vol (float): Mean Absolute Distance vol
- Return type:
rmse_lat (float)
decode.evaluation.predict_dist module#
- decode.evaluation.predict_dist.deviation_dist(x, x_gt, residuals=False, kde=True, ax=None, nan_okay=True)[source]#
Log z vs z_gt