code: def test_exts2par():
      # Test we can load PAR headers from NIfTI extensions
      par_img = PARRECImage.from_filename(EG_PAR)
      nii_img = Nifti1Image.from_image(par_img)
      assert exts2pars(nii_img) == []
      assert exts2pars(nii_img.header) == []
      assert exts2pars(nii_img.header.extensions) == []
      assert exts2pars([]) == []
      # Add a header extension
      with open(EG_PAR, "rb") as fobj:
          hdr_dump = fobj.read()
          dump_ext = Nifti1Extension("comment", hdr_dump)
      nii_img.header.extensions.append(dump_ext)
      hdrs = exts2pars(nii_img)
      assert len(hdrs) == 1
      # Test attribute from PARRECHeader
      assert hdrs[0].get_slice_orientation() == "transverse"
      # Add another PAR extension
      nii_img.header.extensions.append(
          Nifti1Extension("comment", hdr_dump)
      )
      hdrs = exts2pars(nii_img)
      assert len(hdrs) == 2
      # Test attribute from PARRECHeader
      assert hdrs[1].get_slice_orientation() == "transverse"
      # Add null extension, ignored
      nii_img.header.extensions.append(Nifti1Extension("comment", b""))
      # Check all valid inputs
      for source in (
          nii_img,
          nii_img.header,
          nii_img.header.extensions,
          list(nii_img.header.extensions),
      ):
          hdrs = exts2pars(source)
          assert len(hdrs) == 2
  
imports: from glob import glob
  from os.path import basename, dirname
  from os.path import join
  from warnings import simplefilter
  import numpy
  import pytest
  from numpy import array
  from numpy.testing import assert_almost_equal, assert_array_equal
  from ..None import load
  from ..None import parrec
  from ..fileholders import FileHolder
  from ..nifti1 import Nifti1Extension, Nifti1Header, Nifti1Image
  from ..openers import ImageOpener
  from ..parrec import PARRECArrayProxy, PARRECError, PARRECHeader, PARRECImage, exts2pars, parse_PAR_header, vol_is_full, vol_numbers
  from ..testing import assert_arr_dict_equal, clear_and_catch_warnings, suppress_warnings
  from ..volumeutils import array_from_file
  from .None import test_spatialimages
  from .test_arrayproxy import check_mmap
label_desc: Use image node_id 34 for calling a global function with example usage: test_exts2par() without return types