class_docstr: Extracts signals over tissue classes or brain regions
  
  >>> seinterface = SignalExtraction()
  >>> seinterface.inputs.in_file = 'functional.nii'
  >>> seinterface.inputs.label_files = 'segmentation0.nii.gz'
  >>> seinterface.inputs.out_file = 'means.tsv'
  >>> segments = ['CSF', 'GrayMatter', 'WhiteMatter']
  >>> seinterface.inputs.class_labels = segments
  >>> seinterface.inputs.detrend = True
  >>> seinterface.inputs.include_global = True
docstr: validate and  process inputs into useful form.
  Returns a list of nilearn maskers and the list of corresponding label
  names.
docstr_tok: ["validate","and","process","inputs","into","useful","form",".","Returns","a","list","of","nilearn","maskers","and","the","list","of","corresponding","label","names","."]
code: def _process_inputs(self):
      """validate and  process inputs into useful form.
      Returns a list of nilearn maskers and the list of corresponding label
      names."""
      import nilearn.input_data as nl
      import nilearn.image as nli
  
      label_data = nli.concat_imgs(self.inputs.label_files)
      maskers = []
  
      # determine form of label files, choose appropriate nilearn masker
      if np.amax(label_data.dataobj) > 1:  # 3d label file
          n_labels = np.amax(label_data.dataobj)
          maskers.append(nl.NiftiLabelsMasker(label_data))
      else:  # 4d labels
          n_labels = label_data.shape[3]
          if (
              self.inputs.incl_shared_variance
          ):  # independent computation
              for img in nli.iter_img(label_data):
                  maskers.append(
                      nl.NiftiMapsMasker(
                          self._4d(img.dataobj, img.affine)
                      )
                  )
          else:  # one computation fitting all
              maskers.append(nl.NiftiMapsMasker(label_data))
  
      # check label list size
      if not np.isclose(int(n_labels), n_labels):
          raise ValueError(
              "The label files {} contain invalid value {}. Check input.".format(
                  self.inputs.label_files, n_labels
              )
          )
  
      if len(self.inputs.class_labels) != n_labels:
          raise ValueError(
              "The length of class_labels {} does not "
              "match the number of regions {} found in "
              "label_files {}".format(
                  self.inputs.class_labels,
                  n_labels,
                  self.inputs.label_files,
              )
          )
  
      if self.inputs.include_global:
          global_label_data = label_data.dataobj.sum(
              axis=3
          )  # sum across all regions
          global_label_data = (
              np.rint(global_label_data).clip(0, 1).astype("u1")
          )  # binarize
          global_label_data = self._4d(
              global_label_data, label_data.affine
          )
          global_masker = nl.NiftiLabelsMasker(
              global_label_data, detrend=self.inputs.detrend
          )
          maskers.insert(0, global_masker)
          self.inputs.class_labels.insert(0, "GlobalSignal")
  
      for masker in maskers:
          masker.set_params(detrend=self.inputs.detrend)
  
      return maskers
  
file_path: nipype/nipype/interfaces/nilearn.py
imports: import os
  import numpy
  import nibabel
  from ..interfaces.base import traits, TraitedSpec, LibraryBaseInterface, SimpleInterface, BaseInterfaceInputSpec, File, InputMultiPath
label_desc: Use image node_id 2 for calling the SignalExtraction obj's underlying member method code with example usage: obj._process_inputs() and returns: maskers