code: def test_select_from_index():
      dataset_version = "ds000030_R1.0.4"
      data_prefix = f"{dataset_version.split('_')[0]}/{dataset_version}/uncompressed"
      # Prepare url files for subject and filter tests
      urls = [
          f"{data_prefix}/{f}"
          for f in [
              "stuff.html",
              "sub-xxx.html",
              "sub-yyy.html",
              "sub-xxx/ses-01_task-rest.txt",
              "sub-xxx/ses-01_task-other.txt",
              "sub-xxx/ses-02_task-rest.txt",
              "sub-xxx/ses-02_task-other.txt",
              "sub-yyy/ses-01.txt",
              "sub-yyy/ses-02.txt",
          ]
      ]
  
      # Only 1 subject and not subject specific files get downloaded
      new_urls = func.select_from_index(urls, n_subjects=1)
  
      assert len(new_urls) == 6
      assert data_prefix + "/sub-yyy.html" not in new_urls
  
      # 2 subjects and not subject specific files get downloaded
      new_urls = func.select_from_index(urls, n_subjects=2)
  
      assert len(new_urls) == 9
      assert data_prefix + "/sub-yyy.html" in new_urls
  
      # ALL subjects and not subject specific files get downloaded
      new_urls = func.select_from_index(urls, n_subjects=None)
  
      assert len(new_urls) == 9
  
      # test inclusive filters. Only files with task-rest
      new_urls = func.select_from_index(
          urls, inclusion_filters=["*task-rest*"]
      )
  
      assert len(new_urls) == 2
      assert data_prefix + "/stuff.html" not in new_urls
  
      # test exclusive filters. only files without ses-01
      new_urls = func.select_from_index(
          urls, exclusion_filters=["*ses-01*"]
      )
  
      assert len(new_urls) == 6
      assert data_prefix + "/stuff.html" in new_urls
  
      # test filter combination. only files with task-rest and without ses-01
      new_urls = func.select_from_index(
          urls,
          inclusion_filters=["*task-rest*"],
          exclusion_filters=["*ses-01*"],
      )
  
      assert len(new_urls) == 1
      assert data_prefix + "/sub-xxx/ses-02_task-rest.txt" in new_urls
  
imports: import json
  import os
  import re
  import shutil
  import tempfile
  import uuid
  from collections import OrderedDict
  from pathlib import Path
  import nibabel
  import numpy
  import pandas
  import pytest
  from nilearn.datasets import func
  from nilearn.datasets._utils import get_dataset_dir
  from nilearn.datasets.tests._testing import dict_to_archive, list_to_archive
  from nilearn.image import load_img
label_desc: Use image node_id 29 for calling a global function with example usage: test_select_from_index() without return types