class_docstr: This class provides a way to calculate a reasonable output voxel spacing according to
  the input dataset. The achieved values can used to resample the input in 3d segmentation tasks
  (like using as the `pixdim` parameter in `monai.transforms.Spacingd`).
  In addition, it also supports to compute the mean, std, min and max intensities of the input,
  and these statistics are helpful for image normalization
  (as parameters of `monai.transforms.ScaleIntensityRanged` and `monai.transforms.NormalizeIntensityd`).
  
  The algorithm for calculation refers to:
  `Automated Design of Deep Learning Methods for Biomedical Image Segmentation <https://arxiv.org/abs/1904.08128>`_.
class_docstr_tok: ["This","class","provides","a","way","to","calculate","a","reasonable","output","voxel","spacing","according","to","the","input","dataset",".","The","achieved","values","can","used","to","resample","the","input","in","3d","segmentation","tasks","(","like","using","as","the","`","pixdim","`","parameter","in","`","monai.transforms.Spacingd","`",")",".","In","addition",",","it","also","supports","to","compute","the","mean",",","std",",","min","and","max","intensities","of","the","input",",","and","these","statistics","are","helpful","for","image","normalization","(","as","parameters","of","`","monai.transforms.ScaleIntensityRanged","`","and","`","monai.transforms.NormalizeIntensityd","`",")",".","The","algorithm","for","calculation","refers","to",":","`","Automated","Design","of","Deep","Learning","Methods","for","Biomedical","Image","Segmentation","<","https",":","\/\/arxiv.org\/abs\/1904.08128",">","`","_","."]
docstr: This function is used to calculate the percentiles of intensities (and median) of the input dataset. To get
  the required values, all voxels need to be accumulated. To reduce the memory used, this function can be set
  to accumulate only a part of the voxels.
  
  Args:
      foreground_threshold: the threshold to distinguish if a voxel belongs to foreground, this parameter
          is used to select the foreground of images for calculation. Normally, `label > 0` means the corresponding
          voxel belongs to foreground, thus if you need to calculate the statistics for whole images, you can set
          the threshold to ``-1`` (default: ``0``).
      sampling_flag: whether to sample only a part of the voxels (default: ``True``).
      interval: the sampling interval for accumulating voxels (default: ``10``).
      min_percentile: minimal percentile (default: ``0.5``).
      max_percentile: maximal percentile (default: ``99.5``).
docstr_tok: ["This","function","is","used","to","calculate","the","percentiles","of","intensities","(","and","median",")","of","the","input","dataset",".","To","get","the","required","values",",","all","voxels","need","to","be","accumulated",".","To","reduce","the","memory","used",",","this","function","can","be","set","to","accumulate","only","a","part","of","the","voxels",".","Args",":","foreground_threshold",":","the","threshold","to","distinguish","if","a","voxel","belongs","to","foreground",",","this","parameter","is","used","to","select","the","foreground","of","images","for","calculation",".","Normally",",","`","label",">","0","`","means","the","corresponding","voxel","belongs","to","foreground",",","thus","if","you","need","to","calculate","the","statistics","for","whole","images",",","you","can","set","the","threshold","to","``","-1","``","(","default",":","``","0","``",")",".","sampling_flag",":","whether","to","sample","only","a","part","of","the","voxels","(","default",":","``","True","``",")",".","interval",":","the","sampling","interval","for","accumulating","voxels","(","default",":","``","10","``",")",".","min_percentile",":","minimal","percentile","(","default",":","``","0.5","``",")",".","max_percentile",":","maximal","percentile","(","default",":","``","99.5","``",")","."]
code: def calculate_percentiles(
      self,
      foreground_threshold: int = 0,
      sampling_flag: bool = True,
      interval: int = 10,
      min_percentile: float = 0.5,
      max_percentile: float = 99.5,
  ):
      """
      This function is used to calculate the percentiles of intensities (and median) of the input dataset. To get
      the required values, all voxels need to be accumulated. To reduce the memory used, this function can be set
      to accumulate only a part of the voxels.
  
      Args:
          foreground_threshold: the threshold to distinguish if a voxel belongs to foreground, this parameter
              is used to select the foreground of images for calculation. Normally, `label > 0` means the corresponding
              voxel belongs to foreground, thus if you need to calculate the statistics for whole images, you can set
              the threshold to ``-1`` (default: ``0``).
          sampling_flag: whether to sample only a part of the voxels (default: ``True``).
          interval: the sampling interval for accumulating voxels (default: ``10``).
          min_percentile: minimal percentile (default: ``0.5``).
          max_percentile: maximal percentile (default: ``99.5``).
  
      """
      all_intensities = []
      for data in self.data_loader:
          if self.image_key and self.label_key:
              image, label = data[self.image_key], data[self.label_key]
          else:
              image, label = data
          image, *_ = convert_data_type(
              data=image, output_type=torch.Tensor
          )
          label, *_ = convert_data_type(
              data=label, output_type=torch.Tensor
          )
  
          intensities = image[
              torch.where(label > foreground_threshold)
          ].tolist()
          if sampling_flag:
              intensities = intensities[::interval]
          all_intensities.append(intensities)
  
      all_intensities = list(chain(*all_intensities))
      (
          self.data_min_percentile,
          self.data_max_percentile,
      ) = np.percentile(
          all_intensities, [min_percentile, max_percentile]
      )
      self.data_median = np.median(all_intensities)
  
file_path: MONAI/monai/data/dataset_summary.py
imports: from __future__ import annotations
  import warnings
  from itertools import chain
  import numpy
  import torch
  from monai.config import KeysCollection
  from monai.data.dataloader import DataLoader
  from monai.data.dataset import Dataset
  from monai.data.meta_tensor import MetaTensor
  from monai.data.utils import affine_to_spacing
  from monai.transforms import concatenate
  from monai.utils import PostFix, convert_data_type, convert_to_tensor
label_desc: Use image node_id 5 for calling the DatasetSummary obj's underlying member method code with example usage: obj.calculate_percentiles(foreground_threshold, sampling_flag, interval, min_percentile, max_percentile) without return types