code: def test_expand_to_3d():
      # Test 1D and 2D niftis
      # 1D and 2D with full sform or qform affines raise a NiftiError, because we
      # can't be sure which axes the affine refers to.  Should the image have 1
      # length axes prepended?  Or appended?
      xyz_aff = np.diag([2, 3, 4, 1])
      for size in (10,), (10, 2):
          data = np.random.normal(size=size)
          ni_img = nib.Nifti1Image(data, xyz_aff)
          # Default is aligned
          pytest.raises(NiftiError, nifti2nipy, ni_img)
          hdr = get_header(ni_img)
          # The pixdim affine
          for label in "scanner", "aligned", "talairach", "mni":
              hdr.set_sform(xyz_aff, label)
              pytest.raises(NiftiError, nifti2nipy, ni_img)
              hdr.set_sform(None)
              pytest.raises(NiftiError, nifti2nipy, ni_img)
              hdr.set_sform(xyz_aff, label)
              pytest.raises(NiftiError, nifti2nipy, ni_img)
              hdr.set_qform(None)
  
imports: import warnings
  from copy import copy
  import nibabel
  import numpy
  import pytest
  from nibabel.affines import from_matvec
  from nibabel.spatialimages import HeaderDataError
  from numpy.testing import assert_array_equal
  from ...core.api import AffineTransform
  from ...core.api import CoordinateSystem
  from ...core.api import Image
  from ...core.reference.spaces import aligned_csm, mni_csm, scanner_csm, talairach_csm, unknown_csm, unknown_space, vox2mni
  from ...testing import anatfile, funcfile
  from ..files import load
  from ..nibcompat import get_affine, get_header
  from ..nifti_ref import NiftiError, nifti2nipy, nipy2nifti
label_desc: Use image node_id 17 for calling a global function with example usage: test_expand_to_3d() without return types