parameters: (x, transform_matrix, fill_mode='nearest', cval=0.)
return_statement: return x
docstring: Apply transform on nd.array
docstring_summary: Apply transform on nd.array
docstring_tokens: Apply transform on nd . array
function: def apply_transform(x, transform_matrix, fill_mode='nearest', cval=0.):
      """Apply transform on nd.array"""
      x = np.rollaxis(x, 0, 0)
      final_affine_matrix = transform_matrix[:2, :2]
      final_offset = transform_matrix[:2, 2]
      channel_images = [ndi.interpolation.affine_transform(
          x_channel,
          final_affine_matrix,
          final_offset,
          order=0,
          mode=fill_mode,
          cval=cval) for x_channel in x]
      x = np.stack(channel_images, axis=0)
      x = np.rollaxis(x, 0, 0 + 1)
      return x
function_tokens: def apply_transform ( x , transform_matrix , fill_mode = 'nearest' , cval = 0. ) : x = np . rollaxis ( x , 0 , 0 ) final_affine_matrix = transform_matrix [ : 2 , : 2 ] final_offset = transform_matrix [ : 2 , 2 ] channel_images = [ ndi . interpolation . affine_transform ( x_channel , final_affine_matrix , final_offset , order = 0 , mode = fill_mode , cval = cval ) for x_channel in x ] x = np . stack ( channel_images , axis = 0 ) x = np . rollaxis ( x , 0 , 0 + 1 ) return x