code: def fetch_adhd(
      n_subjects=30, data_dir=None, url=None, resume=True, verbose=1
  ):
      """Download and load the ADHD :term:`resting-state` dataset.
  
      See :footcite:t:`ADHDdataset`.
  
      Parameters
      ----------
      n_subjects : int, default=30
          The number of subjects to load from maximum of 40 subjects.
          By default, 30 subjects will be loaded. If None is given,
          all 40 subjects will be loaded.
      %(data_dir)s
      %(url)s
      %(resume)s
      %(verbose)s
  
      Returns
      -------
      data : sklearn.datasets.base.Bunch
          Dictionary-like object, the interest attributes are :
  
           - 'func': Paths to functional :term:`resting-state` images
           - 'phenotypic': Explanations of preprocessing steps
           - 'confounds': CSV files containing the nuisance variables
  
      References
      ----------
      .. footbibliography::
  
      """
      if url is None:
          url = "https://www.nitrc.org/frs/download.php/"
  
      # Preliminary checks and declarations
      dataset_name = "adhd"
      data_dir = get_dataset_dir(
          dataset_name, data_dir=data_dir, verbose=verbose
      )
      ids = adhd_ids()
      nitrc_ids = range(7782, 7822)
      max_subjects = len(ids)
      if n_subjects is None:
          n_subjects = max_subjects
      if n_subjects > max_subjects:
          warnings.warn(
              f"Warning: there are only {max_subjects} subjects"
          )
          n_subjects = max_subjects
      ids = ids[:n_subjects]
      nitrc_ids = nitrc_ids[:n_subjects]
  
      opts = dict(uncompress=True)
  
      # Dataset description
      fdescr = get_dataset_descr(dataset_name)
  
      # First, get the metadata
      phenotypic = (
          "ADHD200_40subs_motion_parameters_and_phenotypics.csv",
          url + "7781/adhd40_metadata.tgz",
          opts,
      )
  
      phenotypic = fetch_files(
          data_dir, [phenotypic], resume=resume, verbose=verbose
      )[0]
  
      # Load the csv file
      phenotypic = np.genfromtxt(
          phenotypic,
          names=True,
          delimiter=",",
          dtype=None,
          encoding=None,
      )
  
      # Keep phenotypic information for selected subjects
      int_ids = np.asarray(ids, dtype=int)
      phenotypic = phenotypic[
          [np.where(phenotypic["Subject"] == i)[0][0] for i in int_ids]
      ]
  
      # Download dataset files
  
      archives = [
          url + f"{int(ni)}/adhd40_{ii}.tgz"
          for ni, ii in zip(nitrc_ids, ids)
      ]
      functionals = [
          f"data/{i}/{i}_rest_tshift_RPI_voreg_mni.nii.gz" for i in ids
      ]
      confounds = [f"data/{i}/{i}_regressors.csv" for i in ids]
  
      functionals = fetch_files(
          data_dir,
          zip(functionals, archives, (opts,) * n_subjects),
          resume=resume,
          verbose=verbose,
      )
  
      confounds = fetch_files(
          data_dir,
          zip(confounds, archives, (opts,) * n_subjects),
          resume=resume,
          verbose=verbose,
      )
  
      return Bunch(
          func=functionals,
          confounds=confounds,
          phenotypic=phenotypic,
          description=fdescr,
      )
  
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 3 for calling a global function with example usage: fetch_adhd(n_subjects, data_dir, url, resume, verbose) and returns: Bunch