function [score, warped_points] = eval_groupwise_single_point (params, warp_centre, r, unwarped_image_vec, unwarped_points_vec, image_set, points_set, n_modes, start_points_vec, model_evaluation_method, weighting_normalisation_method, shape_weight, variation_kept, pdf_evaluation_method, kernel)
% OPTIMISE_GROUPWISE_SINGLE_POINT: Uses PDF's to minimise group-wise complexity
%
%    GENERAL
%
%      function [score, warped_points] = 
%       eval_groupwise_single_point(params, warp_centre, r, unwarped_image_vec,
%       unwarped_points_vec, image_set, points_set, n_modes, start_points_vec,
%       model_evaluation_method, weighting_normalisation_method, shape_weight,
%       variation_kept)
%
% 
%    INPUT/S
%
%      -X:
%          X
%           
%    OUTPUT/S
%
%      -X:
%           X
%
%    PENDING WORK
%      
%      
%
%    KNOWN BUG/S
%
%      
%
%    COMMENT/S
%
%      
%
%    RELATED FUNCTION/S
%
%      
%
%    ABOUT
%      -Created:     February 9th, 2004
%      -Last update: February 2004
%      -Revision:    0.1.0
%      -Author:      R. S. Schestowitz, University of Manchester
% ==============================================================

%d = params(1);
start_points = unwarped_points_vec;
max_d = 0.67;

if (any((abs(params) > max_d)) | any(warp_centre-r <-1) | any(warp_centre+r > 1))
  score = realmax;
  warped_points = unwarped_points_vec;
else
  for i=1:size(params,2)
    warped_points = cps_warp_1d(start_points_vec,warp_centre(i),r(i),params(i));
    start_points = warped_points;
  end
  warped_image = interp1(unwarped_points_vec,unwarped_image_vec,warped_points, 'linear',0);
  image_set(:,size(image_set,2)+1) = warped_image;
  points_set(:,size(points_set,2)+1) = warped_points;

  
  % Note RSS: compute pdf of the intensities
  % evaluate using log(pdf) to return a score
  groupwise_pdf = compute_pdf(image_set, points_set, kernel, shape_weight);
  score = measure_pdf(groupwise_pdf, pdf_evaluation_method, warped_image);
  % Chnage above: addition of warped_points -- needs to be added to
  % multi_point too
end
