function score = eval_msd_multi_warp(knot_displacements, init_knots, unwarped_image, unwarped_points, ref_image, ref_points, n_modes, warp_params)
% EVAL_MSD_MULTI_WARP: Applies a multi warp and evaluates the
%                        warped image against the reference image.
%
% Code written by Katherine Smith, 2003
%
%    GENERAL
%
%      score = eval_msd_multi_warp(knot_displacements, init_knots,
%              unwarped_image, unwarped_points, ref_image, ref_points,
%              n_modes, warp_params)
%
%    INPUT/S
%
%      -knot_displacements:
%            Some warp specific parameter.
%
%      -init_knots:
%            Some warp specific parameter.
%
%      -unwarped_image:
%            Images to be warped.
%
%      -unwarped_points:
%            Points to be warped (points define the images in a way).
%
%      -ref_image:
%            The reference image.
%
%      -ref_points:
%            The reference image points.
%
%      -n_modes:
%           The number of modes
%
%      -warp_params:
%            The parameters of the warp
%           
%    OUTPUT/S
%
%      -score:
%           Mean-squared difference score.
%
%    PENDING WORK
%
%      -
%
%    KNOWN BUG/S
%
%      -None.
%
%    COMMENT/S
%
%      -
%
%    RELATED FUNCTION/S
%
%      MSD, EVAL_MSD, EVAL_MSD_CPS_WARP
%
%    ABOUT
%
%      -Created:     November 23rd, 2003
%      -Last update: Novermber 26th, 2003
%      -Revision:    0.0.2
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

% Smith:scale it all down to try and get it to move more
% RSS: (when warping?)... might need some alteration

% init_knots = init_knots*0.01;
% unwarped_points = unwarped_points*0.01;

warped_points = nrr_trans_1d(unwarped_points, init_knots, init_knots + knot_displacements, warp_params, []);
                % warp points using <multi warp>
warped_image = interp1(unwarped_points,unwarped_image,warped_points, 'linear',0);
                % interpolate image to get cleaner warped image
score = msd(ref_image, warped_image);
                % evaluate warped image according to reference image