class_docstr: A regularly-spaced collection of coordinates
  
  This class provides factory methods for generating Pointsets from
  :class:`~nibabel.spatialimages.SpatialImage`\s and generating masks
  from coordinate sets.
class_docstr_tok: ["A","regularly-spaced","collection","of","coordinates","This","class","provides","factory","methods","for","generating","Pointsets","from",":","class",":","`","~nibabel.spatialimages.SpatialImage","`","\\s","and","generating","masks","from","coordinate","sets","."]
code: def from_image(cls, spatialimage: SpatialImage) -> Self:
      return cls(
          coordinates=GridIndices(spatialimage.shape[:3]),
          affine=spatialimage.affine,
      )
  
imports: from __future__ import annotations
  import math
  import typing
  from dataclasses import dataclass, replace
  import numpy
  from nibabel.casting import able_int_type
  from nibabel.fileslice import strided_scalar
  from nibabel.spatialimages import SpatialImage
label_desc: Use image node_id 1 for calling the Grid obj's underlying member method code with example usage: obj.from_image(cls, spatialimage) and returns: cls