magmap.stats.atlas_stats module¶
Low-level measurement of atlases and statistics generation.
Typically applied to specific types of atlases and less generalizable than measurements in :module:`vols`.
- magmap.stats.atlas_stats.calc_sens_ppv(pos, true_pos, false_pos, false_neg)[source]¶
Calculate sensitivity and positive predictive value (PPV), typically for assessing detection accuracy.
- magmap.stats.atlas_stats.meas_dice(mask1, mask2, img=None)[source]¶
Measure Dice Similarity Coefficient (DSC) between two images.
- Parameters:
mask1 (
np.ndarray) – Mask of first image.mask2 (
np.ndarray) – Mask of second image with same shape as that ofmask2.img (
np.ndarray) – Intensity image whose values within each mask will be summed, of the same shape as that of the masks; defaults to None.
- Returns:
float: DSC between the two images, either based directly on the mask volumes or weighted by intensities of
imgif given.
- magmap.stats.atlas_stats.meas_improvement(path, col_effect, col_p, thresh_impr=0, thresh_p=0.05, col_wt=None, suffix=None, df=None)[source]¶
Measure overall improvement and worsening for a column in a data frame.
- Parameters:
path (str) – Path of file to load into data frame.
col_effect (str) – Name of column with metric to measure.
col_p (str) – Name of column with p-values.
thresh_impr (float) – Threshold of effects below which are considered improved.
thresh_p (float) – Threshold of p-values below which are considered statistically significant.
col_wt (str) – Name of column for weighting.
suffix (str) – Output path suffix; defaults to None.
df (
pd.DataFrame) – Data fram to use instead of loading frompath; defaults to None.
- Returns:
Data frame with improvement measurements. The data frame will be saved to a filename based on
path.- Return type:
pd.DataFrame
- magmap.stats.atlas_stats.meas_landmark_dist(paths, spacing=None)[source]¶
Measure distance between corresponding labels in two labels images.
Supports image transposition of the 2nd image by
magmap.atlas.atlas_refiner()with settings frommagmap.settings.config.transforms.
- magmap.stats.atlas_stats.meas_plot_coefvar(path, id_cols, cond_col, cond_base, metric_cols, composites, size_col=None, size=None, show=True)[source]¶
Measure and plot coefficient of variation (CV) as a scatter plot.
CV is computed two ways:
Based on columns and equation specified in
composites, applied across all samples regardless of groupFor each metric in
metric_cols, separated by groups
- Parameters:
path (str) – Path to data frame.
id_cols (List[str]) – Sequence of columns to serve as index/indices.
cond_col (str) – Name of the condition column.
cond_base (str) – Name of the condition to which all other conditions will be normalized.
metric_cols (List[str]) – Sequence of column names for which to compute z-scores.
composites (List[Enum]) – Sequence of enums specifying the combination, typically from
vols.MetricCombos.size_col (str) – Name of weighting column for coefficient of variation measurement; defaults to None.
size (List[int]) – Sequence of
width, heightto size the figure; defaults to None.show (bool) – True to display the image; defaults to True.
- magmap.stats.atlas_stats.meas_plot_zscores(path, metric_cols, extra_cols, composites, size=None, show=True)[source]¶
Measure and plot z-scores for given columns in a data frame.
- Parameters:
path (str) – Path to data frame.
metric_cols (List[str]) – Sequence of column names for which to compute z-scores.
extra_cols (List[str]) – Additional columns to included in the output data frame.
composites (List[Enum]) – Sequence of enums specifying the combination, typically from
vols.MetricCombos.size (List[int]) – Sequence of
width, heightto size the figure; defaults to None.show (bool) – True to display the image; defaults to True.
- magmap.stats.atlas_stats.plot_clusters_by_label(path, z, suffix=None, show=True, scaling=None)[source]¶
Plot separate sets of clusters for each label.
- magmap.stats.atlas_stats.plot_intensity_nuclei(paths, labels, size=None, show=True, unit=None)[source]¶
Plot nuclei vs. intensity as a scatter plot.
- Parameters:
paths (List[str]) – Sequence of paths to CSV files.
labels (List[str]) – Sequence of label metrics corresponding to
paths.size (List[int]) – Sequence of
width, heightto size the figure; defaults to None.show (bool) – True to display the image; defaults to True.
unit (str) – Denominator unit for density plot; defaults to None.
- Returns:
Data frame with columns matching
labelsfor the givenpathsconcatenated.- Return type:
pd.DataFrame
- magmap.stats.atlas_stats.plot_region_development(metric, size=None, show=True)[source]¶
Plot regions across development for the given metric.
- magmap.stats.atlas_stats.plot_unlabeled_hemisphere(path, cols, size=None, show=True)[source]¶
Plot unlabeled hemisphere fractions as bar and line plots.
- magmap.stats.atlas_stats.smoothing_peak(df, thresh_label_loss=None, filter_size=None)[source]¶
Extract the baseline and peak smoothing quality rows from the given data frame matching the given criteria.
- Parameters:
df – Data frame from which to extract.
thresh_label_loss (default:
None) – Only check rows below or equal to this fraction of label loss; defaults to None to ignore.filter_size (default:
None) – Only rows with the given filter size; defaults to None to ignore.
- Returns:
New data frame with the baseline (filter size of 0) row and the row having the peak smoothing quality meeting criteria.