code: def _type_from_filename(filename):
      """Return image type determined from filename
  
      Filetype is determined by the file extension in 'filename'.
      Currently the following filetypes are supported:
  
      * Nifti single file : ['.nii', '.nii.gz']
      * Nifti file pair : ['.hdr', '.hdr.gz']
      * Analyze file pair : ['.img', '.img.gz']
  
      >>> _type_from_filename('test.nii')
      'nifti1single'
      >>> _type_from_filename('test')
      'nifti1single'
      >>> _type_from_filename('test.hdr')
      'nifti1pair'
      >>> _type_from_filename('test.hdr.gz')
      'nifti1pair'
      >>> _type_from_filename('test.img.gz')
      'analyze'
      >>> _type_from_filename('test.mnc')
      'minc'
      """
      filename = str(filename)
      if filename.endswith(".gz"):
          filename = filename[:-3]
      elif filename.endswith(".bz2"):
          filename = filename[:-4]
      _, ext = os.path.splitext(filename)
      if ext in ("", ".nii"):
          return "nifti1single"
      if ext == ".hdr":
          return "nifti1pair"
      if ext == ".img":
          return "analyze"
      if ext == ".mnc":
          return "minc"
      raise ValueError(f'Strange file extension "{ext}"')
  
file_path: nipy/nipy/io/files.py
imports: import os
  import nibabel
  import numpy
  from nibabel.spatialimages import HeaderDataError
  from ..core.image.image import is_image
  from .nibcompat import get_affine, get_dataobj, get_header
  from .nifti_ref import nifti2nipy, nipy2nifti
label_desc: Use image node_id 3 for calling a global function with example usage: _type_from_filename(filename) and returns: str, str, str, str