magmap.cv.verifier module¶
- magmap.cv.verifier.find_closest_blobs_cdist(blobs, blobs_master, thresh=None, scaling=None)[source]¶
Find the closest blobs within a given tolerance using the Hungarian algorithm to find blob matches.
- Parameters:
blobs (
ndarray) – Blobs as a 2D array of[n, [z, row, column, ...]].blobs_master (
ndarray) – Array in same format asblobs.thresh (
Optional[float], default:None) – Threshold distance beyond which blob pairings are excluded; defaults to None to include all matches.scaling (
Optional[Sequence[float]], default:None) – Sequence of scaling factors by which to multiply the blob coordinates before computing distances, used to scale coordinates from an anisotropic to isotropic ROI before computing distances, which assumes isotropy. Defaults to None.
- Returns:
rowisandcolis, arrays of row and corresponding column indices of the closest matchesdists_closest, an array of corresponding distances for these matches. Only matches within the given tolerance will be included.
- Return type:
Tuple of
- magmap.cv.verifier.match_blobs_roi(blobs, blobs_base, offset, size, thresh, scaling, inner_padding, resize=None)[source]¶
Match blobs from two sets of blobs in an ROI.
Prioritizes the inner portion of ROIs to avoid missing detections because of edge effects while also adding matches between a blob in the inner ROI and another blob in the remaining portion of the ROI.
- Parameters:
blobs (
ndarray) – The blobs to be matched againstblobs_base, given as 2D array of[[z, row, column, radius, ...], ...].blobs_base (
ndarray) – The blobs to whichblobswill be matched, in the same format asblobs.offset (
Sequence[int]) – ROI offset from which to select blobs in x,y,z.thresh (
float) – Distance map thresholdresize (
Optional[Sequence[float]], default:None) – Resize sequence retrieved from ROI profile; defaults to None.
- Returns:
blobs_inner_plus: array of blobs fromblobsblobs_truth_inner_plus: corresponding array fromblobs_basematching blobs inblobsoffset_inner: offset of the inner portion of the ROI in absolute coordinates of x,y,zsize_inner: shape of this inner portion of the ROImatches: Blob matches
- Return type:
Tuple of
- magmap.cv.verifier.meas_detection_accuracy(blobs, verified=False, treat_maybes=0)[source]¶
Measure detection accuracy based on blob confirmation statuses.
- Parameters:
- Returns:
Sensivity, positive predictive value (PPV), and summary of stats as a string. If
blobsis None or empty, returns None for each of these values.- Return type:
- magmap.cv.verifier.setup_match_blobs_roi(tol, blobs=None)[source]¶
Set up tolerances for matching blobs in an ROI.
- magmap.cv.verifier.verify_rois(rois, blobs, blobs_truth, tol, output_db, exp_id, exp_name, channel)[source]¶
Verify blobs in ROIs by comparing detected blobs with truth sets of blobs stored in a database.
Save the verifications to a separate database with a name in the same format as saved processed files but with “_verified.db” at the end. Prints basic statistics on the verification.
Note that blobs are found from ROI parameters rather than loading from database, so blobs recorded within these ROI bounds but from different ROIs will be included in the verification.
- Parameters:
rois – Rows of ROIs from sqlite database.
blobs (
Blobs) – The blobs to be checked for accuracy.blobs_truth (
np.ndarray) – The list by which to check for accuracy, in the same format as blobs.tol – Tolerance as z,y,x of floats specifying padding for the inner ROI and used to generate a single tolerance distance within which a detected and ground truth blob will be considered potential matches.
output_db – Database in which to save the verification flags, typical the database in :attr:
config.verified_db.exp_id – Experiment ID in
output_db.exp_name (str) – Name of experiment to store as the sample name for each row in the output data frame.
channel (List[int]) – Filter
blobs_truthby this channel.
- Returns:
Tuple of
pos, true_pos, false_posstats, feedback message, and accuracy metrics in a data frame.- Return type:
tuple[int, int, int], str,
pandas.DataFrame