code: def test_truncations():
      # Test tests for truncation
      par = pjoin(DATA_PATH, "T2_.PAR")
      with open(par) as fobj:
          gen_info, slice_info = parse_PAR_header(fobj)
      # Header is well-formed as is
      hdr = PARRECHeader(gen_info, slice_info)
      assert hdr.get_data_shape() == (80, 80, 10, 2)
      # Drop one line, raises error
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info[:-1])
      # When we are permissive, we raise a warning, and drop a volume
      with clear_and_catch_warnings(
          modules=[parrec], record=True
      ) as wlist:
          hdr = PARRECHeader(
              gen_info, slice_info[:-1], permit_truncated=True
          )
          assert len(wlist) == 1
      assert hdr.get_data_shape() == (80, 80, 10)
      # Increase max slices to raise error
      gen_info["max_slices"] = 11
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info)
      gen_info["max_slices"] = 10
      hdr = PARRECHeader(gen_info, slice_info)
      # Increase max_echoes
      gen_info["max_echoes"] = 2
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info)
      gen_info["max_echoes"] = 1
      hdr = PARRECHeader(gen_info, slice_info)
      # dynamics
      gen_info["max_dynamics"] = 3
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info)
      gen_info["max_dynamics"] = 2
      hdr = PARRECHeader(gen_info, slice_info)
      # number of b values
      gen_info["max_diffusion_values"] = 2
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info)
      gen_info["max_diffusion_values"] = 1
      hdr = PARRECHeader(gen_info, slice_info)
      # number of unique gradients
      gen_info["max_gradient_orient"] = 2
      with pytest.raises(PARRECError):
          PARRECHeader(gen_info, slice_info)
      gen_info["max_gradient_orient"] = 1
      hdr = PARRECHeader(gen_info, slice_info)
  
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 24 for calling a global function with example usage: test_truncations() without return types