code: def _stringify_path(filepath_or_buffer: FileSpec) -> str:
      """Attempt to convert a path-like object to a string.
  
      Parameters
      ----------
      filepath_or_buffer : str or os.PathLike
  
      Returns
      -------
      str_filepath_or_buffer : str
  
      Notes
      -----
      Adapted from:
      https://github.com/pandas-dev/pandas/blob/325dd68/pandas/io/common.py#L131-L160
      """
      return pathlib.Path(filepath_or_buffer).expanduser().as_posix()
  
file_path: nibabel/nibabel/filename_parser.py
imports: from __future__ import annotations
  import os
  import pathlib
  import typing
label_desc: Use image node_id 1 for calling a global function with example usage: _stringify_path(filepath_or_buffer) and returns: pathlib