code: def test_get_bids_files_inheritance_principle_root_folder(tmp_path):
      """Check if json files are found if in root folder of a dataset.
  
      see https://bids-specification.readthedocs.io/en/latest/common-principles.html#the-inheritance-principle  # noqa: E501
      """
      bids_path = create_fake_bids_dataset(
          base_dir=tmp_path,
          n_sub=1,
          n_ses=1,
          tasks=["main"],
          n_runs=[1],
      )
  
      _rm_all_json_files_from_bids_dataset(bids_path)
  
      # add json file to root of dataset
      json_file = "task-main_bold.json"
      json_file = add_metadata_to_bids_dataset(
          bids_path=bids_path,
          metadata={"RepetitionTime": 1.5},
          json_file=json_file,
      )
      assert json_file.exists()
  
      # make sure that get_bids_files finds the json file
      # but only when looking in root of dataset
      selection = get_bids_files(
          bids_path,
          file_tag="bold",
          file_type="json",
          filters=[("task", "main")],
          sub_folder=True,
      )
      assert selection == []
      selection = get_bids_files(
          bids_path,
          file_tag="bold",
          file_type="json",
          filters=[("task", "main")],
          sub_folder=False,
      )
      assert selection != []
      assert selection[0] == str(json_file)
  
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 5 for calling a global function with example usage: test_get_bids_files_inheritance_principle_root_folder(tmp_path) without return types