code: def test_get_bids_files(tmp_path):
      bids_path = create_fake_bids_dataset(
          base_dir=tmp_path,
          n_sub=10,
          n_ses=2,
          tasks=["localizer", "main"],
          n_runs=[1, 3],
      )
      # For each possible option of file selection we check that we
      # recover the appropriate amount of files, as included in the
      # fake bids dataset.
  
      # 250 files in total related to subject images. Top level files like
      # README not included
      selection = get_bids_files(bids_path)
      assert len(selection) == 250
      # 160 bold files expected. .nii and .json files
      selection = get_bids_files(bids_path, file_tag="bold")
      assert len(selection) == 160
      # Only 90 files are nii.gz. Bold and T1w files.
      selection = get_bids_files(bids_path, file_type="nii.gz")
      assert len(selection) == 90
      # Only 25 files correspond to subject 01
      selection = get_bids_files(bids_path, sub_label="01")
      assert len(selection) == 25
      # There are only 10 files in anat folders. One T1w per subject.
      selection = get_bids_files(bids_path, modality_folder="anat")
      assert len(selection) == 10
      # 20 files corresponding to run 1 of session 2 of main task.
      # 10 bold.nii.gz and 10 bold.json files. (10 subjects)
      filters = [("task", "main"), ("run", "01"), ("ses", "02")]
      selection = get_bids_files(
          bids_path, file_tag="bold", filters=filters
      )
      assert len(selection) == 20
      # Get Top level folder files. Only 1 in this case, the README file.
      selection = get_bids_files(bids_path, sub_folder=False)
      assert len(selection) == 1
      # 80 counfonds (4 runs per ses & sub), testing `fmriprep` >= 20.2 path
      selection = get_bids_files(
          os.path.join(bids_path, "derivatives"),
          file_tag="desc-confounds_timeseries",
      )
      assert len(selection) == 160
  
      bids_path = create_fake_bids_dataset(
          base_dir=tmp_path,
          n_sub=10,
          n_ses=2,
          tasks=["localizer", "main"],
          n_runs=[1, 3],
          confounds_tag="desc-confounds_regressors",
      )
      # 80 counfonds (4 runs per ses & sub), testing `fmriprep` >= 20.2 path
      selection = get_bids_files(
          os.path.join(bids_path, "derivatives"),
          file_tag="desc-confounds_regressors",
      )
      assert len(selection) == 160
  
imports: import json
  import os
  import numpy
  import pandas
  import pytest
  from nilearn._utils.data_gen import add_metadata_to_bids_dataset, create_fake_bids_dataset, generate_fake_fmri_data_and_design
  from nilearn.glm.first_level import FirstLevelModel
  from nilearn.glm.second_level import SecondLevelModel
  from nilearn.interfaces.bids import get_bids_files, parse_bids_filename, save_glm_to_bids
  from nilearn.interfaces.bids.query import _get_metadata_from_bids, infer_repetition_time_from_dataset, infer_slice_timing_start_time_from_dataset
  from nilearn.maskers import NiftiMasker
label_desc: Use image node_id 7 for calling a global function with example usage: test_get_bids_files(tmp_path) without return types