classdef (Sealed) VfPlot
	% Plot 24-2 or 30-2 visual field greyscales (HFA style), and compute MD
	% values
    %
    %   Note that MD values are only intended as approximate, and will
    %   depend on the normative dataset used. The default is to use a set
    %   of 'hacked' values designed to approximate the outputs from the
    %   HFA.
    %
    % VfPlot Methods:
	%   * plot          - plot a single greyscale using the current axes
	%   * plot2        	- create a new figure and plot 2 panels: <Left Right>
	%   * plot3         - create a new figure and plot 3 panels: <Left IVF Right>
    %   * runExample    - minimal working examples of use
    %    
    % See Also:
    %   none
    %
    % Example:
    %   VfPlot.runExample(1) % extreme example (24-2)
    %   VfPlot.runExample(2) % same as 1, but inputs specified as one long vector (sampled left-to-right across each row)
    %   VfPlot.runExample(3) % more realistic example (24-2)
    %   VfPlot.runExample(4) % more realistic but both eyes identical/symmetric (24-2)
    %   VfPlot.runExample(5) % extreme example (30-2)
    %   VfPlot.runExample(6) % more realistic example (30-2)
    %   VfPlot.runExample(7) % symmetric example (30-2)
    %   VfPlot.runExample(8) % 24-2, no IVF plot
    %   VfPlot.runExample(9) % 24-2, just left eye plot, no text
    %    
    % Requires:
    %   <none>
    %
    % Author:
    %   Pete R Jones <petejonze@gmail.com>
    %
    % History:
    %   0.0.1 PJ 07/06/2018 : first_build\n
    %   0.0.2 PJ 12/06/2018 : fixed numerous errors and simplified code\n
    %   0.0.3 PJ 12/06/2018 : integrated tiles into code (now no need for external graphic dependencies)\n
    %   0.0.4 PJ 04/04/2019 : removed dependency on textLoc, added summary statistics (unchecked)\n
    %   0.0.5 PJ 11/04/2019 : added support for 30-2, and added correct MD computation formula and some example normative datasets\n
    %
    %
    % @todo finish adding comments, check IVF, check MD/PSD
    % @todo add support for entering arbitrary grid values in xyz format
    %
    % Copyright 2019 : P R Jones <petejonze@gmail.com>
    % *********************************************************************
    % 

    %% ====================================================================
    %  -----PROPERTIES-----
    %$ ====================================================================
      
    properties (Constant)
        NORM_TYPE = 'hacked' % 'BrentonPhelps1986' 'HeijlLindgrenOlsson1987', 'hacked'
        
        FONTSIZE = 26;
        
        TILES = cat(3, ...
            [ % db0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
            ],[ % db1
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
            ],[ % db2
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
             255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0    0    0    0    0  255  255  255  255    0    0    0    0    0    0    0    0    0    0    0    0
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255
               0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0    0  255  255  255  255
            ],[ % db3
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
            ],[ % db4
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0
               0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
               0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255
               0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
            ],[ % db5
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255    0    0    0    0
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
            ],[ % db6
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
            ],[ % db7
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255    0    0    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255    0    0    0    0  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
             255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255
            ]);
    end
    
    
        
    %% ====================================================================
    %  -----STATIC METHODS (private)-----
    %$ ====================================================================

    methods (Static, Access = private)

        function DLS = ensureMatrix(DLS, eye)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
            
            if ~isvector(DLS) % if already in matrix form do nothing
                if all(size(DLS) == [8 10])
                    return; % ok, 24-2 format
                elseif all(size(DLS) == [10 10])
                    return; % ok, 30-2 format
                else
                    error('matrix dimensions not recognised');
                end
            end
            
            % convert vector to matrix
            if length(DLS)==54 % 24-2
                switch lower(eye)
                    case 'left'
                        mask = [
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,   1
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,   1
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN]==1;
                    case 'right'
                        mask = [
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            1,    1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            1,    1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN]==1;
                    case 'ivf'
                        mask = [
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            1,    1,   1,   1,  1,  1,  1,  1,   1,   1
                            1,    1,   1,   1,  1,  1,  1,  1,   1,   1
                            NaN,  1,   1,   1,  1,  1,  1,  1,   1,  NaN
                            NaN, NaN,  1,   1,  1,  1,  1,  1,  NaN, NaN
                            NaN, NaN, NaN,  1,  1,  1,  1, NaN, NaN, NaN]==1;
                    otherwise
                        error('Eye paramater not recognised: %s', eye);
                end
            elseif length(DLS)==76 % 30-2
                mask = [
                       0   0   0   1   1   1   1   0   0   0
                       0   0   1   1   1   1   1   1   0   0
                       0   1   1   1   1   1   1   1   1   0
                       1   1   1   1   1   1   1   1   1   1
                       1   1   1   1   1   1   1   1   1   1
                       1   1   1   1   1   1   1   1   1   1
                       1   1   1   1   1   1   1   1   1   1
                       0   1   1   1   1   1   1   1   1   0
                       0   0   1   1   1   1   1   1   0   0
                       0   0   0   1   1   1   1   0   0   0
                   	]==1;
            else
                error('vector format not recognised');
            end
            
            % validate
            if numel(DLS) ~= sum(mask(:))
                error('mismatch? %');
            end
            
            % insert values
            tmp = nan(size(mask));
            tmp(mask') = DLS;
            DLS = tmp';
        end

        function [MD, PSD]  = computeSummaryStatistics(DLS, age, eye)
            % Compute summary statistics
            %
            % @param    DLS    XXXX
            % @param    age  	XXXX
            % @param    eye     XXXX
            %
            % @date     03/04/19
            % @author   PRJ
            %
            
            %@todo this code is all unchecked
            
            % convert 24-2 to 30-2
            if all(size(DLS) == [8 10])
                DLS = [nan(1,10); DLS; nan(1,10)];
            end
            

            % need to remove blind spot for these computations
            if(eye==1)
                DLS(4:5,3) = NaN; % remove blindspot
            elseif (eye==2)
                DLS(4:5,8) = NaN; % remove blindspot
            elseif(eye==3)
                DLS(4:5,1) = NaN; % remove nasal regions
                DLS(4:5,end) = NaN;
            end

            % get normative values
            switch lower(VfPlot.NORM_TYPE)
                case lower('HeijlLindgrenOlsson1987')
                    error('not yet implemented')
                case lower('BrentonPhelps1986')
                    DLS_norm_mu_rightEye = [
                        NaN  NaN  NaN  26.8 26.3 25.5 25.1 NaN  NaN  NaN    % +27
                        NaN  NaN  29.0 29.2 28.3 27.6 27.8 28.0 NaN  NaN    % +21
                        NaN  28.9 29.1 29.8 30.2 29.8 30.9 30.4 28.8 NaN    % +15
                        28.3 29.6 31.2 32.6 32.3 31.7 31.2 30.6 30.4 30.3   % +9
                        28.9 30.4 32.1 32.8 33.7 33.5 32.2 NaN  31.3 31.9   % +3
                        29.4 31.0 32.6 33.3 33.8 33.8 32.7 NaN  31.5 31.3   % -3
                        29.6 30.4 31.5 33.4 32.9 32.8 32.8 31.1 31.6 31.1   % -9
                        NaN  30.5 30.6 31.2 32.1 31.3 30.9 32.4 31.2 NaN    % -15
                        NaN  NaN  30.1 29.8 30.9 31.4 31.8 31.2 NaN  NaN    % -21
                        NaN  NaN  NaN  29.0 30.1 30.8 30.7 NaN  NaN  NaN    % -27
                    ]; %-27  -21  -15   -9   -3   +3   +9  +15  +21  +27
                    
                    DLS_norm_sd_rightEye = [
                        NaN NaN NaN 5.8 3.5 4.7 3.9 NaN NaN NaN
                        NaN NaN 3.6 2.6 4.1 2.6 2.6 2.0 NaN NaN
                        NaN 2.9 3.2 2.7 2.2 2.4 2.2 2.3 2.7 NaN
                        2.7 2.4 1.6 1.7 1.6 2.1 2.1 2.7 2.8 3.2
                        2.5 2.2 1.7 1.5 2.0 1.7 1.9 NaN 2.9 2.4
                        2.3 1.7 1.4 2.2 1.4 1.4 2.1 NaN 2.5 2.0
                        2.2 2.1 2.5 1.7 1.9 1.8 2.2 3.2 2.0 2.6
                        NaN 1.8 1.8 2.8 2.1 2.0 2.3 1.9 2.4 NaN
                        NaN NaN 2.5 2.4 2.1 1.9 2.1 2.9 NaN NaN
                        NaN NaN NaN 3.0 2.2 2.6 2.4 NaN NaN NaN
                	];
                
                    age_effect_perDecade_rightEye = [
                        NaN  NaN  NaN   -0.8 -0.6 -0.6 -0.6 NaN  NaN NaN
                        NaN  NaN  -0.7  -0.9 -0.7 -0.5 -0.6 -0.8 NaN NaN
                        NaN  -0.6 -0.6 -0.6 -0.6 -0.8 -0.9 -1.0 -0.7 NaN
                        -0.7 -0.6 -0.6 -0.8 -0.6 -0.7 -0.8 -0.7 -0.9 -0.9
                        -0.7 -0.6 -0.7 -0.7 -0.7 -0.8 -0.7 NaN  -0.9 -0.9
                        -0.9 -0.7 -0.6 -0.6 -0.5 -0.7 -0.5 NaN  -0.8 -0.7
                        -0.8 -0.5 -0.6 -0.7 -0.5 -0.6 -0.7 -0.7 -0.7 -0.9
                        NaN  -0.9 -0.7 -0.5 -0.7 -0.6 -0.5 -0.8 -0.8 NaN
                        NaN  NaN  -0.9 -0.7 -0.7 -0.7 -0.7 -0.6 NaN  NaN
                        NaN  NaN  NaN  -0.6 -0.8 -0.6 -0.6 NaN  NaN  NaN
                    ];
                
                    switch lower(eye)
                        case 'left'
                            DLS_norm_mu       	= fliplr(DLS_norm_mu_rightEye);
                            DLS_norm_var     	= fliplr(DLS_norm_sd_rightEye).^2;
                            age_effect_perYear  = fliplr(age_effect_perDecade_rightEye)/10;
                        case 'right'
                            DLS_norm_mu       	= DLS_norm_mu_rightEye;
                            DLS_norm_var      	= DLS_norm_sd_rightEye.^2;
                            age_effect_perYear	= age_effect_perDecade_rightEye/10;
                        case 'ivf'
                            DLS_norm_mu      	= max(DLS_norm_mu_rightEye, fliplr(DLS_norm_mu_rightEye));
                            DLS_norm_var     	= min(DLS_norm_sd_rightEye, fliplr(DLS_norm_sd_rightEye)).^2;
                            age_effect_perYear	= min(age_effect_perDecade_rightEye, fliplr(age_effect_perDecade_rightEye))/10;
                        otherwise
                            error('error not recognised');
                    end
                case 'hacked' % NB: the 30-2 values not contained in 24-2 are not included, as we don't have normative values for those
                    DLS_norm_mu_rightEye = [
                        NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN    % +27
                        NaN         NaN         NaN         31.3971634  31.3003063  31.1207657  30.9195824 	NaN         NaN         NaN    % +21
                        NaN         NaN         32.4867249  32.9978752  33.2378998  33.0688400  32.6889687  32.2730141 	NaN         NaN    % +15
                        NaN         32.2884140  33.5052452  34.3460884  34.8571892  34.6837044  34.0736923  33.4035378  32.7576370	NaN    % +9
                        31.1352901  32.6934280  34.1959648  35.3150902  35.7905960  35.6487885  34.9410973	NaN         33.0304871	NaN    % +3
                        31.1551819  32.7266464  34.2759552  35.3964272  35.9133224  35.7680817  35.0023766	NaN         33.0958290	NaN    % -3
                        NaN         32.3810883  33.6500931  34.6572533  35.1613846  35.0526886  34.3987885  33.5985641  32.9698639	NaN    % -9
                        NaN         NaN         32.5585251  33.3262825  33.7696495  33.7514076  33.3717995  33.0711212 	NaN         NaN    % -15
                        NaN         NaN         NaN         31.7214527  32.0593491  32.2419968  32.3541641 	NaN         NaN         NaN    % -21
                        NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN    % -27
                        ];  %-27        -21         -15         -9          -3          +3          +9          +15         +21         +27
                    
                    % these values are in fact from HeijlLindgrenOlsson1987:
                    % Normal variability of static perimetric threhsold values
                    % across the central visual field. They are the
                    % intraobserver variability values in Fig3
                    DLS_norm_sd_rightEye = [
                        NaN	NaN	NaN	4.9	4.9 5.2 5.6	NaN	NaN	NaN
                        NaN	NaN	4.6	4.7 4.2 3.7 4.3 4.9 NaN	NaN
                        NaN	4.5	3.4	3.1 2.8 3.0 2.9 3.0 3.8 NaN
                        5.0	3.4	3.3	2.4 2.4 2.1 2.2 3.5 3.4 4.3
                        4.2	2.7	2.3 2.3 2.0 2.2 2.4 NaN	3.7	4.7
                        5.8	2.2	2.3 1.9 1.6 1.8 2.1 NaN	3.3	5.2
                        4.3	3.0	2.4 1.8 2.4 2.2 2.4 3.9 3.5 6.1
                        NaN	3.0	2.7 3.4 2.4 2.4 2.3 2.5 4.3 NaN
                        NaN	NaN	4.2	3.7 2.4 2.4 3.0 4.2 NaN	NaN
                        NaN	NaN NaN	4.9	4.8 5.0 5.8 NaN	NaN	NaN
                        ];
                    
                    age_effect_perYear_rightEye = [
                        NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN    % +27
                        NaN         NaN         NaN         -0.0761451  -0.0721061  -0.0735192  -0.0786026	NaN         NaN         NaN    % +21
                        NaN         NaN         -0.0683477  -0.0636971  -0.0642868  -0.0656189  -0.0688665  -0.0745590	NaN         NaN    % +15
                        NaN         -0.0650492  -0.0579804  -0.0572248  -0.0615872  -0.0629485  -0.0634274  -0.0664786  -0.0713642	NaN    % +9
                        -0.0751606  -0.0573538  -0.0534297  -0.0562050  -0.0593152  -0.0614672  -0.0609725 	NaN         -0.0610697	NaN    % +3
                        -0.0739529  -0.0552317  -0.0510805  -0.0529299  -0.0565063  -0.0580416  -0.0564312 	NaN         -0.0557072 	NaN    % -3
                        NaN         -0.0585148  -0.0495657  -0.0488706  -0.0512410  -0.0524229  -0.0509556  -0.0509538  -0.0542664	NaN    % -9
                        NaN         NaN         -0.0517286  -0.0463620  -0.0461276  -0.0466416  -0.0469215  -0.0513291	NaN         NaN    % -15
                        NaN         NaN         NaN         -0.0481924  -0.0439378  -0.0442902  -0.0479238	NaN         NaN         NaN    % -21
                        NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN         NaN    % -27
                        ];  %-27        -21         -15         -9          -3          +3          +9          +15         +21         +27
                    
                    switch lower(eye)
                        case 'left'
                            DLS_norm_mu          = fliplr(DLS_norm_mu_rightEye);
                            DLS_norm_var         = fliplr(DLS_norm_sd_rightEye).^2;
                            age_effect_perYear  = fliplr(age_effect_perYear_rightEye);
                        case 'right'
                            DLS_norm_mu          = DLS_norm_mu_rightEye;
                            DLS_norm_var         = DLS_norm_sd_rightEye.^2;
                            age_effect_perYear  = age_effect_perYear_rightEye;
                        case 'ivf'
                            DLS_norm_mu          = max(DLS_norm_mu_rightEye, fliplr(DLS_norm_mu_rightEye));
                            DLS_norm_var         = min(DLS_norm_sd_rightEye, fliplr(DLS_norm_sd_rightEye)).^2;
                            age_effect_perYear  = min(age_effect_perYear_rightEye, fliplr(age_effect_perYear_rightEye));
                        otherwise
                            error('error not recognised');
                    end
                otherwise
                    error('specified norm type not recognised');
            end
            
            % get expected values
            normalDLS = (age_effect_perYear * (age-20)) + DLS_norm_mu;
            

            % compute deviation from normative values
            td = DLS - normalDLS;
            
            % compute MD
            idx = ~isnan(td);
            aa = sum(td(idx) .* (1./DLS_norm_var(idx)));
            bb = sum((1./DLS_norm_var(idx)));
            MD = aa/bb;
            
            % Compute pattern standard deviation
            %psd = sqrt(cov(pd));
            PSD = NaN; % not yet implemented
        end % all done!

        function [] = generateGreyscale(DLSgrid, tiles, eye)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
            
            % remove NaN values in matrix by interpolation ----------------
            %neighbours = [1,1,1; 1,0,1; 1,1,1]; % fill in based on all adjacent neighbours
            %neighbours = [0,0,0; 1,0,1; 0,0,0]; % extrapolate horizontally only (preferred because often their are marked differences in the inferior/superior regions. Alternatively could use horizontal near the meridean, and full elsewhere?
            neighbours = [0,1,0; 1,0,1; 0,1,0]; % extrapolate based on cardinal neighbours (compromise)
            while any(isnan(DLSgrid(:)))
                wasnan = isnan(DLSgrid);
                DLSgrid0 = DLSgrid;
                DLSgrid0(wasnan) = 0;
                
                y = (conv2(double(~wasnan), neighbours, 'same') .* wasnan);
                
                idx = y == max(y(:));
                out = conv2(DLSgrid0, neighbours, 'same') ./ y .* wasnan .* idx;
                DLSgrid(idx) = out(idx);
            end
            
            % detect format (24-2 or 30-2) --------------------------------
            if all(size(DLSgrid) == [8 10])
                format = '24';
            elseif all(size(DLSgrid) == [10 10])
                format = '30';
            else
                error('unknown format');
            end
            
            % construct image by placing tiles-----------------------------

            % only bother placing tiles at these locations (otherwise
            % blank)
            switch lower(format)
                case '24'
                    mask = [
                        0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
                        0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0
                        0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
                        0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0
                        0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
                        0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                        0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                        0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                        0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                        1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                        0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                        0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                        0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
                        0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 0 0 0
                        0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
                        0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0
                        0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0
                        ];
                    
                        % tweak mask if looking at left eye or IVF
                        if strcmpi(eye, 'left')
                            mask = fliplr(mask);
                        elseif strcmpi(eye, 'ivf')
                            mask = (mask + fliplr(mask))>0;
                        end
                case '30'
                    mask = [
                            0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
                            0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
                            0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                            0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                            0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0
                            0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0
                            0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
                            0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1
                            0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
                            0 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 0
                            0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0
                            0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0
                            0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 0
                            0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0
                            0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0
                            0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0
                            0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0
                            ];
            end
            
          	% interpolate DLS values out to a m1xn1 matrix of tiles
            m = size(DLSgrid,1);
            n = size(DLSgrid,2);
            m1 = size(mask,1);
            n1 = size(mask,2);
            [X,Y] = meshgrid(1:n,1:m);
            [Xq,Yq] = meshgrid(linspace(1,n,n1),linspace(1,m,m1));
            Vq = interp2(X,Y,DLSgrid,Xq,Yq);

            
            % place tiles to make image
            xf = 28; yf = 24;
            img = ones(size(Vq,1)*xf,yf*size(Vq,2),1);
            for ii = 1:size(Vq,1)
                for jj = 1:size(Vq,2)
                    xmin = 1+((ii -1)*xf);
                    xmax = 1+((ii -1)*xf) + xf;
                    ymin = 1+((jj -1)*yf);
                    ymax = 1+((jj -1)*yf) + yf;
                    
                    if mask(ii,jj)==0
                        img( xmin:xmax-1,ymin:ymax-1) = 255;
                    else
                        %tileN = min(round(Vq(ii,jj)/5), 7)
                        %img( xmin:xmax-1,ymin:ymax-1) = tiles.(sprintf('db%i',tileN));
                        
                        % compute appropriate tile
                        tileN = max(min(round(Vq(ii,jj)/5), 7), 0) + 1;
                        % ALT: [not quite right though?]
                        %EDGES = [-inf 1 6 11 16 21 26 31 inf];
                        %[~,tileN] = histc(Vq(ii,jj), EDGES);

                        % set
                        img( xmin:xmax-1,ymin:ymax-1) = tiles(:,:,tileN);
                    end
                    
                end
            end
            
            % Reduce the size of the cardinal gap
            colcen = ceil(size(Vq,2)/2)-1;
            rowcen = ceil(size(Vq,1)/2)-1;
            img(xf*rowcen:xf*(rowcen+1),:,:) = [];
            img(:,yf*colcen:yf*(colcen+1),:) = [];
            
            % add small white border
            nPixels = 24;
            img = padarray(img, [nPixels nPixels], 255);
           
            % draw plot ---------------------------------------------------
            axis image % set image to fill axes
            hold on
            
            % plot greyscale
            imshow(img);
            
            % draw axes/crosshair: compute key variables
            mx = round(size(img,2)/2);     % horizontal (y axis) centre
            my = round(size(img,1)/2);     % vertical (x axis) centre
            xlims = [1+yf/2, size(img,2)-yf/2]; % range of x axis (hacked for positioning)
            ylims = [1, size(img,1)];      % range of y axis (continue right to edge)
            
            % plot axes (cardinal lines)
            plot([mx,mx], ylims,'LineWidth',1,'Color','k'); % plot y axis
            plot(xlims,[my,my],'LineWidth',1,'Color','k'); % plot x axis
            
            % Add tick marks
            tickHalfLength = yf/2;
            % xTick
            xTick = linspace(xlims(1), xlims(end), 7);
            for i=1:length(xTick)
                plot([xTick(i),xTick(i)], [my-tickHalfLength, my+tickHalfLength],'LineWidth',.5,'Color','k');% pp1.Color(4) = 0.99;
            end
            % yTick
            yTick = linspace(ylims(1)-yf*2, ylims(end)+yf*2, 7); % hacked for positioning
            yTick([1 end]) = [];
            for i =1:length(yTick)
                plot([mx-tickHalfLength, mx+tickHalfLength], [yTick(i), yTick(i)], 'LineWidth',.5,'Color','k');% pp1.Color(4) = 0.99;
            end
            hold off;
        end

        function [] = annotate(eyeStr, DLS, age)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
        
            % annotate panel with psd and md computaions
            VfPlot.textLoc1(eyeStr, 'NorthOutside', 'FontSize',VfPlot.FONTSIZE,'color','k');
            MD  = VfPlot.computeSummaryStatistics(DLS, age, eyeStr);
          	txt = sprintf('MD: %1.1f', MD);
            VfPlot.textLoc1(txt, 'SouthOutside', 'FontSize',VfPlot.FONTSIZE,'color','k');
        end
        
        function [] = annotateSmall(eyeStr, DLS, age)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
        
            % annotate panel with psd and md computaions
            MD  = VfPlot.computeSummaryStatistics(DLS, age, eyeStr);
          	txt = sprintf('MD: %1.1f', MD);
            VfPlot.textLoc1(txt, 'SouthWest', 'FontSize',VfPlot.FONTSIZE/2,'color','k');
        end
       
        function DLS_IVF = computeIVF(DLS_leftEye, DLS_rightEye, method)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %

            % Combine (either Mean or Max)
            x  = cat(3, DLS_leftEye, DLS_rightEye);
            switch lower(method)
                case 'mean'
                    DLS_IVF = round(nanmean(x,3));
                    return;
                case 'max'
                    DLS_IVF = max(x,[],3);
                    return;
                otherwise
                    error('Ungrecognised method: %s', method);
            end
        end
        
        function [] = textLoc1(txt, loc, varargin)
            % Adapted from textLoc.m (on FileExchange)
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
            
            % create text
            H=text(0,0,txt,varargin{:});
            
            % set buffer
            buffer=1/50;
            if strcmpi('latex',get(0,'defaulttextinterpreter'))
                buffer = buffer*5;
            end
            
            % set location
            set(H,'units','normalized');
            switch lower(loc)
                case 'northoutside'
                    set(H,'Position',[.5,1+buffer]);
                    set(H,'HorizontalAlignment','Center');
                    set(H,'VerticalAlignment','Bottom');
                case 'southoutside'
                    set(H,'Position',[.5, -buffer]);
                    set(H,'HorizontalAlignment','Center');
                    set(H,'VerticalAlignment','Top');
                case 'southwest'
                    set(H,'Position',[  buffer,  buffer]);
                    set(H,'HorizontalAlignment','Left');
                    set(H,'VerticalAlignment','Bottom');
                otherwise
                    error('input not recognised: %s', loc);
            end
        end
        
    end
    
    %% ====================================================================
    %  -----STATIC METHODS (public)-----
    %$ ====================================================================

    methods (Static, Access = public)

        function [] = plot(DLS, isRightEye, doAnnotation, age)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %

            % parse user inputs
            if nargin<3 || isempty(doAnnotation)
                doAnnotation = false;
            end
            
            % init
            eyeStr = {'left','right'};
            eyeStr = eyeStr{isRightEye+1};

            % plot eye
            DLS = VfPlot.ensureMatrix(DLS, 'left'); % prepare data (ensure matrix)
            VfPlot.generateGreyscale(DLS, VfPlot.TILES, eyeStr);
            if doAnnotation
                VfPlot.annotateSmall(eyeStr, DLS, age);
            end
        end
        
        function [] = plot2(DLS_leftEye, DLS_rightEye, doAnnotation, age, filename)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %
            
            % parse user inputs
            if nargin<5
                filename = [];
            end
            
            % load tiles [no longer required as hardcoded in]
            %tiles = VfPlot.loadTiles();
            
            % open figure window
            figure();
            
            % plot left eye
            if ~isempty(DLS_leftEye)
              	subplot(1,2,1);
                DLS_leftEye = VfPlot.ensureMatrix(DLS_leftEye, 'left'); % prepare data (ensure matrix)
                VfPlot.generateGreyscale(DLS_leftEye, VfPlot.TILES, 'left');
                if doAnnotation
                    VfPlot.annotate('Left', DLS_leftEye, age);
                end
            end            
            
            % plot right eye
            if ~isempty(DLS_rightEye)
              	subplot(1,2,2);
                DLS_rightEye = VfPlot.ensureMatrix(DLS_rightEye, 'right'); % prepare data (convert to vector, remove NaN by interpolation)
                VfPlot.generateGreyscale(DLS_rightEye, VfPlot.TILES, 'right');
                if doAnnotation
                    VfPlot.annotate('Right', DLS_rightEye, age);
                end
            end
            
            % format figure
            set(gcf, 'InvertHardCopy', 'on');
            set(gcf,'Units','normalized','Position',[0 0 1 1]);
            
            % save to file, if so requested
            if ~isempty(filename)
                print(filename,'-dpng','-r300'); % ALT: dtif
            end
        end
        
        function [] = plot3(DLS_leftEye, DLS_rightEye, plotIVF, doAnnotation, age, filename)
            % xxxxx
            %
            % @param    xxxxx
            %
            % @date     07/06/18
            % @author   PRJ
            %

            % parse user inputs
            if plotIVF && (isempty(DLS_leftEye) || isempty(DLS_rightEye))
                error('both eyes must be specified in order to plot IVF');
            end
            if nargin<6
                filename = [];
            end
           
            % load tiles [no longer required as hardcoded in]
            % tiles = VfPlot.loadTiles();
            
            % open figure window
            figure();
            
            % plot left eye
            if ~isempty(DLS_leftEye)
              	subplot(1,3,1);
                DLS_leftEye = VfPlot.ensureMatrix(DLS_leftEye, 'left'); % prepare data (ensure matrix)
                VfPlot.generateGreyscale(DLS_leftEye, VfPlot.TILES, 'left');
                if doAnnotation
                    VfPlot.annotate('Left', DLS_leftEye, age);
                end
            end            
            
            % plot right eye
            if ~isempty(DLS_rightEye)
              	subplot(1,3,3);
                DLS_rightEye = VfPlot.ensureMatrix(DLS_rightEye, 'right'); % prepare data (convert to vector, remove NaN by interpolation)
                VfPlot.generateGreyscale(DLS_rightEye, VfPlot.TILES, 'right');
                if doAnnotation
                    VfPlot.annotate('Right', DLS_rightEye, age);
                end
            end
            
            % plot IVF
            if plotIVF
              	subplot(1,3,2);
                DLS_IVF = VfPlot.computeIVF(DLS_leftEye, DLS_rightEye, 'max'); % @todo make METHOD a variable
                VfPlot.generateGreyscale(DLS_IVF, VfPlot.TILES, 'IVF');
                if doAnnotation
                    VfPlot.annotate('IVF', DLS_IVF, age);
                end
            end
            
            % format figure
            set(gcf, 'InvertHardCopy', 'on');
            set(gcf,'Units','normalized','Position',[0 0 1 1]);
            
            % save to file, if so requested
            if ~isempty(filename)
                print(filename,'-dpng','-r300'); % ALT: dtif
            end
        end
        
        
        function [] = runExample(N)
            if nargin < 1 || isempty(N)
                N = 1;
            end
            
            % init
            close all;

        	% user params
            switch N
                case 1 % extreme example (24-2)
                    DLS_left = [
                        NaN   NaN   NaN    0     0     10    10   NaN   NaN   NaN
                        NaN   NaN    0     0     0     10    10    10   NaN   NaN
                        NaN    0     0     0     0     10    10    10    10   NaN
                        NaN    0     0     0     0     10    10    10    10    10 
                        NaN    20    20    20    20    30    30    30    30    30
                        NaN    20    20    20    20    30    30    30    30   NaN
                        NaN   NaN    20    20    20    30    30    30   NaN   NaN
                        NaN   NaN   NaN    20    20    30    30   NaN   NaN   NaN
                	];
                    DLS_right = [
                        NaN   NaN   NaN    0     0     10    10   NaN   NaN   NaN
                        NaN   NaN    0     0     0     10    10    10   NaN   NaN
                        NaN    0     0     0     0     10    10    10    10   NaN
                         0     0     0     0     0     10    10    10    10   NaN
                         20    20    20    20    20    30    30    30    30   NaN
                        NaN    20    20    20    20    30    30    30    30   NaN
                        NaN   NaN    20    20    20    30    30    30   NaN   NaN
                        NaN   NaN   NaN    20    20    30    30   NaN   NaN   NaN
                   	];
                    age = 70;
                    fn = []; % no output file name (won't save)
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
            
                case 2 % same as 1, but inputs specified as one long vector (sampled left-to-right across each row)
                    DLS_left = [0	0	10	10	0	0	0	10	10	10	0	0	0	0	10	10	10	10	0	0	0	0	10	10	10	10	10	20	20	20	20	30	30	30	30	30	20	20	20	20	30	30	30	30	20	20	20	30	30	30	20	20	30	30];
                    DLS_right = [0	0	10	10	0	0	0	10	10	10	0	0	0	0	10	10	10	10	0	0	0	0	0	10	10	10	10	20	20	20	20	20	30	30	30	30	20	20	20	20	30	30	30	30	20	20	20	30	30	30	20	20	30	30];
                    age = 70;
                    fn = [];
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
                case 3 % more realistic example
                    DLS_left = [
                        NaN   NaN   NaN    16    11    20    21   NaN   NaN   NaN
                        NaN   NaN    20    25    23    21    21    16   NaN   NaN
                        NaN    23    19    23    24    24    20    21    16   NaN
                        NaN    23    21    24    24    25    24    21     3     9
                        NaN    21     0    23    25    23     0     0     0     0
                        NaN    19     9     0     0     0     0     0     0   NaN
                        NaN   NaN     9    17    12     0     0     6   NaN   NaN
                        NaN   NaN   NaN     0    12    15    10   NaN   NaN   NaN
                 	];
                    DLS_right = [
                        NaN   NaN   NaN    17    17    16    16   NaN   NaN   NaN
                        NaN   NaN    19    21    20    19    20    19   NaN   NaN
                        NaN    18    21    21    22    21    20    21    20   NaN
                        15     19    22    23    24    24    23    17    21   NaN
                        16     19    22    24    25    25    24     4    21   NaN
                        NaN    18    22    22    23    23    22    22    21   NaN
                        NaN   NaN    20    21    21    21    22    21   NaN   NaN
                        NaN   NaN   NaN    18    19    20    20   NaN   NaN   NaN
                    ];
                    age = 78;
                    fn = [];
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
                case 4 % more realistic but both eyes identical/symmetric
                    DLS_left = [
                        NaN   NaN   NaN    14    14    14    14   NaN   NaN   NaN
                        NaN   NaN    16    18    16    17    18    16   NaN   NaN
                        NaN    17    18    19    19    19    19    18    15   NaN
                        NaN    18    15    20    21    21    20    19    16    13
                        NaN    18     3    21    22    22    21    20    17    13
                        NaN    18    19    20    20    20    20    19    16   NaN
                        NaN   NaN    18    19    18    19    19    17   NaN   NaN
                        NaN   NaN   NaN    17    17    16    15   NaN   NaN   NaN
                 	];
                    DLS_right = fliplr(DLS_left);
                    age = 70;
                    fn = [];
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
            	case 5 % extreme example (30-2)
                    DLS_left = [
                        NaN   NaN   NaN    0     0     10    10   NaN   NaN   NaN
                        NaN   NaN    0     0     0     10    10    10   NaN   NaN
                        NaN    0     0     0     0     10    10    10    10   NaN
                          0    0     0     0     0     10    10    10    10    10
                          0    0     0     0     0     10    10    10    10    10 
                         20    20    20    20    20    30    30    30    30    30
                         20    20    20    20    20    30    30    30    30    30
                        NaN    20    20    20    20    30    30    30    30   NaN
                        NaN   NaN    20    20    20    30    30    30   NaN   NaN
                        NaN   NaN   NaN    20    20    30    30   NaN   NaN   NaN
                	];
                    DLS_right = [
                        NaN   NaN   NaN    0     0     10    10   NaN   NaN   NaN
                        NaN   NaN    0     0     0     10    10    10   NaN   NaN
                        NaN    0     0     0     0     10    10    10    10   NaN
                          0    0     0     0     0     10    10    10    10    10
                          0    0     0     0     0     10    10    10    10    10 
                         20    20    20    20    20    30    30    30    30    30
                         20    20    20    20    20    30    30    30    30    30
                        NaN    20    20    20    20    30    30    30    30   NaN
                        NaN   NaN    20    20    20    30    30    30   NaN   NaN
                        NaN   NaN   NaN    20    20    30    30   NaN   NaN   NaN
                        ];
                    age = 70;
                    fn = []; % no output file name (won't save)
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
                case 6 % more realistic example (30-2)
                    DLS_left = [
                        NaN   NaN   NaN    14    13    13    12   NaN   NaN   NaN
                        NaN   NaN    13    14    14    14    14    13   NaN   NaN
                        NaN    16    16    18    16    17    18    16    14   NaN
                        16     17    18    19    19    19    19    18    15    12
                        17     18    15    20    21    21    20    19    16    13
                        17     18     3    21    22    22    21    20    17    13
                        17     18    19    20    20    20    20    19    16    15
                        NaN    17    18    19    18    19    19    17    15   NaN
                        NaN   NaN    16    17    17    16    15    14   NaN   NaN
                        NaN   NaN   NaN    16    17    16    15   NaN   NaN   NaN
                 	];
                    DLS_right = [
                        NaN   NaN   NaN    16    16    16    15   NaN   NaN   NaN
                        NaN   NaN    17    17    17    16    16    18   NaN   NaN
                        NaN    17    19    21    20    19    20    19    20   NaN
                        14     18    21    21    22    21    20    21    20    19
                        15     19    22    23    24    24    23    17    21    20
                        16     19    22    24    25    25    24     4    21    20
                        17     18    22    22    23    23    22    22    21    19
                        NaN    17    20    21    21    21    22    21    20   NaN
                        NaN   NaN    17    18    19    20    20    20   NaN   NaN
                        NaN   NaN   NaN    17    19    19    19   NaN   NaN   NaN
                    ];
                    age = 70;
                    fn = [];
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
                case 7 % symmetric example (30-2)
                    DLS_left = [
                        NaN   NaN   NaN     0     0     7    19   NaN   NaN   NaN
                        NaN   NaN     0    11     0     2    19    16   NaN   NaN
                        NaN     0     0     9    14     0    20    23    21   NaN
                        0       1    15    17    10    12     0    23    26    25
                        0      20    23    25    27    27    29     0    24    20
                        4       0     0     0     0    30    16     0    26    26
                        0       0     0     0     0     0     0    30    23    24
                        NaN     0    15    10    25    26    29    29    28   NaN
                        NaN   NaN    15    19    28    25    29    30   NaN   NaN
                        NaN   NaN   NaN    26    28    29    28   NaN   NaN   NaN
                 	];
                    DLS_right = fliplr(DLS_left);
                    age = 68;
                    fn = [];  
                    
                    % run
                    plotIVF      = true;
                    doAnnotation = true;
                    VfPlot.plot3(DLS_left, DLS_right, plotIVF, doAnnotation, age, fn);
                    
             	case 8 % 24-2, no IVF
                    DLS_left = [
                        NaN   NaN   NaN    14    14    14    14   NaN   NaN   NaN
                        NaN   NaN    16    18    16    17    18    16   NaN   NaN
                        NaN    17    18    19    19    19    19    18    15   NaN
                        NaN    18    15    20    21    21    20    19    16    13
                        NaN    18     3    21    22    22    21    20    17    13
                        NaN    18    19    20    20    20    20    19    16   NaN
                        NaN   NaN    18    19    18    19    19    17   NaN   NaN
                        NaN   NaN   NaN    17    17    16    15   NaN   NaN   NaN
                 	];
                    DLS_right = fliplr(DLS_left);
                    age = 70;
                    fn = [];
                    
                    % run
                    doAnnotation = true;
                    VfPlot.plot2(DLS_left, DLS_right, doAnnotation, age, fn);
                    
            	case 9 % 24-2, just left eye, no text
                    DLS_left = [
                        NaN   NaN   NaN    14    14    14    14   NaN   NaN   NaN
                        NaN   NaN    16    18    16    17    18    16   NaN   NaN
                        NaN    17    18    19    19    19    19    18    15   NaN
                        NaN    18    15    20    21    21    20    19    16    13
                        NaN    18     3    21    22    22    21    20    17    13
                        NaN    18    19    20    20    20    20    19    16   NaN
                        NaN   NaN    18    19    18    19    19    17   NaN   NaN
                        NaN   NaN   NaN    17    17    16    15   NaN   NaN   NaN
                 	];
                    age = 70;
                    fn = [];
                    
                    % run
                    doAnnotation = false;
                    VfPlot.plot2(DLS_left, [], doAnnotation, age, fn);
                    
                otherwise
                    error('Input not recognised: %i', N);
            end
            
        end
        
    end
    

end