tools.roi_stat

Contents

tools.roi_stat#

bartorch.tools.roi_stat()#

Statistic of input over the region roi. BART’s roistat.

Parameters:
  • roi (torch.Tensor) – Weights, binary for the plain statistics, broadcasting against input. An axis where only one of the two exceeds one (several images, or several regions) is kept in the result.

  • input (torch.Tensor) – Values the statistic is taken of.

  • stat ({"count", "sum", "mean", "std", "energy", "variance"}, default='mean') – count is the sum of the weights, sum that of the weighted values, mean their ratio; energy is the sum of squared deviations from the mean, variance energy over count, std its root.

  • bessel (bool, default=False) – Divide by count minus one; std and variance only.

Returns:

Broadcast shape of roi and input, with size one on the axes where both exceed one. Complex for sum and mean, real otherwise.

Return type:

torch.Tensor

Raises:

ValueError – If stat is unknown, bessel is given for another statistic, or the shapes do not broadcast.