code: def str2bool(v):
      """
      Convert strings (and bytearrays) to boolean values
  
      >>> all([str2bool(v) for v in (True, "yes", "true",
      ...      "y", "t", "Yes", "True", "1", "on", "On")])
      True
      >>> all([str2bool(v.encode('utf-8'))
      ...      for v in ("yes", "true", "y", "t", "1", "Yes", "on", "On")])
      True
      >>> any([str2bool(v) for v in (False, "no", "false", "n", "f",
      ...      "False", "0", "off", "Off")])
      False
      >>> any([str2bool(v.encode('utf-8'))
      ...      for v in ("no", "false", "n", "f", "0", "off", "Off")])
      False
      >>> str2bool(None)  # doctest: +ELLIPSIS
      Traceback (most recent call last):
          ...
      ValueError: ...
      >>> str2bool('/some/path')  # doctest: +ELLIPSIS
      Traceback (most recent call last):
          ...
      ValueError: ...
      >>> str2bool('Agg')  # doctest: +ELLIPSIS
      Traceback (most recent call last):
          ...
      ValueError: ...
      >>> str2bool('INFO')  # doctest: +ELLIPSIS
      Traceback (most recent call last):
          ...
      ValueError: ...
      >>> str2bool('/some/bytes/path'.encode('utf-8'))  # doctest: +ELLIPSIS
      Traceback (most recent call last):
          ...
      ValueError: ...
  
      """
      if isinstance(v, bool):
          return v
  
      if isinstance(v, bytes):
          v = v.decode("utf-8")
  
      if isinstance(v, str):
          lower = v.lower()
          if lower in ("yes", "true", "y", "t", "1", "on"):
              return True
          elif lower in ("no", "false", "n", "f", "0", "off"):
              return False
  
      raise ValueError("%r cannot be converted to bool" % v)
  
file_path: nipype/nipype/utils/misc.py
imports: import os
  import sys
  import re
  from collections.abc import Iterator
  from warnings import warn
  from looseversion import LooseVersion
  import numpy
  import textwrap
label_desc: Use image node_id 7 for calling a global function with example usage: str2bool(v) and returns: v, True, False