function score = eval_msd_cps_warp(params, start_points_vec, ref_image_vec)
% EVAL_MSD_CPS_WARP: get similarity score between CPS warped image and
%                    reference. (Evaluare the clamped-plate spline warp using
%                    mean-squared-difference)
%
% Code written by Katherine Smith, 2003
%
%    GENERAL
%
%      score = eval_msd_cps_warp(params, start_points_vec, ref_image_vec)
%
%    INPUT/S
%
%      -params:
%           The paramters of the warps.
%
%           params(1): warp centre
%           params(2): r
%           params(3): d
%
%      -start_points_vector:
%           Points to be warped?
%
%      -ref_image_vec:
%           The reference image vector.
%           (Reference image vector to be compared to warped image).
%           
%    OUTPUT/S
%
%      -score:
%           The similarity score w.r.t. the reference image. 
%           (Mean-squared difference score)
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -None.
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      LINEAR_WARP, POOR_LINEAR_WARP, CPS_WARP_1D, MSD, EVAL_MSD, 
%      EVAL_MODEL_MULTI_WARP
%
%    ABOUT
%
%      -Created:     November 23rd, 2003
%      -Last update: Novermber 27th, 2003
%      -Revision:    0.0.4
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

warped_points = cps_warp_1d(start_points_vec,params(1),params(2),params(3));
    % warp the points
warped_image = interp1(start_points_vec,ref_image_vec,warped_points); 
    % interploate image to apply warp
% warp image (rather use the warped points to interpolate the image)
score = msd(ref_image_vec, warped_image); 
    % evaluate mean squared difference between reference and warped image