code: def fetch_openneuro_dataset(
      urls=None,
      data_dir=None,
      dataset_version="ds000030_R1.0.4",
      verbose=1,
  ):
      """Download OpenNeuro :term:`BIDS` dataset.
  
      This function specifically downloads files from a series of URLs.
      Unless you use :func:`fetch_ds000030_urls` or the default parameters,
      it is up to the user to ensure that the URLs are correct,
      and that they are associated with an OpenNeuro dataset.
  
      Parameters
      ----------
      urls : :obj:`list` of :obj:`str`, optional
          List of URLs to dataset files to download.
          If not specified, all files from the default dataset
          (``ds000030_R1.0.4``) will be downloaded.
      %(data_dir)s
      dataset_version : :obj:`str`, default='ds000030_R1.0.4'
          Dataset version name. Assumes it is of the form [name]_[version].
      %(verbose)s
  
      Returns
      -------
      data_dir : :obj:`str`
          Path to downloaded dataset.
  
      downloaded_files : :obj:`list` of :obj:`str`
          Absolute paths of downloaded files on disk.
  
      Notes
      -----
      The default dataset downloaded by this function is the
      "UCLA Consortium for Neuropsychiatric Phenomics LA5c" dataset
      :footcite:p:`Poldrack2016`.
  
      This copy includes filenames that are not compliant with the current
      version of :term:`BIDS`, so this function also calls
      :func:`patch_openneuro_dataset` to generate BIDS-compliant symlinks.
  
      See Also
      --------
      :func:`fetch_ds000030_urls`
      :func:`patch_openneuro_dataset`
  
      References
      ----------
      .. footbibliography::
      """
      # if urls are not specified we download the complete dataset index
      if urls is None:
          DATASET_VERSION = "ds000030_R1.0.4"
          if dataset_version != DATASET_VERSION:
              warnings.warn(
                  'If `dataset_version` is not "ds000030_R1.0.4", '
                  '`urls` must be specified. Downloading "ds000030_R1.0.4".'
              )
  
          data_prefix = f"{DATASET_VERSION.split('_')[0]}/{DATASET_VERSION}/uncompressed"
          orig_data_dir = data_dir
          data_dir = get_dataset_dir(
              data_prefix,
              data_dir=data_dir,
              verbose=verbose,
          )
  
          _, urls = fetch_ds000030_urls(
              data_dir=orig_data_dir,
              verbose=verbose,
          )
      else:
          data_prefix = f"{dataset_version.split('_')[0]}/{dataset_version}/uncompressed"
          data_dir = get_dataset_dir(
              data_prefix,
              data_dir=data_dir,
              verbose=verbose,
          )
  
      # The files_spec needed for fetch_files
      files_spec = []
      files_dir = []
  
      # Check that data prefix is found in each URL
      bad_urls = [url for url in urls if data_prefix not in url]
      if bad_urls:
          raise ValueError(
              f"data_prefix ({data_prefix}) is not found in at least one URL. "
              "This indicates that the URLs do not correspond to the "
              "dataset_version provided.\n"
              f"Affected URLs: {bad_urls}"
          )
  
      for url in urls:
          url_path = url.split(data_prefix + "/")[1]
          file_dir = os.path.join(data_dir, url_path)
          files_spec.append((os.path.basename(file_dir), url, {}))
          files_dir.append(os.path.dirname(file_dir))
  
      # download the files
      downloaded = []
      for file_spec, file_dir in zip(files_spec, files_dir):
          # Timeout errors are common in the s3 connection so we try to avoid
          # failure of the dataset download for a transient instability
          success = False
          download_attempts = 4
          while download_attempts > 0 and not success:
              try:
                  downloaded_files = fetch_files(
                      file_dir,
                      [file_spec],
                      resume=True,
                      verbose=verbose,
                  )
                  downloaded += downloaded_files
                  success = True
              except Exception:
                  download_attempts -= 1
  
          if not success:
              raise Exception(
                  f"multiple failures downloading {file_spec[1]}"
              )
  
      patch_openneuro_dataset(downloaded)
  
      return data_dir, sorted(downloaded)
  
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 28 for calling a global function with example usage: fetch_openneuro_dataset(urls, data_dir, dataset_version, verbose) and returns: data_dir,  sorted