class_docstr: This class is responsible for the search of the appropriate files to use
  as input based on the constraints given in the config file.
docstr: In the config file, constraints for a given search can be of three
  types:
  ``path_to_search``, ``filename_contains`` and
  ``filename_not_contains``. Each associated value is a string.
  Multiple constraints are delimited by a ``,``.
  This function creates the corresponding matching object with the list
  of constraints for each of these subtypes.
  
  :param default_folder: relative paths are first tested against
      the current folder, and then against this default folder.
  :param input_dict: set of searching parameters.
  :return:
docstr_tok: ["In","the","config","file",",","constraints","for","a","given","search","can","be","of","three","types",":","``","path_to_search","``",",","``","filename_contains","``","and","``","filename_not_contains","``",".","Each","associated","value","is","a","string",".","Multiple","constraints","are","delimited","by","a","``",",","``",".","This","function","creates","the","corresponding","matching","object","with","the","list","of","constraints","for","each","of","these","subtypes",".",":","param","default_folder",":","relative","paths","are","first","tested","against","the","current","folder",",","and","then","against","this","default","folder",".",":","param","input_dict",":","set","of","searching","parameters",".",":","return",":"]
code: def from_dict(cls, input_dict, default_folder=None):
      """
      In the config file, constraints for a given search can be of three
      types:
      ``path_to_search``, ``filename_contains`` and
      ``filename_not_contains``. Each associated value is a string.
      Multiple constraints are delimited by a ``,``.
      This function creates the corresponding matching object with the list
      of constraints for each of these subtypes.
  
      :param default_folder: relative paths are first tested against
          the current folder, and then against this default folder.
      :param input_dict: set of searching parameters.
      :return:
      """
      path, contain, not_contain, regex = [], (), (), ()
      for name, value in input_dict.items():
          if not value:
              continue
          if name == "path_to_search":
              try:
                  # for a string of comma separated path.
                  value = value.split(",")
              except AttributeError:
                  pass
  
              for path_i in value:
                  path_i = path_i.strip()
                  path_orig = os.path.abspath(
                      os.path.expanduser(path_i)
                  )
                  if os.path.exists(path_orig):
                      path.append(path_orig)
                      continue
  
                  if not default_folder:
                      tf.logging.fatal(
                          'data input folder "%s" not found, did you maybe '
                          "forget to download data?",
                          path_i,
                      )
                      raise ValueError
                  path_def = os.path.join(default_folder, path_i)
                  path_def = os.path.abspath(path_def)
                  if not os.path.exists(path_def):
                      tf.logging.fatal(
                          'data input folder "%s" not found, did you maybe '
                          "forget to download data?",
                          path_i,
                      )
                      raise ValueError
                  path.append(path_def)
  
          elif name == "filename_contains":
              contain = (
                  tuple(set(value))
                  if not isinstance(value, six.string_types)
                  else tuple([value])
              )
          elif name == "filename_not_contains":
              not_contain = (
                  tuple(set(value))
                  if not isinstance(value, six.string_types)
                  else tuple([value])
              )
          elif name == "filename_removefromid":
              regex = (
                  tuple(set(value))
                  if not isinstance(value, six.string_types)
                  else tuple([value])
              )
      path = tuple(set(path))
      new_matcher = cls(
          path, contain, not_contain, regex[0] if regex else ""
      )
      return new_matcher
  
file_path: NiftyNet/niftynet/utilities/filename_matching.py
imports: from __future__ import absolute_import, print_function
  import os
  import re
  import six
  import niftynet.io.misc_io
  import tensorflow
label_desc: Use image node_id 2 for calling the KeywordsMatching obj's underlying member method code with example usage: obj.from_dict(cls, input_dict, default_folder) and returns: new_matcher