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: Calculate the target spacing according to all spacings.
  If the target spacing is very anisotropic,
  decrease the spacing value of the maximum axis according to percentile.
  The spacing is computed from `affine_to_spacing(data[spacing_key][0], 3)` if `data[spacing_key]` is a matrix,
  otherwise, the `data[spacing_key]` must be a vector of pixdim values.
  
  Args:
      spacing_key: key of the affine used to compute spacing in metadata (default: ``affine``).
      anisotropic_threshold: threshold to decide if the target spacing is anisotropic (default: ``3``).
      percentile: for anisotropic target spacing, use the percentile of all spacings of the anisotropic axis to
          replace that axis.
docstr_tok: ["Calculate","the","target","spacing","according","to","all","spacings",".","If","the","target","spacing","is","very","anisotropic",",","decrease","the","spacing","value","of","the","maximum","axis","according","to","percentile",".","The","spacing","is","computed","from","`","affine_to_spacing","(","data","[","spacing_key","]","[","0","]",",","3",")","`","if","`","data","[","spacing_key","]","`","is","a","matrix",",","otherwise",",","the","`","data","[","spacing_key","]","`","must","be","a","vector","of","pixdim","values",".","Args",":","spacing_key",":","key","of","the","affine","used","to","compute","spacing","in","metadata","(","default",":","``","affine","``",")",".","anisotropic_threshold",":","threshold","to","decide","if","the","target","spacing","is","anisotropic","(","default",":","``","3","``",")",".","percentile",":","for","anisotropic","target","spacing",",","use","the","percentile","of","all","spacings","of","the","anisotropic","axis","to","replace","that","axis","."]
code: def get_target_spacing(
      self,
      spacing_key: str = "affine",
      anisotropic_threshold: int = 3,
      percentile: float = 10.0,
  ):
      """
      Calculate the target spacing according to all spacings.
      If the target spacing is very anisotropic,
      decrease the spacing value of the maximum axis according to percentile.
      The spacing is computed from `affine_to_spacing(data[spacing_key][0], 3)` if `data[spacing_key]` is a matrix,
      otherwise, the `data[spacing_key]` must be a vector of pixdim values.
  
      Args:
          spacing_key: key of the affine used to compute spacing in metadata (default: ``affine``).
          anisotropic_threshold: threshold to decide if the target spacing is anisotropic (default: ``3``).
          percentile: for anisotropic target spacing, use the percentile of all spacings of the anisotropic axis to
              replace that axis.
  
      """
      if len(self.all_meta_data) == 0:
          self.collect_meta_data()
      if spacing_key not in self.all_meta_data[0]:
          raise ValueError(
              "The provided spacing_key is not in self.all_meta_data."
          )
      spacings = []
      for data in self.all_meta_data:
          spacing_vals = convert_to_tensor(
              data[spacing_key][0], track_meta=False, wrap_sequence=True
          )
          if spacing_vals.ndim == 1:  # vector
              spacings.append(spacing_vals[:3][None])
          elif spacing_vals.ndim == 2:  # matrix
              spacings.append(affine_to_spacing(spacing_vals, 3)[None])
          else:
              raise ValueError(
                  "data[spacing_key] must be a vector or a matrix."
              )
      all_spacings = concatenate(to_cat=spacings, axis=0)
      all_spacings, *_ = convert_data_type(
          data=all_spacings, output_type=np.ndarray, wrap_sequence=True
      )
  
      target_spacing = np.median(all_spacings, axis=0)
      if (
          max(target_spacing) / min(target_spacing)
          >= anisotropic_threshold
      ):
          largest_axis = np.argmax(target_spacing)
          target_spacing[largest_axis] = np.percentile(
              all_spacings[:, largest_axis], percentile
          )
  
      output = list(target_spacing)
  
      return tuple(output)
  
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 3 for calling the DatasetSummary obj's underlying member method code with example usage: obj.get_target_spacing(spacing_key, anisotropic_threshold, percentile) and returns: tuple