class_docstr: This is the Spinal Cord Gray Matter Challenge dataset.
  
  :param root_dir: the directory containing the test dataset.
  :param site_ids: a list of site ids to filter (i.e. [1, 3]).
  :param subj_ids: the list of subject ids to filter.
  :param transform: the transformations that should be applied.
  :param cache: if the data should be cached in memory or not.
  :param slice_axis: axis to make the slicing (default axial).
  
  .. note:: This dataset assumes that you only have one class in your
            ground truth mask (w/ 0's and 1's). It also doesn't
            automatically resample the dataset.
  
  .. seealso::
      Prados, F., et al (2017). Spinal cord grey matter
      segmentation challenge. NeuroImage, 152, 312–329.
      https://doi.org/10.1016/j.neuroimage.2017.03.010
  
      Challenge Website:
      http://cmictig.cs.ucl.ac.uk/spinal-cord-grey-matter-segmentation-challenge
class_docstr_tok: ["This","is","the","Spinal","Cord","Gray","Matter","Challenge","dataset",".",":","param","root_dir",":","the","directory","containing","the","test","dataset",".",":","param","site_ids",":","a","list","of","site","ids","to","filter","(","i.e",".","[","1",",","3","]",")",".",":","param","subj_ids",":","the","list","of","subject","ids","to","filter",".",":","param","transform",":","the","transformations","that","should","be","applied",".",":","param","cache",":","if","the","data","should","be","cached","in","memory","or","not",".",":","param","slice_axis",":","axis","to","make","the","slicing","(","default","axial",")",".","..","note",":",":","This","dataset","assumes","that","you","only","have","one","class","in","your","ground","truth","mask","(","w\/","0","'s","and","1","'s",")",".","It","also","doesn't","automatically","resample","the","dataset",".","..","seealso",":",":","Prados",",","F.",",","et","al","(","2017",")",".","Spinal","cord","grey","matter","segmentation","challenge",".","NeuroImage",",","152",",","312\u2013329",".","https",":","\/\/doi.org\/10.1016\/j.neuroimage.2017.03.010","Challenge","Website",":","http",":","\/\/cmictig.cs.ucl.ac.uk\/spinal-cord-grey-matter-segmentation-challenge"]
code: def __init__(
      self,
      root_dir,
      slice_axis=2,
      site_ids=None,
      subj_ids=None,
      cache=True,
      transform=None,
      slice_filter_fn=None,
      canonical=False,
  ):
      self.root_dir = root_dir
      self.site_ids = site_ids or range(
          1, SCGMChallenge2DTest.NUM_SITES + 1
      )
      self.subj_ids = subj_ids or range(
          11, 10 + SCGMChallenge2DTest.NUM_SUBJECTS + 1
      )
  
      self.filename_pairs = []
  
      for site_id in self.site_ids:
          for subj_id in self.subj_ids:
              input_filename = self._build_train_input_filename(
                  site_id, subj_id
              )
              gt_filename = None
  
              input_filename = os.path.join(
                  self.root_dir, input_filename
              )
              if not os.path.exists(input_filename):
                  raise RuntimeError(
                      "Path '{}' doesn't exist !".format(input_filename)
                  )
              self.filename_pairs.append((input_filename, gt_filename))
  
      super().__init__(
          self.filename_pairs,
          slice_axis,
          cache,
          transform,
          slice_filter_fn,
          canonical,
      )
  
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 1 to create a new SCGMChallenge2DTest object from inherited base classes: MRI2DSegmentationDataset with example: obj = SCGMChallenge2DTest(root_dir, slice_axis, site_ids, subj_ids, cache, transform, slice_filter_fn, canonical)