def tkr_vox2ras(img, zooms=None):
if zooms is not None:<EOL><INDENT>shape = img<EOL><DEDENT>else:<EOL><INDENT>try:              img = img.header<EOL>except Exception: pass<EOL>try:              (shape, zooms) = (img.get_data_shape(), img.get_zooms())<EOL>except Exception: raise ValueError('<STR_LIT>')<EOL><DEDENT>zooms = zooms[<NUM_LIT:0>:<NUM_LIT:3>]<EOL>shape = shape[<NUM_LIT:0>:<NUM_LIT:3>]<EOL>(dC, dR, dS) = zooms<EOL>(nC, nR, nS) = <NUM_LIT:0.5> * (np.asarray(shape) * zooms)<EOL>return np.asarray([[-dC,   <NUM_LIT:0>,   <NUM_LIT:0>,  nC],<EOL>[  <NUM_LIT:0>,   <NUM_LIT:0>,  dS, -nS],<EOL>[  <NUM_LIT:0>, -dR,   <NUM_LIT:0>,  nR],<EOL>[  <NUM_LIT:0>,   <NUM_LIT:0>,   <NUM_LIT:0>,   <NUM_LIT:1>]])<EOL>
tkr_vox2ras(img) yields the FreeSurfer tkr VOX2RAS matrix for the given nibabel image object
  img. The img must have a get_shape() method and header member with a get_zooms() method.
tkr_vox2ras(hdr) operates on a nibabel image header object.
tkr_vox2ras(shape, zooms) operates on the shape (e.g., for FreeSurfer subjects (256,256,256))
  and the zooms or voxel dimensions (e.g., for FreeSurfer subjects, (1.0, 1.0, 1.0)).