atlannot.evaluation module

Evaluation.

atlannot.evaluation.check_installed() bool[source]

Check whether the atlas_alignment_meter package is installed.

Returns:

Whether the atlas_alignment_meter package is installed

Return type:

bool

atlannot.evaluation.conditional_entropy(nissl: ndarray, atlas: ndarray) float[source]

Compute entropies of Nissl densities.

Parameters:
  • nissl – Nissl volume.

  • atlas – Annotation atlas.

Returns:

conditional_entropy – Conditional entropy of the densities of Nissl depending on the brain regions.

Return type:

float

atlannot.evaluation.entropy(arr: np.ndarray | ma.MaskedArray, *, n_bins: int = 256, value_range: tuple[int, int] | None = None) float[source]

Compute the entropy of the value distribution in an array.

The entropy is computed over the discrete value distribution of the given data, which is obtained by putting all values into a given number of bins that are uniformly distributed over a given value range. Note that the exact pixel positions and the shape of the data array don’t matter, only the value distribution.

In order to obtain results that are compatible with each other it is important that the entropy is computed using the same bins. This can be ensured by using fixed values for the n_bins and value_range parameters.

Parameters:
  • arr – The array for which to compute the entropy.

  • n_bins – The number of histogram bins. The entropy is computed over the discretized value distribution of the given array. To obtain the discretization, a histogram of all values in the given array is computed using the given number of equally sized bins across the value range specified by the value_range parameter.

  • value_range – The value range over which to compute the data distribution specified the lower and upper bound. If not provided then the min and max of all array values will be used. In order to obtain compatible results for different arrays or for different masked regions of the same array it is important to make sure that the histograms are computed over exactly the same bins. The bins are uniquely specified by the n_bins and value_range parameters, therefore, for compatible results it is important to keep these constant.

Returns:

Entropy of the (masked) array.

Return type:

float

atlannot.evaluation.evaluate(atlas: np.ndarray, nissl: np.ndarray, reference: np.ndarray, region_meta: RegionMeta, regions_to_evaluate: dict[str, list[int]] | None = None) dict[str, Any][source]

Evaluate the atlas.

Parameters:
  • atlas – Atlas to evaluate.

  • nissl – Corresponding Nissl Volume.

  • reference – Reference atlas.

  • region_meta – Region Meta containing all the information concerning the labels.

  • regions_to_evaluate – Regions to evaluate. If None, regions to evaluation considered are REGIONS_TO_EVALUATE = { “Somatosensory Cortex”: [453], “Visual Cortex”: [669], “Rest of Cortex”: [315], “Thalamus”: [549], “Hippocampus”: [1080], “Cerebullum”: [512], “Basal Ganglia”: [477, 1022, 470, 381],}

Returns:

results – Dictionary containing the results of the evaluation.

Return type:

dict[str, Any]

atlannot.evaluation.evaluate_region(region_ids: list[int], atlas: np.ndarray, reference: np.ndarray, region_meta: RegionMeta) dict[str, Any][source]

Evaluate the atlas.

Parameters:
  • region_ids – Region IDs to evaluate.

  • atlas – Atlas to evaluate.

  • reference – Reference atlas.

  • region_meta – Region Meta containing all the information concerning the labels.

Returns:

results – Dictionary containing the results of the region evaluation.

Return type:

dict[str, Any]

atlannot.evaluation.how_to_install_msg() str[source]

Get installation instructions for atlas_alignment_meter.

Returns:

The instructions on how to install atlas_alignment_meter.

Return type:

str

atlannot.evaluation.iou(annot_vol_1: np.ndarray, annot_vol_2: np.ndarray, region_ids: Collection[int] | None = None) dict[int, float][source]

Compute the intersection over union of given region IDs.

Parameters:
  • annot_vol_1 – The first annotation volume.

  • annot_vol_2 – The second annotation volume.

  • region_ids – A sequence of region IDs to compute the intersection over union. If None, the IoU is computed for all the region IDs present in at least one of the volumes.

Returns:

results – Dictionary with the region IDs as keys and the intersection over union scores as values.

Return type:

dict[int, float]

atlannot.evaluation.jaggedness(volume: np.ndarray, axis: int = 0, region_ids: Collection[int] | None = None, all_region_ids: Collection[int] | None = None) dict[int, float][source]

Compute the jaggedness of given region IDs for the specified volume.

Parameters:
  • volume – An annotation volume.

  • axis – Axis along which to compute the jaggedness.

  • region_ids – A collection of region IDs to compute the jaggedness. If None, the jaggedness is computed for all the region IDs present in the volume.

  • all_region_ids – A collection of unique IDs in the volume provided. Can be useful to speed up the computation. It’s typically computed using np.unique(volume). If not provided, it will be set to np.unique(volume).

Returns:

results – Dictionary containing the region id as keys and the mean of the jaggedness of that given region id as values.

Return type:

dict[int, float]

atlannot.evaluation.warn_if_not_installed() None[source]

Issue a UserWarning if atlas_alignment_meter is not installed.