class_docstr: This is a generic class for 2D (slice-wise) segmentation datasets.
  
  :param filename_pairs: a list of tuples in the format (input filename,
                         ground truth filename).
  :param slice_axis: axis to make the slicing (default axial).
  :param cache: if the data should be cached in memory or not.
  :param transform: transformations to apply.
class_docstr_tok: ["This","is","a","generic","class","for","2D","(","slice-wise",")","segmentation","datasets",".",":","param","filename_pairs",":","a","list","of","tuples","in","the","format","(","input","filename",",","ground","truth","filename",")",".",":","param","slice_axis",":","axis","to","make","the","slicing","(","default","axial",")",".",":","param","cache",":","if","the","data","should","be","cached","in","memory","or","not",".",":","param","transform",":","transformations","to","apply","."]
docstr: Compute the mean and standard deviation of the entire dataset.
  
  :param verbose: if True, it will show a progress bar.
  :returns: tuple (mean, std dev)
docstr_tok: ["Compute","the","mean","and","standard","deviation","of","the","entire","dataset",".",":","param","verbose",":","if","True",",","it","will","show","a","progress","bar",".",":","returns",":","tuple","(","mean",",","std","dev",")"]
code: def compute_mean_std(self, verbose=False):
      """Compute the mean and standard deviation of the entire dataset.
  
      :param verbose: if True, it will show a progress bar.
      :returns: tuple (mean, std dev)
      """
      sum_intensities = 0.0
      numel = 0
  
      with DatasetManager(
          self, override_transform=mt_transforms.ToTensor()
      ) as dset:
          pbar = tqdm(
              dset, desc="Mean calculation", disable=not verbose
          )
          for sample in pbar:
              input_data = sample["input"]
              sum_intensities += input_data.sum()
              numel += input_data.numel()
              pbar.set_postfix(
                  mean="{:.2f}".format(sum_intensities / numel),
                  refresh=False,
              )
  
          training_mean = sum_intensities / numel
  
          sum_var = 0.0
          numel = 0
  
          pbar = tqdm(
              dset, desc="Std Dev calculation", disable=not verbose
          )
          for sample in pbar:
              input_data = sample["input"]
              sum_var += (input_data - training_mean).pow(2).sum()
              numel += input_data.numel()
              pbar.set_postfix(
                  std="{:.2f}".format(np.sqrt(sum_var / numel)),
                  refresh=False,
              )
  
      training_std = np.sqrt(sum_var / numel)
      return training_mean.item(), training_std.item()
  
imports: import os
  import re
  import collections
  from medicaltorch import transforms
  from tqdm import tqdm
  import numpy
  import nibabel
  from torch.utils.data import Dataset
  import torch
  from torch._six import string_classes, int_classes
  from PIL import Image
label_desc: Use image node_id 5 for calling the MRI2DSegmentationDataset obj's underlying member method code with example usage: obj.compute_mean_std(verbose) and returns: training_mean,  training_std