code: def fetch_localizer_contrasts(
      contrasts,
      n_subjects=None,
      get_tmaps=False,
      get_masks=False,
      get_anats=False,
      data_dir=None,
      url=None,
      resume=True,
      verbose=1,
      legacy_format=True,
  ):
      """Download and load Brainomics/Localizer dataset (94 subjects).
  
      "The Functional Localizer is a simple and fast acquisition
      procedure based on a 5-minute functional magnetic resonance
      imaging (fMRI) sequence that can be run as easily and as
      systematically as an anatomical scan. This protocol captures the
      cerebral bases of auditory and visual perception, motor actions,
      reading, language comprehension and mental calculation at an
      individual level. Individual functional maps are reliable and
      quite precise. The procedure is described in more detail on the
      Functional Localizer page."
      (see https://osf.io/vhtf6/)
  
      You may cite :footcite:t:`Papadopoulos-Orfanos2017`
      when using this dataset.
  
      Scientific results obtained using this dataset are described
      in :footcite:t:`Pinel2007`.
  
      Parameters
      ----------
      contrasts : :obj:`list` of :obj:`str`
          The contrasts to be fetched (for all 94 subjects available).
          Allowed values are::
  
          - "checkerboard"
          - "horizontal checkerboard"
          - "vertical checkerboard"
          - "horizontal vs vertical checkerboard"
          - "vertical vs horizontal checkerboard"
          - "sentence listening"
          - "sentence reading"
          - "sentence listening and reading"
          - "sentence reading vs checkerboard"
          - "calculation (auditory cue)"
          - "calculation (visual cue)"
          - "calculation (auditory and visual cue)"
          - "calculation (auditory cue) vs sentence listening"
          - "calculation (visual cue) vs sentence reading"
          - "calculation vs sentences"
          - "calculation (auditory cue) and sentence listening"
          - "calculation (visual cue) and sentence reading"
          - "calculation and sentence listening/reading"
          - "calculation (auditory cue) and sentence listening vs "
          - "calculation (visual cue) and sentence reading"
          - "calculation (visual cue) and sentence reading vs checkerboard"
          - "calculation and sentence listening/reading vs button press"
          - "left button press (auditory cue)"
          - "left button press (visual cue)"
          - "left button press"
          - "left vs right button press"
          - "right button press (auditory cue)"
          - "right button press (visual cue)"
          - "right button press"
          - "right vs left button press"
          - "button press (auditory cue) vs sentence listening"
          - "button press (visual cue) vs sentence reading"
          - "button press vs calculation and sentence listening/reading"
  
          or equivalently on can use the original names::
  
          - "checkerboard"
          - "horizontal checkerboard"
          - "vertical checkerboard"
          - "horizontal vs vertical checkerboard"
          - "vertical vs horizontal checkerboard"
          - "auditory sentences"
          - "visual sentences"
          - "auditory&visual sentences"
          - "visual sentences vs checkerboard"
          - "auditory calculation"
          - "visual calculation"
          - "auditory&visual calculation"
          - "auditory calculation vs auditory sentences"
          - "visual calculation vs sentences"
          - "auditory&visual calculation vs sentences"
          - "auditory processing"
          - "visual processing"
          - "visual processing vs auditory processing"
          - "auditory processing vs visual processing"
          - "visual processing vs checkerboard"
          - "cognitive processing vs motor"
          - "left auditory click"
          - "left visual click"
          - "left auditory&visual click"
          - "left auditory & visual click vs right auditory&visual click"
          - "right auditory click"
          - "right visual click"
          - "right auditory&visual click"
          - "right auditory & visual click vs left auditory&visual click"
          - "auditory click vs auditory sentences"
          - "visual click vs visual sentences"
          - "auditory&visual motor vs cognitive processing"
  
      n_subjects : int or list, optional
          The number or list of subjects to load. If None is given,
          all 94 subjects are used.
  
      get_tmaps : boolean, default=False
          Whether t maps should be fetched or not.
  
      get_masks : boolean, default=False
          Whether individual masks should be fetched or not.
  
      get_anats : boolean, default=False
          Whether individual structural images should be fetched or not.
      %(data_dir)s
      %(url)s
      %(resume)s
      %(verbose)s
      %(legacy_format)s
  
      Returns
      -------
      data : Bunch
          Dictionary-like object, the interest attributes are :
  
          - 'cmaps': :obj:`list` of :obj:`str`
              Paths to nifti contrast maps
          - 'tmaps' :obj:`list` of :obj:`str` (if 'get_tmaps' set to True)
              Paths to nifti t maps
          - 'masks': :obj:`list` of :obj:`str`
              Paths to nifti files corresponding to the subjects individual masks
          - 'anats': :obj:`str`
              Path to nifti files corresponding to the subjects structural images
  
      References
      ----------
      .. footbibliography::
  
      See Also
      --------
      nilearn.datasets.fetch_localizer_calculation_task
      nilearn.datasets.fetch_localizer_button_task
  
      """
      if isinstance(contrasts, str):
          raise ValueError(
              "Contrasts should be a list of strings, but "
              f'a single string was given: "{contrasts}"'
          )
      if n_subjects is None:
          n_subjects = 94  # 94 subjects available
      if isinstance(n_subjects, numbers.Number) and (
          (n_subjects > 94) or (n_subjects < 1)
      ):
          warnings.warn(
              "Wrong value for 'n_subjects' (%d). The maximum "
              "value will be used instead ('n_subjects=94')"
          )
          n_subjects = 94  # 94 subjects available
  
      # we allow the user to use alternatives to Brainomics contrast names
      contrast_name_wrapper = {
          # Checkerboard
          "checkerboard": "checkerboard",
          "horizontal checkerboard": "horizontal checkerboard",
          "vertical checkerboard": "vertical checkerboard",
          "horizontal vs vertical checkerboard": "horizontal vs vertical checkerboard",  # noqa 501
          "vertical vs horizontal checkerboard": "vertical vs horizontal checkerboard",  # noqa 501
          # Sentences
          "sentence listening": "auditory sentences",
          "sentence reading": "visual sentences",
          "sentence listening and reading": "auditory&visual sentences",
          "sentence reading vs checkerboard": "visual sentences vs checkerboard",
          # Calculation
          "calculation (auditory cue)": "auditory calculation",
          "calculation (visual cue)": "visual calculation",
          "calculation (auditory and visual cue)": "auditory&visual calculation",  # noqa 501
          "calculation (auditory cue) vs sentence listening": "auditory calculation vs auditory sentences",  # noqa 501
          "calculation (visual cue) vs sentence reading": "visual calculation vs sentences",  # noqa 501
          "calculation vs sentences": "auditory&visual calculation vs sentences",  # noqa 501
          # Calculation + Sentences
          "calculation (auditory cue) and sentence listening": "auditory processing",  # noqa 501
          "calculation (visual cue) and sentence reading": "visual processing",
          "calculation (visual cue) and sentence reading vs "
          "calculation (auditory cue) and sentence listening": "visual processing vs auditory processing",  # noqa 501
          "calculation (auditory cue) and sentence listening vs "
          "calculation (visual cue) and sentence reading": "auditory processing vs visual processing",  # noqa 501
          "calculation (visual cue) and sentence reading vs checkerboard": "visual processing vs checkerboard",  # noqa 501
          "calculation and sentence listening/reading vs button press": "cognitive processing vs motor",  # noqa 501
          # Button press
          "left button press (auditory cue)": "left auditory click",
          "left button press (visual cue)": "left visual click",
          "left button press": "left auditory&visual click",
          "left vs right button press": "left auditory & visual click vs "
          + "right auditory&visual click",
          "right button press (auditory cue)": "right auditory click",
          "right button press (visual cue)": "right visual click",
          "right button press": "right auditory & visual click",
          "right vs left button press": "right auditory & visual click "
          + "vs left auditory&visual click",
          "button press (auditory cue) vs sentence listening": "auditory click vs auditory sentences",  # noqa 501
          "button press (visual cue) vs sentence reading": "visual click vs visual sentences",  # noqa 501
          "button press vs calculation and sentence listening/reading": "auditory&visual motor vs cognitive processing",  # noqa 501
      }
      allowed_contrasts = list(contrast_name_wrapper.values())
  
      # convert contrast names
      contrasts_wrapped = []
      # get a unique ID for each contrast. It is used to give a unique name to
      # each download file and avoid name collisions.
      contrasts_indices = []
      for contrast in contrasts:
          if contrast in allowed_contrasts:
              contrasts_wrapped.append(
                  contrast.title().replace(" ", "")
              )
              contrasts_indices.append(
                  allowed_contrasts.index(contrast)
              )
          elif contrast in contrast_name_wrapper:
              name = contrast_name_wrapper[contrast]
              contrasts_wrapped.append(name.title().replace(" ", ""))
              contrasts_indices.append(allowed_contrasts.index(name))
          else:
              raise ValueError(
                  f"Contrast '{contrast}' is not available"
              )
  
      # Get the dataset OSF index
      dataset_name = "brainomics_localizer"
      index_url = "https://osf.io/hwbm2/download"
      data_dir = get_dataset_dir(
          dataset_name, data_dir=data_dir, verbose=verbose
      )
      index_file = fetch_single_file(
          index_url, data_dir, verbose=verbose
      )
      with open(index_file) as of:
          index = json.load(of)
  
      # Build data URLs that will be fetched
      files = {}
      # Download from the relevant OSF project, using hashes generated
      # from the OSF API. Note the trailing slash. For more info, see:
      # https://gist.github.com/emdupre/3cb4d564511d495ea6bf89c6a577da74
      root_url = "https://osf.io/download/{0}/"
      if isinstance(n_subjects, numbers.Number):
          subject_mask = np.arange(1, n_subjects + 1)
      else:
          subject_mask = np.array(n_subjects)
      subject_ids = [f"S{int(s):02}" for s in subject_mask]
      data_types = ["cmaps"]
      if get_tmaps:
          data_types.append("tmaps")
      filenames = []
  
      def _is_valid_path(path, index, verbose):
          if path not in index:
              if verbose > 0:
                  print(f"Skipping path '{path}'...")
              return False
          return True
  
      for subject_id in subject_ids:
          for data_type in data_types:
              for _, contrast in enumerate(contrasts_wrapped):
                  name_aux = str.replace(
                      str.join("_", [data_type, contrast]), " ", "_"
                  )
                  file_path = os.path.join(
                      "brainomics_data",
                      subject_id,
                      f"{name_aux}.nii.gz",
                  )
                  path = "/".join(
                      [
                          "/localizer",
                          "derivatives",
                          "spm_1st_level",
                          f"sub-{subject_id}",
                          (
                              f"sub-{subject_id}_task-localizer"
                              f"_acq-{contrast}_{data_type}.nii.gz"
                          ),
                      ]
                  )
                  if _is_valid_path(path, index, verbose=verbose):
                      file_url = root_url.format(index[path][1:])
                      opts = {"move": file_path}
                      filenames.append((file_path, file_url, opts))
                      files.setdefault(data_type, []).append(file_path)
  
      # Fetch masks if asked by user
      if get_masks:
          for subject_id in subject_ids:
              file_path = os.path.join(
                  "brainomics_data",
                  subject_id,
                  "boolean_mask_mask.nii.gz",
              )
              path = "/".join(
                  [
                      "/localizer",
                      "derivatives",
                      "spm_1st_level",
                      f"sub-{subject_id}",
                      f"sub-{subject_id}_mask.nii.gz",
                  ]
              )
              if _is_valid_path(path, index, verbose=verbose):
                  file_url = root_url.format(index[path][1:])
                  opts = {"move": file_path}
                  filenames.append((file_path, file_url, opts))
                  files.setdefault("masks", []).append(file_path)
  
      # Fetch anats if asked by user
      if get_anats:
          for subject_id in subject_ids:
              file_path = os.path.join(
                  "brainomics_data",
                  subject_id,
                  "normalized_T1_anat_defaced.nii.gz",
              )
              path = "/".join(
                  [
                      "/localizer",
                      "derivatives",
                      "spm_preprocessing",
                      f"sub-{subject_id}",
                      f"sub-{subject_id}_T1w.nii.gz",
                  ]
              )
              if _is_valid_path(path, index, verbose=verbose):
                  file_url = root_url.format(index[path][1:])
                  opts = {"move": file_path}
                  filenames.append((file_path, file_url, opts))
                  files.setdefault("anats", []).append(file_path)
  
      # Fetch subject characteristics
      participants_file = os.path.join(
          "brainomics_data", "participants.tsv"
      )
      path = "/localizer/participants.tsv"
      if _is_valid_path(path, index, verbose=verbose):
          file_url = root_url.format(index[path][1:])
          opts = {"move": participants_file}
          filenames.append((participants_file, file_url, opts))
  
      # Fetch behavioural
      behavioural_file = os.path.join(
          "brainomics_data", "phenotype", "behavioural.tsv"
      )
      path = "/localizer/phenotype/behavioural.tsv"
      if _is_valid_path(path, index, verbose=verbose):
          file_url = root_url.format(index[path][1:])
          opts = {"move": behavioural_file}
          filenames.append((behavioural_file, file_url, opts))
  
      # Actual data fetching
      fdescr = get_dataset_descr(dataset_name)
      fetch_files(data_dir, filenames, verbose=verbose)
      for key, value in files.items():
          files[key] = [os.path.join(data_dir, val) for val in value]
  
      # Load covariates file
      participants_file = os.path.join(data_dir, participants_file)
      csv_data = pd.read_csv(participants_file, delimiter="\t")
      behavioural_file = os.path.join(data_dir, behavioural_file)
      csv_data2 = pd.read_csv(behavioural_file, delimiter="\t")
      csv_data = csv_data.merge(csv_data2)
      subject_names = csv_data["participant_id"].tolist()
      subjects_indices = []
      for name in subject_ids:
          if name not in subject_names:
              continue
          subjects_indices.append(subject_names.index(name))
      csv_data = csv_data.iloc[subjects_indices]
      if legacy_format:
          warnings.warn(_LEGACY_FORMAT_MSG, DeprecationWarning)
          csv_data = csv_data.to_records(index=False)
      return Bunch(ext_vars=csv_data, description=fdescr, **files)
  
imports: import fnmatch
  import glob
  import json
  import numbers
  import os
  import re
  import warnings
  from io import BytesIO
  from pathlib import Path
  import nibabel
  import nibabel
  import numpy
  import pandas
  from scipy.io import loadmat
  from sklearn.utils import Bunch
  from nilearn.image import get_data
  from .._utils import check_niimg, fill_doc
  from .._utils.numpy_conversions import csv_to_array
  from ._utils import fetch_files, fetch_single_file, filter_columns, get_dataset_descr, get_dataset_dir, read_md5_sum_file, tree, uncompress_file
label_desc: Use image node_id 6 for calling a global function with example usage: fetch_localizer_contrasts(contrasts, n_subjects, get_tmaps, get_masks, get_anats, data_dir, url, resume, verbose, legacy_format) and returns: Bunch, True, False