code: def _get_metadata_from_bids(
      field,
      json_files,
      bids_path=None,
  ):
      """Get a metadata field from a BIDS json sidecar files.
  
      This assumes that all the json files in the list have the same value
      for that field,
      hence the metadata is read only from the first json file in the list.
  
      Parameters
      ----------
      field : :obj:`str`
          Name of the field to be read. For example 'RepetitionTime'.
  
      json_files : :obj:`list` of :obj:`str`
          List of path to json files, for example returned by get_bids_files.
  
      bids_path : :obj:`str` or :obj:`pathlib.Path`, optional
          Fullpath to the BIDS dataset.
  
      Returns
      -------
      float or None
          value of the field or None if the field is not found.
      """
      if json_files:
          assert isinstance(json_files, list) and isinstance(
              json_files[0], (Path, str)
          )
          with open(json_files[0]) as f:
              specs = json.load(f)
          value = specs.get(field)
          if value is not None:
              return value
          else:
              warn(f"'{field}' not found in file {json_files[0]}.")
      else:
          msg_suffix = f" in {bids_path}" if bids_path else ""
          warn(f"No bold.json found in BIDS folder{msg_suffix}.")
  
      return None
  
file_path: nilearn/nilearn/interfaces/bids/query.py
imports: from __future__ import annotations
  import glob
  import json
  import os
  from pathlib import Path
  from warnings import warn
label_desc: Use image node_id 1 for calling a global function with example usage: _get_metadata_from_bids(field, json_files, bids_path) and returns: None, value