code: def _get_atlas_data_and_labels(
      atlas_source,
      atlas_name,
      symmetric_split=False,
      data_dir=None,
      resume=True,
      verbose=1,
  ):
      """Implement fetching logic common to \
      both fetch_atlas_juelich and fetch_atlas_harvard_oxford.
  
      This function downloads the atlas image and labels.
      """
      if atlas_source == "Juelich":
          url = (
              "https://www.nitrc.org/frs/download.php/12096/Juelich.tgz"
          )
      elif atlas_source == "HarvardOxford":
          url = "https://www.nitrc.org/frs/download.php/9902/HarvardOxford.tgz"
      else:
          raise ValueError(f"Atlas source {atlas_source} is not valid.")
      # For practical reasons, we mimic the FSL data directory here.
      data_dir = get_dataset_dir(
          "fsl", data_dir=data_dir, verbose=verbose
      )
      opts = {"uncompress": True}
      root = os.path.join("data", "atlases")
  
      if atlas_source == "HarvardOxford":
          if symmetric_split:
              atlas_name = atlas_name.replace("cort-max", "cortl-max")
  
          if atlas_name.startswith("sub-"):
              label_file = "HarvardOxford-Subcortical.xml"
              is_lateralized = False
          elif atlas_name.startswith("cortl"):
              label_file = "HarvardOxford-Cortical-Lateralized.xml"
              is_lateralized = True
          else:
              label_file = "HarvardOxford-Cortical.xml"
              is_lateralized = False
      else:
          label_file = "Juelich.xml"
          is_lateralized = False
      label_file = os.path.join(root, label_file)
      atlas_file = os.path.join(
          root, atlas_source, f"{atlas_source}-{atlas_name}.nii.gz"
      )
      atlas_file, label_file = fetch_files(
          data_dir,
          [(atlas_file, url, opts), (label_file, url, opts)],
          resume=resume,
          verbose=verbose,
      )
      # Reorder image to have positive affine diagonal
      atlas_img = reorder_img(atlas_file)
      names = {}
      from xml.etree import ElementTree
  
      names[0] = "Background"
      for n, label in enumerate(
          ElementTree.parse(label_file).findall(".//label")
      ):
          new_idx = int(label.get("index")) + 1
          if new_idx in names:
              raise ValueError(
                  f"Duplicate index {new_idx} for labels "
                  f"'{names[new_idx]}', and '{label.text}'"
              )
  
          # fix typos in Harvard Oxford labels
          if atlas_source == "HarvardOxford":
              label.text = label.text.replace("Ventrical", "Ventricle")
              label.text = label.text.replace("Operculum", "Opercular")
  
          names[new_idx] = label.text.strip()
  
      # The label indices should range from 0 to nlabel + 1
      assert list(names.keys()) == list(range(n + 2))
      names = [item[1] for item in sorted(names.items())]
      return atlas_img, atlas_file, names, is_lateralized
  
imports: import json
  import os
  import re
  import shutil
  import warnings
  import xml.etree.ElementTree
  from pathlib import Path
  from tempfile import mkdtemp
  import nibabel
  import numpy
  import pandas
  from sklearn.utils import Bunch
  from .._utils import check_niimg, fill_doc
  from ..image import get_data, new_img_like, reorder_img
  from ._utils import fetch_files, get_dataset_descr, get_dataset_dir
label_desc: Use image node_id 6 for calling a global function with example usage: _get_atlas_data_and_labels(atlas_source, atlas_name, symmetric_split, data_dir, resume, verbose) and returns: atlas_img,  atlas_file,  names,  is_lateralized