code: def test_from_image(self, shape):
      # Check image is generates voxel coordinates
      affine = np.diag([2, 3, 4, 1])
      img = SpatialImage(strided_scalar(shape), affine)
      grid = ps.Grid.from_image(img)
      grid_coords = grid.get_coords()
  
      assert grid.n_coords == prod(shape[:3])
      assert grid.dim == 3
      assert np.allclose(grid.affine, affine)
  
      assert np.allclose(grid_coords[0], [0, 0, 0])
      # Final index is [4, 4, 4], scaled by affine
      assert np.allclose(grid_coords[-1], [8, 12, 16])
  
imports: from math import prod
  from pathlib import Path
  from unittest import skipUnless
  import numpy
  import pytest
  from nibabel import pointset
  from nibabel.affines import apply_affine
  from nibabel.arrayproxy import ArrayProxy
  from nibabel.fileslice import strided_scalar
  from nibabel.onetime import auto_attr
  from nibabel.optpkg import optional_package
  from nibabel.spatialimages import SpatialImage
  from nibabel.tests.nibabel_data import get_nibabel_data
label_desc: Use image node_id 1 for calling the TestGrids obj's underlying member method code with example usage: obj.test_from_image(shape) without return types