Home > Source > Bin > build_1d_bump_model_1.m

build_1d_bump_model_1

PURPOSE ^

BUILD_1D_BUMP_MODEL: Builds a 1-D model for some bump data

SYNOPSIS ^

function [status] = build_1d_bump_model(spline_type, placement_type, objective_function,apply_intensity_offset, save_movie, do_plot, movie_type,progress_bar, user_menu, produce_statistics,see_model_before_each_iteration, show_pixels, show_score_vs_iteration,show_model_after_optimisation, show_specificity_statistics, verbose_score,movie_name, window, average_smooth_enabled, gaussian_smooth_enabled,bump_width, bump_width_variation, bump_height, bump_height_variation,bump_position_freedom, initial_diminish_factor, smoothness_factor,plot_before_and_after, number_of_bins, model_evaluation_method,show_score_using_model, handle, n_modes, shape_weight,weighting_normalisation_method, variation_kept,run_all_objective_functions, kernel, save_data, load_data,save_bumps, draw_warp_curve, overlap_scores, show_target,format, filter, filter_level, model_score_type, gen_iters,spec_iters, draw_curve_by_images);

DESCRIPTION ^

 BUILD_1D_BUMP_MODEL: Builds a 1-D model for some bump data
                      and returns some related statistics.

 Code originally written by Katherine Smith, 2003

    GENERAL

      Omitted.

    INPUT/S

      -- No arguments will lead to defaults

      -spline_type: 
           The type of spline to be used. 'single_point' or
           'multi_point' at present.

      -placement_type:
           Placement type for 'multi_point':
                    'grid' or 'edges' or 'random'
           placement type for 'single_point':
                    'overlap_grid' or 'edges_and_scale'
                    or 'random_and_scale'.

      -objective_function:
           'msd_opt_together' or 'model_opt_separare' or
           'msd_opt_separate' or 'model_opt_together'.

      .....
           
    OUTPUT/S

      -status:
           The status of the operation of this routine (to be returned at
           the end

      -Figures produced and results displayed are main
       data to be utilised.

    PENDING WORK

      -

    KNOWN BUG/S

      -

    COMMENT/S

      -Different video outputs are generated but controlling which
       one is chosen is not trivial. It currently just does the
       job of experimentation and showing results as pixels
       or bumps.

    RELATED FUNCTION/S

      See other functions in same directory, filenames
      beginning with "build" in particular. There seem to be much
      overlap due to cut-and-paste.

    ABOUT

      -Created:     December 29rd, 2003
      -Last update: February 18th, 2004
      -Revision:    0.6.6
      -Author:      R. S. Schestowitz, University of Manchester
 ==============================================================

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [status] = build_1d_bump_model( ...
0002     spline_type, placement_type, objective_function, ...
0003     apply_intensity_offset, save_movie, do_plot, movie_type, ...
0004     progress_bar, user_menu, produce_statistics, ...
0005     see_model_before_each_iteration, show_pixels, show_score_vs_iteration, ...
0006     show_model_after_optimisation, show_specificity_statistics, verbose_score, ...
0007     movie_name, window, average_smooth_enabled, gaussian_smooth_enabled, ...
0008     bump_width, bump_width_variation, bump_height, bump_height_variation, ...
0009     bump_position_freedom, initial_diminish_factor, smoothness_factor, ...
0010     plot_before_and_after, number_of_bins, model_evaluation_method, ...
0011     show_score_using_model, handle, n_modes, shape_weight, ...
0012     weighting_normalisation_method, variation_kept, ...
0013     run_all_objective_functions, kernel, save_data, load_data, ...
0014     save_bumps, draw_warp_curve, overlap_scores, show_target, ...
0015     format, filter, filter_level, model_score_type, gen_iters, ...
0016     spec_iters, draw_curve_by_images);
0017 
0018 % BUILD_1D_BUMP_MODEL: Builds a 1-D model for some bump data
0019 %                      and returns some related statistics.
0020 %
0021 % Code originally written by Katherine Smith, 2003
0022 %
0023 %    GENERAL
0024 %
0025 %      Omitted.
0026 %
0027 %    INPUT/S
0028 %
0029 %      -- No arguments will lead to defaults
0030 %
0031 %      -spline_type:
0032 %           The type of spline to be used. 'single_point' or
0033 %           'multi_point' at present.
0034 %
0035 %      -placement_type:
0036 %           Placement type for 'multi_point':
0037 %                    'grid' or 'edges' or 'random'
0038 %           placement type for 'single_point':
0039 %                    'overlap_grid' or 'edges_and_scale'
0040 %                    or 'random_and_scale'.
0041 %
0042 %      -objective_function:
0043 %           'msd_opt_together' or 'model_opt_separare' or
0044 %           'msd_opt_separate' or 'model_opt_together'.
0045 %
0046 %      .....
0047 %
0048 %    OUTPUT/S
0049 %
0050 %      -status:
0051 %           The status of the operation of this routine (to be returned at
0052 %           the end
0053 %
0054 %      -Figures produced and results displayed are main
0055 %       data to be utilised.
0056 %
0057 %    PENDING WORK
0058 %
0059 %      -
0060 %
0061 %    KNOWN BUG/S
0062 %
0063 %      -
0064 %
0065 %    COMMENT/S
0066 %
0067 %      -Different video outputs are generated but controlling which
0068 %       one is chosen is not trivial. It currently just does the
0069 %       job of experimentation and showing results as pixels
0070 %       or bumps.
0071 %
0072 %    RELATED FUNCTION/S
0073 %
0074 %      See other functions in same directory, filenames
0075 %      beginning with "build" in particular. There seem to be much
0076 %      overlap due to cut-and-paste.
0077 %
0078 %    ABOUT
0079 %
0080 %      -Created:     December 29rd, 2003
0081 %      -Last update: February 18th, 2004
0082 %      -Revision:    0.6.6
0083 %      -Author:      R. S. Schestowitz, University of Manchester
0084 % ==============================================================
0085       
0086 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0087 %% variables (parameters) initialisation           %%
0088   
0089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0090 %% Input Defaults              %%
0091 
0092 if (nargin == 0),
0093     disp(' ');
0094     disp('Argument(s) ommited. Using defaults instead.');
0095     disp(' ');
0096     spline_type = 'multi_point';
0097          % SMITH: spline type 'single_point' or 'multi_point'
0098          % SMITH: placement type for multipoint: 'grid' or 'edges' or 'random'
0099          % SMITH: placement type for singlepoint: 'overlap_grid' or 'edges_and_scal or 'random_and_scale'
0100     placement_type = 'random';
0101          % controls knotpoint selection on the grid
0102     objective_function = 'model_opt_together';
0103          % choice of objective function
0104     apply_intensity_offset = 1;
0105          % 0: Offset should not be applied to data
0106          % 1: Offset enabled
0107     
0108     save_movie = 0;
0109          % should movie be saved (boolean)
0110          % 0: No
0111          % 1: Yes
0112     do_plot = 0;
0113          % should bumps be plotted as it changes? (Boolean)
0114          % (Old comment: this also enables frames being captured which slows down the
0115          % process. Capturing of frames and plotting can potentially be separated to make
0116          % this routine more useful).
0117     movie_type = 1;
0118          % type of movie to save
0119          % 0: bumps as pixels. do_plot may be 0 for a pixel clip to be recorded.
0120          % 1: bump plots. Remember to set do_plot to 1.
0121     movie_name = 'undefined';
0122     format = 'png';
0123     gen_iters = 25;
0124        % generalisability iterations = 25;
0125        % specificity iterations
0126     spec_iters = 25;
0127        % specificity iterations
0128     progress_bar = 1;
0129          % display progress bar or text instead
0130          % 0: Hierarchical Text
0131          % 1: Progress bar
0132          % 2: Quiet
0133          % 3: Console progress bar
0134     model_score_tyype = 'Deafault';
0135     user_menu = 0;
0136     number_of_bins=50;
0137          % 0: parameters need to be set in file
0138          % 1: menu input
0139     produce_statistics = 0;
0140          % should statistics be displayed at the end (boolean)
0141     see_model_before_each_iteration = 0;
0142          % should a combined model be produced and displayed before each
0143          % iteration, this should be set to 1
0144     show_pixels = 0;
0145          % show pixels representation (boolean). Mandatory for pixel movie
0146          % capture
0147     show_score_vs_iteration = 0;
0148     show_model_after_optimisation = 0;
0149     show_specificity_statistics = 0;
0150          % more booleans which are self-explanatory
0151     verbose_score = 0;
0152          % boolean: display score or not after optimisation
0153     average_smooth_enabled = 0;
0154     gaussian_smooth_enabled = 0;
0155     window = 1;
0156     
0157     plot_before_and_after = 0;
0158          % will only ever be used if the two above are set
0159     bump_width = 0.2;
0160     bump_width_variation = 0.5;
0161     bump_height = 0.2;
0162     bump_height_variation = 0.3;
0163     bump_position_freedom = 0.9;
0164     initial_diminish_factor = 2;
0165     smoothness_factor = 17;
0166          % set the bump parameters
0167 
0168     model_evaluation_method = 1;
0169                       % 1: Determinant
0170                       % 0: MDL
0171                       % 2: Sum of log of Eigenvalues
0172     show_score_using_model = 0;
0173     handle = 'Default';
0174       % give figures a fefault name
0175     n_modes = 20;
0176     variation_kept = 0.99;
0177       % keep 99%
0178       % number of modes in the model to be accounted for
0179     shape_weight = 0.06;  
0180     weighting_normalisation_method = 'edge';
0181     run_all_objective_functions = 0;
0182        % do not try running all the objective functions
0183     called_from_gui = 0;
0184        % indicate that GUI was not used in this case
0185     kernel = 'Exponential';
0186     save_data = 0;
0187     load_data = 0;
0188     save_bumps = 0;
0189     draw_warp_curve = 0;
0190     draw_curve_by_images = 0;
0191     overlap_scores = 0;
0192     show_target = 0;
0193         % do not show perfectly aligned images estimate
0194 else
0195     called_from_gui = 1;
0196         % indicate that default values were not set and that the function
0197         % was called from REGISTER
0198 end
0199 
0200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0201 %% Optimisation Controllers    %%
0202 
0203 % The values below will be defaults if user menu does not appear
0204 
0205 n_images = 2;
0206          % how many images to try to register in each set
0207 n_iterations = 2;
0208          % how many iterations of the optimisation to run, default was 50.
0209 n_sets = 1;
0210          % how many sets of images to register (in order to get better statistics)
0211 image_width = 50;
0212          % the number of pixels or the lenght of the data vector
0213 n_points = 5;
0214          % an argument that is passed to the model optimisation function.
0215          % meaning still unknown.
0216 
0217        
0218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0219 %% Input / Output              %%
0220 
0221 warning off;
0222          % keeps st_pca.m quiet
0223 error_found = 0;
0224          % status flag
0225 status = ['                      '];
0226          % set intiaial status packet
0227 if (run_all_objective_functions == 1),
0228     colour = 'r';
0229         % set initial colour for overlaid plots
0230     style = ':';
0231         % similarly to style of line
0232     progress_bar = 2;
0233 end
0234      % the progress indicators will not work for this routine so disable
0235      % them
0236 
0237 
0238 verbose = 'off';
0239          % be verbose or not during general-purpose optimisation
0240 if strcmp(movie_name, 'undefined'),
0241     movie_name = ['movie_', spline_type, '_', placement_type, '_', objective_function,'_width', num2str(image_width), '_images', num2str(n_images), '_iterations', num2str(n_iterations), '.avi'];
0242          % name for the AVI to be saved
0243          % The name will attempt to encompass all construction details
0244 end
0245          
0246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0247 %% Others (most are obsolete)  %%
0248                        
0249 % white_ctr = 0;
0250          % white counter? Was used for simple bumps in code that is now
0251          % commented out
0252 % ref_shift = 0.2;
0253        % shift in reference image??
0254 % max_shift = 0.2;
0255        % maximum allowed shift?
0256 % step = 0.1;
0257        % used in two lines below only
0258 % los = zeros(n_images,floor((max_shift-ref_shift)/step));
0259 % his = zeros(n_images,floor((max_shift-ref_shift)/step));
0260        % not understood yet
0261 % blurred = 0;
0262        % image blurring has been applied to images (boolean)
0263 % min_error = 0;
0264 % max_error = 1;
0265        % define error range??
0266 % error_step = 0.1;
0267 % n_error_steps = (max_error-min_error) / error_step;
0268 
0269 frame_counter = 0;
0270          % counter for video frames. Do not fiddle with this variable.
0271 
0272 if (progress_bar == 0),
0273  progress_indicator_type = 'Hierarchical Text';
0274 elseif (progress_bar == 1),
0275  progress_indicator_type = 'Progress Bar';
0276 elseif (progress_bar == 2),
0277  progress_indicator_type = 'Quiet'; 
0278 elseif (progress_bar == 3),
0279  progress_indicator_type = 'Console Progress Bar';
0280 else
0281  error('Callback value for progress indicator is not recognised');
0282 end
0283 
0284          % do type conversions for input to make code below readable
0285          
0286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0287 %% Begin Set initialisation    %%
0288 
0289 if (user_menu == 1),
0290   [n_sets, n_iterations, n_images, image_width] = get_parameters_from_user('Default');
0291 end 
0292 
0293 tic;
0294        % start counting time
0295 for this_set = 1:n_sets
0296        % for all sets
0297        % Old: user gets status about set number. Multiple sets generate reliable
0298        %      statistics
0299   tic;
0300        % This is called again (stack of time counters????? Doesn't seem so)
0301        % This will need to be changed (one tic omitted) for the statistics
0302        % to work properly. Only one stopwatch can work at a time.
0303        % Smith: for each set of n_sets images, build a model
0304        % calculate obj fn values from these models, plot the mean with error
0305        % bars given by 1 stddev away
0306   if (strcmp(progress_indicator_type,'Hierarchical Text')),      
0307     disp(['calculating set ', num2str(this_set), ' out of ', num2str(n_sets), ' sets...']);
0308   elseif (strcmp(progress_indicator_type,'Progress Bar')),
0309       gui_active(1);     % will add an abort button
0310       if (strcmp(getenv('OS'), 'Linux')),
0311          h = progressbar( [], 0, 'Preparing for registration', [['Registration Progress on '], [get_host]]);
0312       else
0313          h = progressbar( [], 0, 'Preparing for registration', 'Registration Progress');
0314       end
0315   end    
0316 
0317   
0318   if (strcmp(progress_indicator_type,'Progress Bar')),
0319            h = progressbar( h, 0, 'Fetching Data');
0320   end
0321           
0322 
0323   if (load_data == 0),
0324       [imagelist, images, points] = make_1d_bump(n_images, image_width...
0325           , bump_width, bump_width_variation, bump_height, bump_height_variation...
0326           , bump_position_freedom, initial_diminish_factor, smoothness_factor...
0327           , save_bumps, format);
0328        % create a set of images
0329       if (called_from_gui == 1 & save_bumps == 1),
0330         status = [[status];['(**) Images saved     '];['                      ']];
0331       end
0332   else
0333       output = open([[handle],['.mat']]);
0334       points = output.points;
0335       images = output.images;
0336                   % copy the data structures from the file
0337   end     
0338   
0339   if (save_data == 1)
0340       save([[handle],['.mat']], 'images','points');
0341       if (called_from_gui == 1),
0342         status = [[status];['(**) Data saved       '];['                      ']];
0343       end
0344   end
0345   
0346   figure;
0347   [X,Y] = meshgrid(n_images, -image_width/2:1:image_width/2-1);
0348   Z = zeros(n_images, image_width);
0349 size(X)
0350 size(Y)
0351 size(Z)
0352 size(images)
0353   for i = 1:n_images,
0354     Z(:,i) = images(:,i);
0355   end  
0356   mesh(X,Y,Z);
0357   axis([-30 30 -30 30 -1 1]);
0358   % plot3(1:2,1:2,images(1,:))
0359   
0360   
0361   if (strcmp(progress_indicator_type,'Progress Bar')),
0362            h = progressbar( h, 0, 'Pre-processing Data');
0363   end
0364   
0365   if (average_smooth_enabled),
0366       images = average_smooth(images, window);
0367   end  
0368   
0369   if (gaussian_smooth_enabled),
0370          images = gaussian_smooth(images, window); 
0371   end
0372        % smooth all images - used to be disabled and set <blurred> to 1
0373        
0374   if (apply_intensity_offset),
0375       vertical_pane_location = 3;
0376                        % Need is for only 3 columns in plot
0377   else
0378       vertical_pane_location = 2;
0379                        % Need is for only 2 columns in plot
0380   end
0381 
0382   points = -1 + 2 * (points - 1) / (image_width - 1);
0383        % Smith: normalise points from -1 to 1
0384        %% keep = 0.999999; NOTE (RSS Feb. 2004): became obsolete
0385        % Is this precision required? Perhaps in optimisation.
0386   ref_points_vec = points(:,1);
0387   ref_image_vec = images(:,1);
0388        % set first image generated to be reference
0389   % ref_hi = his(1);
0390   % ref_lo = los(1);
0391        % and get its upper and lower boundaries. his and lois were
0392        % generated and returned as output for simple bumps
0393 
0394        
0395   if (draw_warp_curve == 1),
0396        overlap_curve_fig = figure('Name','Overlapping Warp Curves');
0397   end
0398   
0399   if (show_pixels == 1),
0400     pixels_figure = figure('Name','Pixel Representation');
0401   end
0402   
0403   
0404   
0405   if (draw_curve_by_images == 1),
0406     curve_subplot_fig = figure('Name',[['Warp Curves for all data - objective function: '],[objective_function]]);
0407     curves = figure(curve_subplot_fig);
0408     for i=1:n_images,
0409        subplot(n_images, n_iterations + 1, i * (n_iterations + 1) - n_iterations);
0410        hold on;
0411        axis off;
0412        plot(points(:,i));
0413        axis([-1 image_width -1 1]);
0414        hold off;
0415     end
0416   end
0417   
0418 
0419 %%             END OF INITIALISATION               %%
0420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0421 
0422 
0423 
0424 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0425 %% Warping images, then modelling warped images    %%
0426 %% attempt to register images by warping.          %%
0427   if (plot_before_and_after),
0428     for i=1:n_images,
0429        images_before_offset(:,i) = images(:,i);
0430     end
0431   end
0432   if (do_plot),
0433     subplot_fig = figure('Name',[[handle],[': Left: Original images ; Right: Images subjected to warping']]);
0434     H=figure(subplot_fig);
0435     for i=1:n_images,
0436        subplot(n_images, vertical_pane_location, (vertical_pane_location * i) - vertical_pane_location + 1);
0437        hold on;
0438        plot(images(:,i));
0439        % title(['Unwarped image #',num2str(i)]);
0440        axis([0 image_width 0 1]);
0441        grid on;
0442        hold off;
0443     end
0444   else
0445     subplot_fig = 0;
0446       % pass a void figure to the optimisation functions
0447   end
0448   
0449   if (apply_intensity_offset),
0450       for index = 1:n_images,
0451          peak (index) = max(images(:,index));
0452       end
0453       peak_reference = max (peak);  
0454       for index = 1:n_images,
0455         peak_difference = peak_reference - max(images(:,index));
0456         images(:,index) = images(:,index) + peak_difference;
0457         if (do_plot),
0458             subplot(n_images, vertical_pane_location, (vertical_pane_location * index) - vertical_pane_location + 2);
0459             hold on;
0460             plot(images(:,index));
0461             % title(['Unwarped image #',num2str(i)]);
0462             axis([0 image_width 0 1]);
0463             grid on;
0464             hold off;
0465         end
0466       end        
0467   end 
0468 %% NOTE: Change here in traversal above (RSS, December 2003)
0469   
0470     still_to_go = 1;
0471           % condition for while loop. This will enable the program to
0472           % continually try all objective functions.
0473     
0474     
0475     while (still_to_go == 1),
0476     
0477     if (run_all_objective_functions == 0)
0478         still_to_go = 0;
0479            % break out of while loop after just one iteration
0480     else
0481            % try all objective functions sequentially
0482        if strcmp(objective_function, 'all'),
0483            % meaning that it is in its first iteration
0484            objective_function = 'model_opt_together';
0485        elseif strcmp(objective_function, 'model_opt_together'),
0486            objective_function = 'model_opt_separate';    
0487        elseif strcmp(objective_function, 'model_opt_separate'),
0488            objective_function = 'msd_opt_together';
0489        elseif strcmp(objective_function, 'msd_opt_together'),
0490            objective_function = 'msd_opt_separate';
0491        elseif strcmp(objective_function, 'msd_opt_separate'),
0492            objective_function = 'mi_opt_together';
0493        elseif strcmp(objective_function, 'mi_opt_together'),
0494            objective_function = 'mi_opt_separate';
0495        elseif strcmp(objective_function, 'mi_opt_separate'),
0496            objective_function = 'nmi_opt_together';
0497        elseif strcmp(objective_function, 'nmi_opt_together'),
0498            objective_function = 'nmi_opt_separate';
0499        elseif strcmp(objective_function, 'nmi_opt_separate'),           
0500            objective_function = 'void';   
0501            still_to_go = 0;
0502               % signal to break out of the while loop because the test of
0503               % all objective functions is finished.
0504        else
0505            error('Problem with <Run All Objective Functions> option');
0506        end
0507     end   
0508     
0509       warped_images = images;
0510       warped_points = points;
0511           % set this initial state to plot the examples before change
0512     
0513     
0514     % correctly_warped_points = points;
0515     % correctly_warped_images = images;
0516     % for i=1:n_images
0517     % % now bung in the right deformations to get them back
0518     % correctly_warped_points(:,i) = linear_warp(ref_points_vec, los(i,white_ctr), his(i,white_ctr), ref_lo, ref_hi);
0519     % correctly_warped_points_vec = correctly_warped_points(:,i);
0520     % image_vec = images(:,i);
0521     % % resample at the warped points - point on reg. grid has value of point at same index in warpy grid
0522     % % need to interpolate
0523     % correctly_warped_images(:,i) = interp1(ref_points_vec, image_vec, correctly_warped_points_vec);
0524     % correct_model = build_model(correctly_warped_images,correctly_warped_points,1,'','edge',0);
0525     % converging_score(i) = measure_model(correct_model.variances,50);
0526     % end
0527     % figure,plot(log(converging_score)),title('Log of score as model converges');
0528     
0529       if ((strcmp(progress_indicator_type,'Console Progress Bar')) | (strcmp(progress_indicator_type,'Progress Bar')))
0530          progress_bar_position = 0;
0531          time_for_this_iteration = 10;
0532          total_images = n_images * n_iterations;
0533          step_size = 50 / total_images;
0534       end   
0535         % initialise progress bar
0536       for n = 1:n_iterations,
0537         if (strcmp(progress_indicator_type,'Hierarchical Text'))  
0538            % iterations aim to get good statistical results by averaging
0539           disp(['    +-Running iteration number ',num2str(n), ' out of ',num2str(n_iterations), ' iterations...']);
0540         end     
0541         
0542            % Smith: correct registration
0543            % attempt to register
0544            
0545         if (see_model_before_each_iteration),  
0546           w_c_model = build_model(warped_images, warped_points, variation_kept,'Optimised warp', weighting_normalisation_method);
0547                   % create an appearance model...
0548           show_combined_model(w_c_model,ref_points_vec, 2, 2, [[handle],[': Combined model before iteration number ', num2str(n)]]);
0549                   % and show the model before each iteration
0550         end          
0551         for i = 1:n_images,
0552            % start iteration time counter
0553          if (strcmp(progress_indicator_type,'Hierarchical Text')),
0554            disp(['        +-Warping image ',num2str(i),' out of ',num2str(n_images), ' images in total...']);
0555          end
0556          
0557          this_step = ((n-1) * n_images) + i;
0558                     
0559          if (strcmp(progress_indicator_type,'Progress Bar')),
0560            tic;
0561            progress_bar_position = progress_bar_position + step_size;
0562            steps_remaining = (n_images * n_iterations) - this_step;
0563            minutes = floor(time_for_this_iteration * steps_remaining / 60);
0564            seconds = rem(floor(time_for_this_iteration *  steps_remaining), 60);
0565            max_count   = 50;
0566                % The console-based GUI is 50 units wide
0567            if (seconds > 9),
0568                h = progressbar( h, step_size/50,['            Estimated remaining time: ', num2str(minutes), ':', num2str(seconds)]);
0569            else
0570                h = progressbar( h, step_size/50,['            Estimated remaining time: ', num2str(minutes), ':0', num2str(seconds)]);
0571            end    
0572            if ~gui_active,
0573                     error_found = 1;
0574                     break; % if aborted was pressed
0575            end
0576               % use the third-part GUI-like progress bar (added February
0577               % 2004)
0578          end
0579          if (strcmp(progress_indicator_type,'Console Progress Bar')),
0580                                % if console progress bar
0581            tic;
0582            progress_bar_position = progress_bar_position + step_size;
0583            clc;
0584            disp(['|=================================================|']);
0585            progress_string='|';       
0586            for counter = 1:floor(progress_bar_position),
0587                progress_string = [progress_string, '#'];
0588            end
0589            disp(progress_string);
0590            disp(['|================= ',num2str(floor(progress_bar_position * 2)),'% completed =================|']);
0591                           % display progress per cent
0592            steps_remaining = (n_images * n_iterations) - this_step;
0593            minutes = floor(time_for_this_iteration * steps_remaining / 60);
0594            seconds = rem(floor(time_for_this_iteration *  steps_remaining), 60);
0595            disp(' ');
0596            if (seconds > 9),
0597              disp(['            Estimated remaining time: ', num2str(minutes), ':', num2str(seconds)]);
0598                           % show time indicators
0599            else
0600              disp(['            Estimated remaining time: ', num2str(minutes), ':0', num2str(seconds)]);
0601            end
0602          end
0603          image_vec = warped_images(:,i);
0604          points_vec = warped_points(:,i);     
0605          
0606          if (show_pixels == 1),   
0607              appended_vector=[];
0608              for current_image=1:n_images,
0609                appended_vector=[[appended_vector],[warped_images(:,current_image),[warped_images(:,current_image)]],[warped_images(:,current_image)]];
0610                    % append bump data 3 times for width which is visible
0611              end
0612            
0613                  %% appended_vector=appended_vector * 256
0614                  %% use if scale of 0..255 used
0615     
0616              G = figure(pixels_figure);
0617              hold on;
0618               % title('Bumps as pixels');
0619              imshow(appended_vector',[0,1]);
0620                        % show as an image
0621              if (movie_type == 0 & save_movie == 1),
0622                   frame_counter = frame_counter + 1;
0623                   M(frame_counter) = getframe(G);
0624              end
0625              hold off;
0626          end
0627                   
0628          if (movie_type == 1 & save_movie == 1 & do_plot == 1),
0629                    frame_counter = frame_counter + 1;
0630                    M(frame_counter) = getframe(H);
0631          end
0632                    % capture pixels frame
0633          if    (strcmp(objective_function,'model_opt_together')),
0634                  [param_list, warped_point, warped_image, score] = optimise_all_warps_model([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type,placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept);
0635          elseif(strcmp(objective_function,'void')),        
0636                  break;
0637          elseif(strcmp(objective_function,'model_opt_separate')),
0638                  [param_list, warped_point, warped_image, score] = optimise_warps_model([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type, placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept);
0639          elseif(strcmp(objective_function,'msd_opt_together')),          
0640                  [param_list, warped_point, warped_image, score] = optimise_all_warps_msd(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score);
0641          elseif(strcmp(objective_function,'msd_opt_separate')),
0642                  [param_list, warped_point, warped_image, score] = optimise_warps_msd(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score);
0643          elseif(strcmp(objective_function,'mi_opt_together')),         
0644                  [param_list, warped_point, warped_image, score] = optimise_all_warps_mi(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, number_of_bins);
0645          elseif(strcmp(objective_function,'mi_opt_separate')),
0646                  [param_list, warped_point, warped_image, score] = optimise_warps_mi(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, number_of_bins);
0647          elseif(strcmp(objective_function,'nmi_opt_together')),         
0648                  [param_list, warped_point, warped_image, score] = optimise_all_warps_nmi(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, number_of_bins);
0649          elseif(strcmp(objective_function,'nmi_opt_separate')),
0650                  [param_list, warped_point, warped_image, score] = optimise_warps_nmi(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, number_of_bins);
0651          elseif(strcmp(objective_function,'mixed_msd_model')),
0652                     if (((n / n_iterations < 2 / 10) & (n / n_iterations >= 1 / 10)) |...
0653                         ((n / n_iterations < 4 / 10) & (n / n_iterations >= 3 / 10)) |...
0654                         ((n / n_iterations < 6 / 10) & (n / n_iterations >= 5 / 10)) |...
0655                         ((n / n_iterations < 8 / 10) & (n / n_iterations >= 7 / 10)) |...
0656                         ((n / n_iterations < 10 / 10) & (n / n_iterations >= 9 / 10))),
0657                       [param_list, warped_point, warped_image, score] = optimise_all_warps_msd(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score);
0658                     else
0659                       [param_list, warped_point, warped_image, score] = optimise_all_warps_model([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type,placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept);
0660                     end                    
0661          elseif(strcmp(objective_function,'model_post_msd')),
0662                     if (n / n_iterations < 1 / 2),
0663                         % for the first half
0664                       [param_list, warped_point, warped_image, score] = optimise_all_warps_msd(ref_image_vec, ref_points_vec, image_vec, points_vec, spline_type, placement_type, n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score);
0665                     else
0666                         % and for the second half
0667                       [param_list, warped_point, warped_image, score] = optimise_all_warps_model([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type,placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept);
0668                     end
0669          elseif(strcmp(objective_function,'tfc_eccv')), 
0670                  % msgbox('TFC ECCV 2004: Under Construction.');
0671                  pdf_evalution_method = 'Default';
0672                  [param_list, warped_point, warped_image, score] = optimise_groupwise([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type,placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept, pdf_evalution_method, kernel);         
0673          elseif(strcmp(objective_function,'wavelet_complexity')),  
0674                  % msgbox('Wavelets: Under Construction.');
0675                  wavelet_evalution_method = 'Default';
0676                  [param_list, warped_point, warped_image, score] = optimise_wavelet([warped_images(:,1:i-1),warped_images(:,i+1:n_images)], [warped_points(:,1:i-1),warped_points(:,i+1:n_images)], image_vec, points_vec,spline_type,placement_type,n_points, verbose, do_plot, subplot_fig, i * vertical_pane_location, vertical_pane_location, image_width, n_images, verbose_score, model_evaluation_method, n_modes, weighting_normalisation_method, shape_weight, variation_kept, wavelet_evalution_method, filter, filter_level);         
0677          
0678          else
0679                  error(['Unknown objective function: ', objective_function]);
0680          end
0681          
0682          if (draw_warp_curve == 1),
0683            figure(overlap_curve_fig);
0684            hold on;
0685            plot(warped_points);   
0686            hold off;
0687          end  
0688          
0689          if (draw_curve_by_images == 1),
0690              figure(curves);
0691              subplot(n_images, n_iterations + 1, i * (n_iterations + 1) - (n_iterations - n));
0692              hold on;
0693              axis off;
0694              plot(warped_points(:,i));
0695              axis([-1 image_width -1 1]);
0696              hold off;
0697          end 
0698          
0699          warped_images(:,i) = warped_image;
0700          warped_points(:,i) = warped_point;
0701     
0702          % figure(subplot_fig),title(['Warped images, after image ',num2str(i),' iteration ',num2str(n)]);
0703          % dummy = waitforbuttonpress;
0704          
0705          if (show_score_using_model == 1),           
0706              % if evaluation is through model then always overwrite score
0707             c_model = build_model(warped_images, warped_points, variation_kept, '', weighting_normalisation_method, shape_weight);
0708                 % first build a model
0709             if (strcmp(model_score_type, 'Default')),
0710                 score = measure_model(c_model.variances, n_modes, model_evaluation_method, c_model);
0711             elseif (strcmp(model_score_type, 'Specificity')),  
0712                 score = find_specificity(c_model, images, spec_iters, ref_points_vec);
0713             elseif (strcmp(model_score_type, 'Generalisability')),  
0714                 score = find_generalisability(c_model, gen_iters);
0715             elseif (strcmp(model_score_type, 'Mean MSD')),
0716                 score = measure_model_msd(warped_images);
0717             elseif (strcmp(model_score_type, 'All')),
0718               % score = measure_model(c_model.variances, n_modes, model_evaluation_method, c_model);
0719                             % use deafult as score that is primary
0720                 all_scores = [[find_specificity(c_model, images, spec_iters, ref_points_vec)], [find_generalisability(c_model, gen_iters)], [measure_model_msd(warped_images)]];    
0721                            % get all scores above and store them in a
0722                            % matrix
0723             else
0724                error(['Wrong scoring method (', [model_score_type], ') passed. Internal error.']);
0725             end
0726             
0727          end    
0728     
0729     
0730          if(n == n_iterations),
0731             final_score(i, this_set) = score;
0732                 % give the final score for the set if end is reached
0733          end
0734          
0735          score_for_iteration(i,n) = score;
0736                % record the score for this iteration and this image to be later
0737                % plotted for analysis
0738          if (strcmp(model_score_type, 'All')),
0739              all_scores_for_iteration(i,n,1) = all_scores(1);
0740              all_scores_for_iteration(i,n,2) = all_scores(2);
0741              all_scores_for_iteration(i,n,3) = all_scores(3);
0742          end    
0743          if ((strcmp(progress_indicator_type,'Progress Bar')) | (strcmp(progress_indicator_type,'Console Progress Bar'))),
0744            times(this_step) = toc;
0745            time_for_this_iteration = mean (times);
0746          end
0747         end  % end:images
0748       end  % end:iterations
0749       if (strcmp(progress_indicator_type,'Progress Bar')),
0750                 h = progressbar( h, 0, 'Finalising');
0751       end
0752       if (show_score_vs_iteration),
0753                     
0754 %           figure('Name', [[handle],[': Score versus iterations for every image warping step - objective function: '],[objective_function]]);
0755 %                  % create a new figure to show graph of optimisation for
0756 %                  % all steps and all images individually
0757 %           hold on;
0758 %           title('Score versus iterations for every image warping step');
0759 %           xlabel('Iteration number');
0760 %           ylabel('Score');
0761 %           for i=1:n_images,
0762 %                 plot(score_for_iteration(i,:));
0763 %           end;
0764 %           hold off;
0765 %
0766 %           figure('Name', [[handle],[': Score versus iterations - objective function: '],[objective_function]]);
0767 %                  % create a new figure to show graph of optimisation
0768 %           hold on;
0769 %           title('Score versus iterations');
0770 %           xlabel('Iteration number');
0771 %           ylabel('Mean score');
0772 %           for i=1:n_iterations,
0773 %              mean_score(i) = mean(score_for_iteration(:,i));
0774 %           end
0775 %           plot(mean_score);
0776 %           hold off;
0777           
0778           if (overlap_scores == 0),
0779              figure('Name', [[handle],[': Score versus image warping step - objective function: '],[objective_function]]);
0780                  % create a new figure to show graph of optimisation
0781           else
0782               
0783              figure(101);
0784           end
0785           
0786           hold on;
0787           
0788           if (strcmp(model_score_type, 'All')),
0789             title('Proportional score versus image warping step');
0790             xlabel('Warping Step');
0791             ylabel('% Change');  
0792             position_counter = 0;  
0793             for i=1:n_iterations,
0794               for j=1:n_images,
0795                 position_counter = position_counter + 1;
0796                 all_warp_step_score_vector(position_counter,1) = all_scores_for_iteration(j,i,1);
0797                 all_warp_step_score_vector(position_counter,2) = all_scores_for_iteration(j,i,2);
0798                 all_warp_step_score_vector(position_counter,3) = all_scores_for_iteration(j,i,3);
0799               end
0800             end
0801             all_warp_step_percent_vector(1,1) = 0;
0802                                % no change
0803             all_warp_step_percent_vector(2,1) = 0;
0804             all_warp_step_percent_vector(3,1) = 0;
0805                 
0806             for i = 2:n_iterations * n_images,
0807                     all_warp_step_percent_vector(1,i) = (all_warp_step_score_vector(i,1) - all_warp_step_score_vector(i-1,1)) / (all_warp_step_score_vector(i-1,1) + 0.001) * 100;
0808                     all_warp_step_percent_vector(2,i) = (all_warp_step_score_vector(i,2) - all_warp_step_score_vector(i-1,2)) / (all_warp_step_score_vector(i-1,2) + 0.001) * 100;
0809                     all_warp_step_percent_vector(3,i) = (all_warp_step_score_vector(i,3) - all_warp_step_score_vector(i-1,3)) / (all_warp_step_score_vector(i-1,3) + 0.001) * 100;              
0810             end          
0811           else
0812               title('Score versus image warping step');
0813               xlabel('Warping Step');
0814               ylabel('Score');
0815               position_counter = 0;
0816               for i=1:n_iterations,
0817                   for j=1:n_images,
0818                     position_counter = position_counter + 1;
0819                     warp_step_score_vector(position_counter) = score_for_iteration(j,i);
0820                   end
0821               end
0822           end
0823           if (run_all_objective_functions == 1),
0824               if strcmp(colour,'r'),
0825                 colour = 'g';
0826               elseif strcmp(colour,'g')
0827                 colour = 'b';
0828               else
0829                 colour = 'r';
0830               end 
0831               
0832               if strcmp(style,':'),
0833                 style = '-';
0834               elseif strcmp(style,'-')
0835                 style = '--';
0836               elseif strcmp(style,'--')
0837                 style = '-.'; 
0838               else
0839                 style = ':';
0840               end 
0841               plot(warp_step_score_vector,[[colour],[style]]);
0842               legend('Sequential MSD','Joint MSD','Sequential Model-based','Joint Model-based','Squential MI',...
0843                      'Joint MI', 'Sequential NMI', 'Joint NMI','Void');
0844           else
0845                 % if a normal single plot will suffice
0846                 if (strcmp(model_score_type, 'All')),
0847                          plot (all_warp_step_percent_vector(1,:), 'r');
0848                          plot (all_warp_step_percent_vector(2,:), 'g');
0849                          plot (all_warp_step_percent_vector(3,:), 'b');
0850                          legend('Specificity', 'Generalisability', 'Mean MSD');
0851                 else 
0852                          plot (warp_step_score_vector); 
0853                 end
0854                 if (show_target == 1),
0855                     Epsilon = 0.0001;
0856                     plot (repmat([log(Epsilon.^n_modes)], 1,n_iterations * n_images),'--');
0857                     legend('Current Evaluation','Log eigenvalues of perfectly registered images');
0858                 end
0859           end   
0860           hold off;
0861       end
0862       
0863       w_c_model = build_model(warped_images, warped_points, variation_kept, 'Optimised warp', weighting_normalisation_method, shape_weight);      
0864          % Smith: build model from warped images
0865       w_intensity_total_vars = w_c_model.intensity_model.total_var;
0866       w_shape_total_vars = w_c_model.shape_model.total_var;
0867          % get these two values to be used later
0868       model_score(this_set) = measure_model(w_c_model.variances, n_modes, model_evaluation_method, w_c_model);
0869       msd_score(this_set) = measure_model_msd(warped_images);
0870       shape_modes(this_set) = w_c_model.n_shape_modes;
0871       intensity_modes(this_set) = size(w_c_model.intensity_model.pcs,2);
0872       shape_variance(this_set) = sum(w_c_model.shape_model.variances);
0873       intensity_variance(this_set) = sum(w_c_model.intensity_model.variances);
0874          % copy some values to be displayed for statistics
0875       
0876       if (show_model_after_optimisation),
0877           show_combined_model(w_c_model,ref_points_vec, 2, 2, [[handle],[': Final combined model built from optimised warps - objective function: '],[objective_function]]);
0878       end
0879       
0880       if (show_specificity_statistics),
0881         [w_c_model.mean_specificity, w_c_model.std_specificity] = find_specificity(w_c_model, images, spec_iters, ref_points_vec);
0882         disp(' ');
0883         disp([['Objective function: '], [objective_function]]);
0884         disp(['Mean of specificity:               ', num2str(w_c_model.mean_specificity)]);
0885         disp(['Standard deviation of specificity: ', num2str(w_c_model.std_specificity)]);
0886       end
0887      
0888     
0889     % fig_title = 'Automatically aligned: ';
0890     % show_shape_model(w_shape_model, ref_points_vec, ref_image_vec, 2, white_width)
0891     % show_intensity_model(w_intensity_model, 2, white_width, fig_title)
0892     % show_combined_model(w_c_model, ref_points_vec, 2, white_width, fig_title)
0893     
0894     
0895     
0896     
0897     %%             END OF MODEL-BUILDING                    %%
0898     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0899     
0900     
0901     
0902     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0903     %% Now provide some statistics on the                   %%
0904     %% simulation/experiment                                %%
0905     
0906       
0907       %% Warping images, then modelling warped images    %%
0908     %% attempt to register images by warping.          %%
0909     
0910       if (plot_before_and_after),
0911         subplot_fig = figure('Name', [[handle],[': Left: Before registration; Right: After Registration - Objective function: '], [objective_function]]);
0912         H=figure(subplot_fig);
0913         for i=1:n_images,
0914            subplot(n_images, vertical_pane_location, (vertical_pane_location * i) - vertical_pane_location + 1);
0915            hold on;
0916            plot(images_before_offset(:,i));
0917            % title(['Unwarped image #',num2str(i)]);
0918            axis([0 image_width 0 1]);
0919            grid on;
0920            hold off;
0921         end
0922         if (apply_intensity_offset),
0923           for index = 1:n_images,
0924              peak (index) = max(images(:,index));
0925           end
0926           peak_reference = max (peak);  
0927           for index = 1:n_images,
0928             peak_difference = peak_reference - max(images(:,index));
0929             images(:,index) = images(:,index) + peak_difference;
0930             subplot(n_images, vertical_pane_location, (vertical_pane_location * index) - vertical_pane_location + 2);
0931             hold on;
0932             plot(images(:,index));
0933             % title(['Unwarped image #',num2str(i)]);
0934             axis([0 image_width 0 1]);
0935             grid on;
0936             hold off;
0937           end        
0938         end    
0939     
0940           % pass a void figure to the optimisation functions
0941         for i=1:n_images,
0942            subplot(n_images, vertical_pane_location, i * vertical_pane_location);
0943            hold on;
0944            plot(warped_images(:,i));
0945            % title(['Unwarped image #',num2str(i)]);
0946            axis([0 image_width 0 1]);
0947            grid on;
0948            hold off;
0949         end   
0950       else
0951         subplot_fig = 0; 
0952       end
0953     
0954       
0955  end % while
0956  
0957  t = toc;
0958       
0959  if (strcmp(progress_indicator_type,'Hierarchical Text')),
0960          disp(['Time for set ',num2str(this_set),': ',num2str(t)]);
0961  end
0962  time(this_set) = t;
0963  
0964 end % end set
0965 
0966 if (strcmp(progress_indicator_type,'Progress Bar')),
0967    progressbar( h,-1 );
0968       % destroy progress bar
0969 end
0970 
0971 if (produce_statistics == 1),
0972     disp(' ');
0973     disp(['======================================================']); 
0974     disp(['================= SET STATISTICS =====================']);
0975     disp(['| Objective function:                       ', objective_function]);
0976     disp(['| Mean of match score:                      ', num2str(mean(final_score(:)))]);    
0977     disp(['| Standard deviation of match score:        ', num2str(std(final_score(:)))]);
0978     disp(['| Mean of model score:                      ', num2str(mean(model_score(:)))]);    
0979     disp(['| Standard deviation of model score:        ', num2str(std(model_score(:)))]);
0980     disp(['| Mean of msd score:                        ', num2str(mean(msd_score(:)))]);
0981     disp(['| Standard deviation of msd score:          ', num2str(std(msd_score(:)))]);
0982     disp(['| Mean of shape modes:                      ', num2str(mean(shape_modes(:)))]);
0983     disp(['| Standard deviation of shape modes:        ', num2str(std(shape_modes(:)))]);
0984     disp(['| Mean of intensity modes:                  ', num2str(mean(intensity_modes(:)))]);
0985     disp(['| Standard deviation of intensity modes:    ', num2str(std(intensity_modes(:)))]);
0986     disp(['| Mean of shape variance:                   ', num2str(mean(shape_variance(:)))]);
0987     disp(['| Standard deviation of shape variance:     ', num2str(std(shape_variance(:)))]);        
0988     disp(['| Mean of intensity variance:               ', num2str(mean(intensity_variance(:)))]);    
0989     disp(['| Standard deviation of intensity variance: ', num2str(std(intensity_variance(:)))]);    
0990     disp(['| Mean time:                                ', num2str(mean(time(:)))]);    
0991     disp(['| Standard deviation of time:               ', num2str(std(time(:)))]);    
0992     t = toc;
0993          % get time from the counter initiated by <tic>
0994     disp(['| Total time:                               ',num2str(t)]);
0995          % display total time
0996     disp(['======================================================']); 
0997 end
0998 
0999 
1000 if (save_movie == 1)
1001   movie(M);
1002   movie2avi(M,movie_name);
1003   disp(' ');
1004   disp([movie_name, ' saved']);
1005           % process the movie and save it
1006   if (called_from_gui == 1),
1007       status = [[status];['(**) Video saved      '];['                      ']];
1008   end
1009 end
1010       
1011 if (error_found == 0),
1012               % if the error flag is not set
1013     if (called_from_gui == 1),
1014       status = [[status];['Registration Completed'];
1015              ['                      '];       
1016              ['Status: OK            ']];
1017          % send message
1018     else
1019       status = 'Status: OK'; 
1020          %indicate that everything was okay
1021     end
1022 elseif (error_found == 1),
1023     if (called_from_gui == 1),
1024       status = [[status];['Registration Completed'];
1025              ['                      '];       
1026              ['Status: Error         '];
1027              ['                      '];
1028              ['Operation Aborted     ']];
1029          % send message about error
1030     else
1031       status = 'Status: Operation Aborted'; 
1032          % indicate that something had gone wrong
1033     end    
1034 else
1035     if (called_from_gui == 1),
1036       status = [[status];['Registration Completed'];
1037              ['                      '];       
1038              ['Status: Error         '];
1039              ['                      '];
1040              ['Exit code unknown     ']];
1041          % send message about error
1042     else
1043       status = 'Status: Error'; 
1044          %indicate that something had gone wrong
1045     end
1046 end    
1047 
1048 %% END OF STATISTICS                                  %%
1049 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Generated on Fri 14-May-2004 10:05:30 by m2html © 2003