docstr: The `motion_estimate` method aligns scans with an online
  template so that spatial transforms map some average head
  space to the scanner space. To conventionally redefine the
  head space as being aligned with some reference scan, we need
  to right compose each head_average-to-scanner transform with
  the refscan's 'to head_average' transform.
docstr_tok: ["The","`","motion_estimate","`","method","aligns","scans","with","an","online","template","so","that","spatial","transforms","map","some","average","head","space","to","the","scanner","space",".","To","conventionally","redefine","the","head","space","as","being","aligned","with","some","reference","scan",",","we","need","to","right","compose","each","head_average-to-scanner","transform","with","the","refscan","'s","'to","head_average","'","transform","."]
code: def align_to_refscan(self):
      """
      The `motion_estimate` method aligns scans with an online
      template so that spatial transforms map some average head
      space to the scanner space. To conventionally redefine the
      head space as being aligned with some reference scan, we need
      to right compose each head_average-to-scanner transform with
      the refscan's 'to head_average' transform.
      """
      if self.refscan is None:
          return
      Tref_inv = self.transforms[self.refscan].inv()
      for t in range(self.nscans):
          self.transforms[t] = (self.transforms[t]).compose(Tref_inv)
  
imports: import os
  import warnings
  import numpy
  from nibabel import io_orientation
  from nibabel.affines import apply_affine
  from ...core.image.image_spaces import as_xyz_image, make_xyz_image, xyz_affine
  from ...io.nibcompat import get_header
  from ..slicetiming import timefuncs
  from ._registration import _cspline_sample3d, _cspline_sample4d, _cspline_transform
  from .affine import Affine, Rigid
  from .optimizer import configure_optimizer, use_derivatives
  from .type_check import check_type, check_type_and_shape
label_desc: Use image node_id 13 for calling the Realign4dAlgorithm obj's underlying member method code with example usage: obj.align_to_refscan() without return types