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","."]
code: def _prepare_indexes(self):
      for segpair in self.handlers:
          input_data_shape, _ = segpair.get_pair_shapes()
          for segpair_slice in range(input_data_shape[2]):
              # Check if slice pair should be used or not
              if self.slice_filter_fn:
                  slice_pair = segpair.get_pair_slice(
                      segpair_slice, self.slice_axis
                  )
  
                  filter_fn_ret = self.slice_filter_fn(slice_pair)
                  if not filter_fn_ret:
                      continue
  
              item = (segpair, segpair_slice)
              self.indexes.append(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 3 for calling the MRI2DSegmentationDataset obj's underlying member method code with example usage: obj._prepare_indexes() without return types