code: def test_read_mgh():
      # test.mgz was generated by the following command
      # mri_volsynth --dim 3 4 5 2 --vol test.mgz
      # --cdircos 1 2 3 --rdircos 2 3 1 --sdircos 3 1 2
      # mri_volsynth is a FreeSurfer command
      mgz = load(MGZ_FNAME)
  
      # header
      h = mgz.header
      assert h["version"] == 1
      assert h["type"] == 3
      assert h["dof"] == 0
      assert h["goodRASFlag"] == 1
      assert_array_equal(h["dims"], [3, 4, 5, 2])
      assert_almost_equal(h["tr"], 2.0)
      assert_almost_equal(h["flip_angle"], 0.0)
      assert_almost_equal(h["te"], 0.0)
      assert_almost_equal(h["ti"], 0.0)
      assert_array_almost_equal(h.get_zooms(), [1, 1, 1, 2])
      assert_array_almost_equal(h.get_vox2ras(), v2r)
      assert_array_almost_equal(h.get_vox2ras_tkr(), v2rtkr)
  
      # data. will be different for your own mri_volsynth invocation
      v = mgz.get_fdata()
      assert_almost_equal(v[1, 2, 3, 0], -0.3047, 4)
      assert_almost_equal(v[1, 2, 3, 1], 0.0018, 4)
  
imports: import io
  import os
  import pathlib
  import numpy
  import pytest
  from numpy.testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from ...None import imageglobals
  from ...fileholders import FileHolder
  from ...openers import ImageOpener
  from ...spatialimages import HeaderDataError
  from ...testing import data_path
  from ...tests import test_spatialimages
  from ...tests import test_wrapstruct
  from ...tmpdirs import InTemporaryDirectory
  from ...volumeutils import sys_is_le
  from ...wrapstruct import WrapStructError
  from ..None import load, save
  from ..mghformat import MGHError, MGHHeader, MGHImage
label_desc: Use image node_id 1 for calling a global function with example usage: test_read_mgh() without return types