DeconvNetToolbox
gui.m
Go to the documentation of this file.
00001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00002 % A gui that provides access to launchable experiments of various types and
00003 % setting of their parameters. This gui seems to work for most MATLAB releases
00004 % that support guis except R2011a currently (controls are not visible for
00005 % some reason). This function was created specifically for my setup and therefore
00006 % may not work 100 percent of the time on various setups. Note: you must set
00007 % the paths at the top of this file to the start paths of where to save
00008 % the results to and where you stored the images you want to run on (just the
00009 % start paths must be set here, the rest of the paths can be set in the gui).
00010 %
00011 % Instructions for using the GUI: this gui allows you to set any parameters
00012 % necessary to train a Deconvolutional Network using this toolbox. When
00013 % the gui opens it loads a file named gui_has_set_the_params.mat in the GUI/
00014 % directory. This store a struct called model which holds all the parameters
00015 % the gui sets. Clicking of the fields will modify the value in the model variable
00016 % but it does not save back to gui_has_set_the_params.mat each time you change
00017 % a parameter. To save out to this file click the 'Save' button in the lower
00018 % right corner of the gui. Once saved, you can run the experiments of choice
00019 % from any machine that can access that gui_has_set_the_params.mat file (and has
00020 % it on it's path). Once saved, the parameters are loaded from this file the
00021 % next time the gui is opened as well.
00022 %
00023 % When any of the parameters are changed (enter was hit on a field or a drop down
00024 % item was selected for example), then the description at the top right of 
00025 % the gui will update to describe what that parameter is means in the model.
00026 % So a handy way to determine what each parameter does is to just enter the
00027 % same value back in a field and hit enter to see this description. The directory
00028 % buttons in the bottom left corner can be used to visually select a directory
00029 % instead of typing in the long strings in the fields to the right. Any buttons
00030 % that may do harm pop up a warning information message first as well. 
00031 %
00032 % @file
00033 % @author Matthew Zeiler
00034 % @date Mar 11, 2010
00035 %
00036 % @gui_file @copybrief gui.m
00037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00038 
00039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00040 % @copybrief gui.m
00041 %
00042 % @param fig_num An optional figure number to create the gui in. Defaults to 999.
00043 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00044 function gui(fig_num)
00045 % SIMPLE_GUI2 Select a data set from the pop-up menu, then
00046 % click one of the plot-type push buttons. Clicking the button
00047 % plots the selected data in the axes.
00048 
00049 if(nargin<1)
00050     fgui = figure(999);
00051     close(999)
00052     %  Create and then hide the GUI as it is being constructed.
00053     fgui = figure(999);
00054 else
00055     fgui = figure(fig_num);
00056     close(fig_num)
00057     %  Create and then hide the GUI as it is being constructed.
00058     fgui = figure(fig_num);
00059 end
00060 set(fgui,'Visible','off');
00061 set(fgui,'Position',[1,40,1200,700]);
00062 set(fgui,'Name','Experiment Setup - GUI');
00063 
00064 % [START_DATASET_DIRECTORY,START_RESULTS_DIRECTORY] = setupPaths();
00065 % The path to the directoy where this gui file is located.
00066 GUI_DIRECTORY = [parentdir(mfilename('fullpath')) '/'];
00067 
00068 
00069 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00070 % SETUP RESULTS AND DATASET start paths here.
00071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00072 % Note: the final path will be [these 'Result/...'] auto-genned results
00073 % directories by defulat. And [these 'Datasets/...'] dataset directory.
00074 % Make sure these DO NOT end in '/'.
00075 START_DATASET_DIRECTORY = '/Users/zeiler/work/Thesis';
00076 START_RESULTS_DIRECTORY = '/Users/zeiler/work/Thesis';
00077 % BELOW IS OPTIONAL: You can have multiple paths as well.
00078 % Pick different paths if running somewhere else (can keep doing this if you
00079 % have multiple different machines/environments you want to run on.
00080 
00081 % A second machine setup.
00082 if(~exist(START_DATASET_DIRECTORY,'dir'))
00083     fprintf('START_DATASET_DIRECTORY: %s does not exist.\n',START_DATASET_DIRECTORY);    
00084     START_DATASET_DIRECTORY = '/misc/vlgscratch1/FergusGroup/zeiler';
00085     fprintf('Using %s instead.\n',START_DATASET_DIRECTORY);
00086 end
00087 if(~exist(START_RESULTS_DIRECTORY,'dir'))
00088     fprintf('START_RESULTS_DIRECTORY: %s does not exist.\n',START_RESULTS_DIRECTORY);
00089     START_RESULTS_DIRECTORY = '/misc/FergusGroup/zeiler';
00090     fprintf('Using %s instead.\n',START_RESULTS_DIRECTORY);
00091 end
00092 
00093 % A 3rd machine setup.
00094 if(~exist(START_DATASET_DIRECTORY,'dir'))
00095     fprintf('START_DATASET_DIRECTORY: %s does not exist.\n',START_DATASET_DIRECTORY);
00096     START_DATASET_DIRECTORY = '/scratch/mdz222';
00097     fprintf('Using %s instead.\n',START_DATASET_DIRECTORY);
00098 end
00099 if(~exist(START_RESULTS_DIRECTORY,'dir'))
00100     fprintf('START_RESULTS_DIRECTORY: %s does not exist.\n',START_RESULTS_DIRECTORY);
00101     START_RESULTS_DIRECTORY = '/scratch/mdz222';
00102     fprintf('Using %s instead.\n',START_RESULTS_DIRECTORY);
00103 end
00104 % Error if none of these worked.
00105 if(~exist(START_DATASET_DIRECTORY,'dir'))
00106     error('Final START_DATASET_DIRECTORY does not exist. Make sure it is set properly at the top of gui.m');
00107 end
00108 if(~exist(START_RESULTS_DIRECTORY,'dir'))
00109     error('Final START_RESULTS_DIRECTORY does not exist. Make sure it is set properly at the top of gui.m');
00110 end
00111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00112 
00113 % Remove training slash in directory names.
00114 if(strcmp(START_RESULTS_DIRECTORY(end),'/'))
00115     START_RESULTS_DIRECTORY = START_RESULTS_DIRECTORY(1:end-1);
00116 end
00117 if(strcmp(START_DATASET_DIRECTORY(end),'/'))
00118     START_DATASET_DIRECTORY = START_DATASET_DIRECTORY(1:end-1);
00119 end
00120 
00121 
00122 
00123 
00124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00125 %% Do not touch anything below here.
00126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00127 % Determine the architecture.
00128 upath = userpath;
00129 if(exist(strcat(upath(1:end-1),'mac.m'),'file'))
00130     ARCH = 'MAC';
00131 else
00132     ARCH = 'LINUX';
00133 end
00134 
00135 
00136 EXPERIMENTAL = 0; % include buggy code?
00137 
00138 % The number of computation threads to use
00139 model.comp_threads = 2;
00140 
00141 %%%%%%%%%%
00142 %% IPP or GPU Libraries (use for speed!)
00143 %%%%%%%%%%
00144 % Whether or not to use IPP libraries (much faster if you can use this but requires the IPPConvsToolbox from www.matthewzeiler.com/software/).
00145 model.USE_IPP = 1;
00146 if(~exist(strcat('ipp_conv2.',mexext),'file'))
00147     fprintf('You do not have the compiled versions of the IPP Convolutions Toolbox therefore reverting to slower MATLAB only implementation.\n')
00148     model.USE_IPP = 0;
00149 end
00150 
00151 % If you want to use the GPU (overrides the ipp setting).
00152 if(exist('startGPU.m','file') && exist('GPUstart.m','file'))
00153     model.USE_GPU = 1; % Checks if a gpu exists at start.
00154 else
00155     fprintf('You do not have the GPUmat modules installed so reverting to CPU implementation.\n');
00156     model.USE_GPU = 0;
00157 end
00158 %%%%%%%%%%
00159 
00160 
00161 %%%%%%%%%%
00162 %% Plotting and Saving Directories
00163 %%%%%%%%%%
00164 % If >0 then results will be plotted every PLOT_RESULTS many epochs in the various forms.
00165 % (set to zero for speed if you just want to save the results instead of view online).
00166 % Note: the plots lock to different locations on the screen initially but can be
00167 % dragged anywhere afterwards. This locking was designed for an (1920x1080) or
00168 % higher resolution screen.
00169 model.PLOT_RESULTS = 0;
00170 % If >0 then results will be saved every SAVE_RESULTS many epochs in the format epoch#_layer#.mat
00171 model.SAVE_RESULTS = 5;
00172 % If you want to show figure(123) which lets you stop a program at any time by pressing 's' on the keyboard when the figure is in focus.
00173 model.SHOW_KEYPRESS = 1;
00174 % If >0 then error function evaluation will be printed out (faster if you don't) every DISPLAY_ERROR many epochs.
00175 % THIS IS AUTOMATICALLY SET WHEN RECONSTRUCTING as it is needed to display the reconstructed results as well.
00176 model.DISPLAY_ERRORS = 0;
00177 % If you want to be notified of the start and end of the model's run.
00178 % Enter your email here, leave blank '' otherwise.
00179 model.EMAIL_NOTIFICATIONS = '';
00180 % If 1 then this suppress warnings that are generated from the toolboxes (such as not compiled warnings).
00181 model.SUPPRESS_WARNINGS = 0;
00182 % A note you can add as a description of the current experiment (to help recal it later).
00183 model.notes = '';
00184 
00185 % Where to save the results (will be appended to save various things if SAVE_RESULTS>1)
00186 % Note this is based on the current directory by defuault, you'll likely want to change this.
00187 model.fullsavepath = './Results/fruit_100_100/Run_1/';
00188 % Path to a folder containing only image files (and maybe other folder but it
00189 % will not be checked recursively) for training or to reconstruct.
00190 model.fulldatapath = './Datasets/Images/fruit_100_100/';
00191 % Set this to the last folder
00192 model.tag = 'fruit_100_100';
00193 % model.fulldatapath = '/Datasets/Images/city_100_100/';
00194 % model.tag = 'city_100_100';
00195 % Example for reconstructing.
00196 % model.fulldatapath = '/Datasets/Images/singles/test1/';
00197 
00198 % Used for Reconstruction: this is a path to a previously trained model used
00199 % for reconstructing an image (this is a file but don't both with the .mat extension).
00200 % Note: this is ignored during training.
00201 model.fullmodelpath = './Results/fruit_100_100/Run_1/epoch5_layer2.mat';
00202 %%%%%%%%%%
00203 
00204 
00205 
00206 %%%%%%%%%%
00207 %% Image Preprocessing
00208 %%%%%%%%%%
00209 % Parameters for the image creation/preprocessing.
00210 model.ZERO_MEAN = 0;          % binary (subtract mean or not)
00211 model.CONTRAST_NORMALIZE = 'laplacian_cn'; % binary (constrast normalize images or not) Available types are: 'none','local_cn','laplacian_cn','box_cn','PCA_whitening','ZCA_image_whitening','ZCA_patch_whitening',and 'inv_f_whitening'
00212 model.COLOR_IMAGES = 'gray';   % string: 'gray', 'rgb', 'ycbcr', 'hsv'
00213 model.SQUARE_IMAGES = 1;      % binary (square images or not)
00214 model.image_frames = {1,1,'end'}; % Selection of the frames as 1:1:end
00215 %%%%%%%%%%
00216 
00217 
00218 
00219 %%%%%%%%%%
00220 %% Training Adjustments
00221 %%%%%%%%%%
00222 % Batch size used in training (leave at 1 as batching doesn't work well).
00223 model.batch_size = 16;
00224 
00225 % If this is set to 0, then they are picked in order (1 is best).
00226 model.RANDOM_IMAGE_ORDER = 1;
00227 
00228 % Number of epochs per layer through the training set (5 is usually sufficient).CG
00229 model.maxepochs = [5 10 10 10 25 25 25 25 25 25];
00230 % Number of steps of conjugate gradient used when updating filters and feature maps at each iteration (2 is best).
00231 model.min_iterations = 2;
00232 % Threshold for the gradients.
00233 model.grad_threshold = 0.01;
00234 
00235 % For Yann's inference scheme, if you want to train the 1st layer initially.
00236 model.LAYER1_FIRST = 0;
00237 %%%%%%%%%%
00238 
00239 %%%%%%%%%%
00240 %% Model Structure
00241 %%%%%%%%%%
00242 % Number of layers total in the model you want to train. Note: below you will
00243 % see many variables defined for a 4 layer model. This was just for convenience
00244 % and only the first num_layers of them are used for the layers. 4 was just
00245 % choosen as a reasonable size as well, but the code will accept any number of
00246 % layer (though not tested) if these arrays of parameters below are extended.
00247 % This is the physical number of layers in the model.
00248 % model.layer is calculated as the top layer of the current training phase based
00249 % on the lambda, gamma, and beta coefficients (0's in all mean no layer).
00250 model.num_layers = 4;
00251 % The number of training phases to conduct. For example, phase 1 might be to
00252 % train only layer 1, phase 2 train layer 2,3, etc...
00253 model.num_phases = 4;
00254 % Size of each filters in each layer (assumes square). (7 is good).
00255 model.filter_size = [[7 7];[7 7];[7 7];[7 7];[7 7];[7 7];[7 7];[7 7];[7 7];[7 7]];
00256 % Number of feature maps in each layer. (this is the defualt).
00257 model.num_feature_maps = [15 50 100 150 250 250 250 250 250 250];
00258 % Number of input maps in the first layer (do not modify this).
00259 if(strcmp(model.COLOR_IMAGES,'ycbcr') || strcmp(model.COLOR_IMAGES,'rgb') || strcmp(model.COLOR_IMAGES,'hsv'))
00260     % Number of input maps in all layers (do not modify this).
00261     model.num_input_maps = [3 model.num_feature_maps(1:end-1)];
00262 else
00263     % Number of input maps in all layers (do not modify this).
00264     model.num_input_maps = [1 model.num_feature_maps(1:end-1)];
00265 end
00266 
00267 % The default types for the connectivity matrix (from cvpr2010)
00268 model.conmat_types = {'Full','Full','Full','Full','Full','Full','Full','Full','Full','Full'};
00269 % Initialize connectivity matrices to the desired defaults.
00270 [model] = update_conmats(model);
00271 %%%%%%%%%%
00272 
00273 %%%%%%%%%%
00274 %% Learning parameters
00275 %%%%%%%%%%
00276 % The type of inference to use: 'ISTA','FISTA','CG' or 'APPROX'. May have to change parameters below.
00277 % Only ISTA is recommended and fully tested.
00278 model.INFERENCE_TYPE = {'ISTA','ISTA','ISTA','ISTA','ISTA','ISTA','ISTA','ISTA','ISTA','ISTA'}; % Try to infer just with a singe forward prop up from teh image.
00279 % The type of learning filters to use: 'ISTA','FISTA','CG'. May have to change parameters below.
00280 % Only CG is recommended and fully tested.
00281 model.LEARNING_TYPE = {'CG','CG','CG','CG','CG','CG','CG','CG','CG','CG'}; % Try to infer just with a singe forward prop up from teh image.
00282 % If this is set to 0 then feature maps can be positive or negative, 1 forces positive.
00283 model.POSITIVE_Z = 1;
00284 
00285 
00286 % Reconstruction term lambda*||sum(conv(z,f)) - y||^2 weighting for each layer (1 works well).
00287 model.lambda = [
00288     [2 0 0 0 0 0 0 0 0 0];       % Layer1
00289     [0 0.1 0 0 0 0 0 0 0 0];       % Layer2
00290     [0 0 0.005 0 0 0 0 0 0 0];       % Layer3
00291     [0 0 0 1e-3 0 0 0 0 0 0];       % Layer4
00292     [0 0 0 0 1 0 0 0 0 0];       % Layer5
00293     [0 0 0 0 0 1 0 0 0 0];       % Layer6
00294     [0 0 0 0 0 0 1 0 0 0];       % Layer7
00295     [0 0 0 0 0 0 0 1 0 0];       % Layer8
00296     [0 0 0 0 0 0 0 0 1 0];       % Layer9
00297     [0 0 0 0 0 0 0 0 0 1];       % Layer10
00298     ];
00299 % The alpha-norm on the auxilary variable kappa*|x|^alpha for each layer.
00300 model.alpha = [
00301     [1 1 1 1 1 1 1 1 1 1];       % Layer1
00302     [1 1 1 1 1 1 1 1 1 1];       % Layer2
00303     [1 1 1 1 1 1 1 1 1 1];       % Layer3
00304     [1 1 1 1 1 1 1 1 1 1];       % Layer4
00305     [1 1 1 1 1 1 1 1 1 1];       % Layer5
00306     [1 1 1 1 1 1 1 1 1 1];       % Layer6
00307     [1 1 1 1 1 1 1 1 1 1];       % Layer7
00308     [1 1 1 1 1 1 1 1 1 1];       % Layer8
00309     [1 1 1 1 1 1 1 1 1 1];       % Layer9
00310     [1 1 1 1 1 1 1 1 1 1];       % Layer10
00311     ];
00312 
00313 % The regeme over the continutaion variable, beta.
00314 %start value
00315 % Any negative number will automatically estimate a new beta value per batch per
00316 % epoch (recommended for first time users or to quickly find good settings for
00317 % the step size).
00318 model.Binitial = [
00319     [1e-3 0 0 0 0 0 0 0 0 0];       % Layer1
00320     [0 1e-4 0 0 0 0 0 0 0 0];       % Layer2
00321     [0 0 1e-6 0 0 0 0 0 0 0];       % Layer3
00322     [0 0 0 1e-8 0 0 0 0 0 0];       % Layer4
00323     [0 0 0 0 -1 0 0 0 0 0];       % Layer5
00324     [0 0 0 0 0 -1 0 0 0 0];       % Layer6
00325     [0 0 0 0 0 0 -1 0 0 0];       % Layer7
00326     [0 0 0 0 0 0 0 -1 0 0];       % Layer8
00327     [0 0 0 0 0 0 0 0 -1 0];       % Layer9
00328     [0 0 0 0 0 0 0 0 0 -1];       % Layer10
00329     ];
00330 %beta = beta*Bmultiplier each iteration
00331 % Only used in CG (not supported anymore).
00332 model.Bmultiplier = [
00333     [10 10 10 10 10 10 10 10 10 10];       % Layer1
00334     [10 10 10 10 10 10 10 10 10 10];       % Layer2
00335     [10 10 10 10 10 10 10 10 10 10];       % Layer3
00336     [10 10 10 10 10 10 10 10 10 10];       % Layer4
00337     [10 10 10 10 10 10 10 10 10 10];       % Layer5
00338     [10 10 10 10 10 10 10 10 10 10];       % Layer6
00339     [10 10 10 10 10 10 10 10 10 10];       % Layer7
00340     [10 10 10 10 10 10 10 10 10 10];       % Layer8
00341     [10 10 10 10 10 10 10 10 10 10];       % Layer9
00342     [10 10 10 10 10 10 10 10 10 10];       % Layer10
00343     ];
00344 % Numbr of iterations of ISTA or CG per batch per epoch.
00345 % Set these to 6's if using CG for inference (1 for ISTA/FISTA)
00346 model.betaT = [1 1 1 1 1 1 1 1 1 1];
00347 
00348 %%%%%%%%%%%
00349 % Pooling
00350 %%%%%%%%%%%
00351 % If you want to loop and unloop the pooling operation at each iteration.
00352 % Default is 3, there are various types in infer_ISTA now, this is the correct one.
00353 model.SUBSAMPLING_UPDATES = [3 3 3 3 3 3 3 3 3 3];
00354 % Normalization type for each layer and the input image (first one).
00355 model.norm_types = {'Max3','Max3','Max3','Max3','Max3','Max3','Max3','Max3','Max3','Max3'};
00356 % The size of the pooling regions.
00357 model.norm_sizes = {[3 3 3 1 1 1],[3 3 2 1 1 1],[3 3 2 1 1 1],[3 3 2 1 1 1],[4 4 1 1 1 1],[4 4 1 1 1 1],...
00358     [2 2 1 1 1 1],[2 2 1 1 1 1],[2 2 1 1 1 1],[2 2 1 1 1 1]};
00359 %%%%%%%%%%%
00360 
00361 %%%%%%%%%%%
00362 % Filter normalization (done in this order in normalize_filters)
00363 %%%%%%%%%%%
00364 model.SHIFT_FILTERS = logical(zeros(1,10)); % if You want to shift the filters by their center of mass
00365 model.ZERO_MEAN_FILTERS = logical(ones(1,10)); % if you want to make the filters zero mean before noramlization.
00366 model.NORMALIZE_FILTERS = logical(zeros(1,10)); % If you want to normalize filters by L2 norm.
00367 model.MAX_FILTERS = logical(ones(1,10)); % If you want to normalize filters by the max filter value for each feature map.
00368 model.GREEDY_FILTER_SHUTOFF = zeros(1,10,'single'); % if you want to greedily turn off filter planes that don't do much.
00369 % This value is a decimal fractin of the total number of input maps (1 being
00370 % 100% shutoff, 0 being don't shut off any).
00371 model.FILTER_CLIPPING=[0 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1]; % If you want to clip and at what value the abs(F)<FILTER_CLIPPING.
00372 %%%%%%%%%%%
00373 
00374 
00375 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00376 %% Experimental Features (do not modify as these are buggy).
00377 %%%%%%%%%%%
00378 % Reconstruction term gamma*||sum(conv(z_L,f)) - z_{L-1}||^2 weighting for each
00379 % layer. (experimental, leave at 0).
00380 model.gamma = [
00381     [0 0 0 0 0 0 0 0 0 0];       % Layer1
00382     [0 0 0 0 0 0 0 0 0 0];       % Layer2
00383     [0 0 0 0 0 0 0 0 0 0];       % Layer3
00384     [0 0 0 0 0 0 0 0 0 0];       % Layer4
00385     [0 0 0 0 0 0 0 0 0 0];       % Layer5
00386     [0 0 0 0 0 0 0 0 0 0];       % Layer6
00387     [0 0 0 0 0 0 0 0 0 0];       % Layer7
00388     [0 0 0 0 0 0 0 0 0 0];       % Layer8
00389     [0 0 0 0 0 0 0 0 0 0];       % Layer9
00390     [0 0 0 0 0 0 0 0 0 0];       % Layer10
00391     ];
00392 % A coefficient on the filter L2 regularization (leave at 1, not in papers)
00393 % Note used anymore, do not touch. (experimental, leave at 1)
00394 model.kappa = [
00395     [1 1 1 1 1 1 1 1 1 1];       % Layer1
00396     [1 1 1 1 1 1 1 1 1 1];       % Layer2Full
00397     [1 1 1 1 1 1 1 1 1 1];       % Layer3
00398     [1 1 1 1 1 1 1 1 1 1];       % Layer4
00399     [1 1 1 1 1 1 1 1 1 1];       % Layer5
00400     [1 1 1 1 1 1 1 1 1 1];       % Layer6
00401     [1 1 1 1 1 1 1 1 1 1];       % Layer7
00402     [1 1 1 1 1 1 1 1 1 1];       % Layer8
00403     [1 1 1 1 1 1 1 1 1 1];       % Layer9
00404     [1 1 1 1 1 1 1 1 1 1];       % Layer10
00405     ];
00406 % If set to 1, then the fitlers for that layer will be updated by the
00407 % reconstructions from layers above. Might not want this in very deep models.
00408 % Experimental, leave as lower left triangle.
00409 model.Fabove = [
00410     [1 0 0 0 0 0 0 0 0 0];       % Layer1
00411     [1 1 0 0 0 0 0 0 0 0];       % Layer2
00412     [1 1 1 0 0 0 0 0 0 0];       % Layer3
00413     [1 1 1 1 0 0 0 0 0 0];       % Layer4
00414     [1 1 1 1 1 0 0 0 0 0];       % Layer5
00415     [1 1 1 1 1 1 0 0 0 0];       % Layer6
00416     [1 1 1 1 1 1 1 0 0 0];       % Layer7
00417     [1 1 1 1 1 1 1 1 0 0];       % Layer8
00418     [1 1 1 1 1 1 1 1 1 0];       % Layer9
00419     [1 1 1 1 1 1 1 1 1 1];       % Layer10
00420     ];
00421 
00422 % This adds the lambda = lambda + ramp_lambda_amount at each iteration.
00423 model.ramp_lambda_amount = 0;
00424 
00425 %%%%%%%%%
00426 % Noising images
00427 % Noise, leave this as 'none' for no noise.
00428 model.noisetype = 'None (Reconstruct)';
00429 % If you want to update the y variable when reconstructing.
00430 model.UPDATE_INPUT = 0;
00431 % Lambda for the reconstruction error of the updated and input images.
00432 model.lambda_input = 1;
00433 
00434 % Phase specific pooling parameters.
00435 %%%%%%%%%%
00436 
00437 %%%%%%%%%%%
00438 % z0 map parameters, still fairly experimental and no longer supported
00439 %%%%%%%%%%%
00440 % Make the z0 filter size the same as the first layer's by default.
00441 model.z0_filter_size = model.filter_size(1);
00442 % The coefficient on the gradient(z0) term when training z0. (this may vary).
00443 model.psi = 1;
00444 % Check to determine if you even want to train the z0 map (while training z and f).
00445 model.TRAIN_Z0 = 0;
00446 %%%%%%%%%%%
00447 
00448 %%%%%%%%%%
00449 %% Selection stuff
00450 %%%%%%%%%%
00451 model.TIME_LAYER = 0;  % The layer in which time series modelling occurs. (0 for static images)
00452 model.prev_frames = 2; % The number of previous frames to condition on. (must have TIME_LAYER > 0)
00453 model.INFER_USING = 1:3; % The input maps to use for inference. Form is [1:2],[1 3 4], etc. Dont use end keyword.
00454 model.gen_frames = 10; % The number of new video frames to generate.
00455 model.LIMIT_TIME_LAYER_THROUGH_TIME = 0; % If 1 then top layer only connects to the same feature maps (from previous layer) through time, otherwise uses model.conamts{top_layer}
00456 %%%%%%%%%%
00457 
00458 %%%%%%%%%%
00459 %% Not Used (do not modify, kept in for backwards compatibility).
00460 %%%%%%%%%%
00461 model.RAMP_DOWN_AND_UP = 0; %switch to beta=beta/Bmultiplier after half way
00462 % The beta-norm on the dummy variable - feature map clamping.
00463 model.beta_norm = 2;
00464 % The alpha-normalization on the F's.
00465 model.alphaF = 2;
00466 %%%%%%%%%%
00467 
00468 %%%%%%%%%%
00469 %% GUI Specific fields (not included so do not modify)
00470 %%%%%%%%%%
00471 % The type of experiment you want to run (used by the gui).
00472 model.exptype = 'Train New Model';
00473 % The actual file to run the experiment at. Leave a space before first char
00474 model.expfile = ' trainAll';
00475 % The location where the job was run from. Leave a space before first char.
00476 model.machine = ' local_server';
00477 if(strcmp(ARCH,'MAC'))
00478     model.machine = ' laptop';
00479 else
00480     model.machine = ' local_server';
00481 end
00482 
00483 % The dataset directory (where to load images from for training/reconstruction).
00484 model.datadirectory = '/Datasets/Images/fruit_100_100/';
00485 % model.datadirectory = '/Datasets/Images/city_100_100/';
00486 % model.datadirectory = '/Datasets/Images/singles/test1/';
00487 
00488 % The model directory (used when loading a previous model).
00489 model.modeldirectory = '/Results/train/city_100_100/color_filters_9_45/Run_0/epoch25_layer1';
00490 % Where to save the results.
00491 model.savedirectory = '/Results/+';
00492 %%%%%%%%%
00493 
00494 
00495 
00496 
00497 % Load the previously set parameters (overwrites the above)
00498 % Uncomment this if you are adding new variables to the gui/model.
00499 if(EXPERIMENTAL)
00500     if(exist('gui_has_set_the_params.mat','file'))
00501         load gui_has_set_the_params
00502     end
00503 else
00504     if(exist('default_params','file'))
00505         load default_params
00506     elseif(exist('gui_has_set_the_params.mat','file'))
00507         load gui_has_set_the_params
00508     end
00509 end
00510 % model.modeldirectory = '';
00511 %% Force further initialization
00512 % model.exptype = 'Train New Model';
00513 % model.SUPPRESS_WARNINGS = 0;
00514 
00515 model.savedirectory = '/Results/+';
00516 % If you want to use the GPU (overrides the ipp setting).
00517 if(exist('startGPU.m','file') && exist('GPUstart.m','file'))
00518     model.USE_GPU = 1; % Checks if a gpu exists at start.
00519     if(exist([fileparts(which('GPUstart.m')) '/modules/mdz'],'dir')==0)
00520         fprintf('GPUmat modules required for DeconvNet Toolbox are not installed properly....using CPU\n');
00521         model.USE_GPU = 0;
00522     end
00523 else
00524     fprintf('You do not have the GPUmat modules installed so reverting to CPU implementation.\n');
00525     model.USE_GPU = 0;
00526 end
00527 
00528 model = backwards_compatible(model);
00529 
00530 
00531 
00532 
00533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00534 
00535 %%%%%%%%%%%%%%%%%%%FILTER%%%%%%%%%%%%%%%%%%%%%
00536 %% Construct GUI Components
00537 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00538 % Description of each function.
00539 hdescriptiontext = uicontrol('Style','text',...
00540     'String','This is where each parameter will be described. Click and edit any of the parameters below and then click the ''Save'' button to save them. Finally you will be told which file to run in MATLAB.',...
00541     'HorizontalAlignment','left',...
00542     'Position',[410,645,775,50]);
00543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00544 
00545 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00546 %% Construct the panel frames
00547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00548 hp1 = uipanel(fgui,'Title','Type of Experiment:                            Layers:',...
00549     'Position',[.01 .92 .32 0.07]);
00550 uipanel('Title','Preprocessing:',...
00551     'Position',[.01 .85 .32 0.07]);
00552 uipanel('Title','Training Setup:',...
00553     'Position',[.01 .67 .32 0.18]);
00554 uipanel('Title','Phase Specific Params:',...
00555     'Position',[.01 .36 .32 0.31]);
00556 uipanel('Title','Layer Specific Params:',...
00557     'Position',[.34 .36 .65 0.31]);
00558 halphabox = uipanel('Title','Alphas:',...
00559     'Position',[.34 .14 .08 0.22]);
00560 hlabmdabox = uipanel('Title','Lambdas (recon to y):',...
00561     'Position',[.01 .14 .32 0.22]);
00562 hvideobox = uipanel('Title','Video:',...
00563     'Position',[.34 .67 .32 0.1]);
00564 hBinitbox = uipanel('Title','Binit:',...
00565     'Position',[.42 .14 .08 0.22]);
00566 hkappabox = uipanel('Title','Kappas:',...
00567     'Position',[.50 .14 .08 0.22]);
00568 hBmultbox = uipanel('Title','Beta Multiplier:',...
00569     'Position',[.58 .14 .08 0.22]);
00570 hgammabox = uipanel('Title','Gammas (recon to pool_z):',...
00571     'Position',[.67 .14 .32 0.22]);
00572 hz0box = uipanel('Title','z0 Maps:',...
00573     'Position',[.34 .77 .32 0.09]);
00574 hFabovebox = uipanel('Title','Fabove:',...
00575     'Position',[.67 .66 .16 0.22]);
00576 uipanel('Title','Notes:',...
00577     'Position',[.83 .66 .16 0.22]);
00578 hupdateybox = uipanel('Title','Learn y Settings:',...
00579     'Position',[.34 .86 .32 0.07]);
00580 uipanel('Title','Save/Plot Settings:',...
00581     'Position',[.67 .01 .16 0.13]);
00582 hdirpanel = uipanel('Title','Directories:',...
00583     'Position',[.01 .01 .65 0.13]);
00584 uipanel('Title','Save/Load Params:',...
00585     'Position',[.84 .01 .15 0.13]);
00586 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00587 
00588 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00589 %% Type of Expermiment
00590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00591 if(EXPERIMENTAL)
00592     exptypestring = {'List Results','View Figures','Train Layer By Layer','Train New Model','Continue Training On Top','Train 2-Layer Joint Method','Top Down Visualize','Top Down Sampling','Reconstruct Layer By Layer','Reconstruct 2-Layer Joint Method','Reconstruct Using Trained Model','Generate Video','Load Params From Previous Model'};
00593 else
00594     exptypestring = {'Train New Model','Continue Training On Top','Reconstruct Using Trained Model','Load Params From Previous Model'};
00595 end
00596 % Setup dropdown for the experiment type.
00597 hexptype = uicontrol('Style','popupmenu',...
00598     'String',exptypestring,'Position',[15,650,235,25],...
00599     'Callback',{@hexptype_Callback});
00600 % Set the default for the experiment dropdown menu.
00601 set(hexptype,'Value',find(strcmp(get(hexptype,'String'),model.exptype)))
00602 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00603 % Callback for experiment type.
00604 %
00605 % @param source the gui component that called this.
00606 % @param eventdata relates to the event of activating the gui component.
00607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00608     function hexptype_Callback(source,eventdata)
00609         % Determine the selected data set.
00610         str = get(source, 'String');
00611         val = get(source,'Value');
00612         % Set current data to the selected data set.
00613         switch str{val};
00614             case 'List Results'
00615                 set(hdescriptiontext,'String','Recursively list the variables input for each model in folders below the input folder. Separate desired variables with commas.');
00616                 %                 model.modeldirectory = '/Results/train/notnature_100_100/color_filters_9_45/Run_8/';
00617                 model.datadirectory = 'alpha';
00618                 set(hdatadirectorytext,'String','Input Params:','Callback',[])
00619             case 'View Figures'
00620                 set(hdescriptiontext,'String','To view the saved figures for an experiment. Input "list" to recursively list available figures form input directory. Input "gui" to select the figure to open. Leaving Inputs blank plots all figures in the folder.');
00621                 %                 model.modeldirectory = '/Results/train2/fruit_100_100/color_filters_9_45/';
00622                 model.datadirectory = 'list recurse';
00623                 set(hdatadirectorytext,'String','Input Params:','Callback',[])
00624             case 'Train Layer By Layer' % User selects Peaks.
00625                 set(hdescriptiontext,'String','Train all the layers (one layer at a time) using the selected data set and parameters.');
00626                 model.expfile = ' train';
00627                 %                 model.datadirectory = '/Datasets/Images/notnature_100_100/';
00628                 model.modeldirectory = 'not used';
00629                 %                 model.PLOT_RESULTS = 0;
00630                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00631             case 'Train New Model' % User selects Peaks.
00632                 set(hdescriptiontext,'String','Train all the layers together using the selected data set and parameters. Multiple phases of traiing can also be used to train one layer in a phase or any combinations of layer in each phase.');
00633                 model.expfile = ' trainAll';
00634                 %                 model.datadirectory = '/Datasets/Images/notnature_100_100/';
00635                 model.modeldirectory = 'not used';
00636                 %                 model.PLOT_RESULTS = 0;
00637                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00638             case 'Continue Training On Top' % User selects Membrane.
00639                 set(hdescriptiontext,'String','Train additional layers of the model (on top of a previously trained model). Select the number of layers in the final model you want and the phases to train with, then the training will continue from the last trained layer/phase. The dataset used in the model and data directories must match.');
00640                 model.expfile = ' train_remaining_layers';
00641                 %                 model.modeldirectory = '/Results/train/kyoto_200_200_CROPS/color_filters_24/Run_1/epoch10_layer1.mat';
00642                 %                 model.datadirectory = '/Datasets/Images/city_100_100/';
00643                 model.image_frames{2}=1;
00644                 %                 model.PLOT_RESULTS = 0;
00645                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00646             case 'Train 2-Layer Joint Method' % User selects Peaks.
00647                 set(hdescriptiontext,'String','Train a 2-layer model using Yanns joint method of inferring the both layers feature maps and filters simultaneously.');
00648                 model.expfile = ' train2';
00649                 %                 model.datadirectory = '/Datasets/Images/notnature_100_100/';
00650                 model.modeldirectory = 'not used';
00651                 %                 model.PLOT_RESULTS = 0;
00652                 model.num_layers = 2;
00653                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00654             case 'Top Down Visualize' % User selects Membrane.
00655                 set(hdescriptiontext,'String','Visualize the filters in upper layers in pixel space. The layer specified in the data directory is where the visualization starts and moves downward.');
00656                 model.expfile = ' top_down';
00657                 %                 model.modeldirectory = '/Results/train/inside_city_train/color_filters_9_45/Run_2/epoch25_layer2';
00658                 model.datadirectory = 'not used';
00659                 %                 model.PLOT_RESULTS = 1;
00660                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00661             case 'Top Down Sampling' % User selects Membrane.
00662                 set(hdescriptiontext,'String','Visualize the filters in upper layers in pixel space when sampled from the models distribution. The layer specified in the data directory is where the visualization starts and moves downward.');
00663                 model.expfile = ' top_down_sampling';
00664                 %                 model.modeldirectory = '/Results/train/inside_city_train/color_filters_9_45/Run_2/epoch25_layer2';
00665                 model.datadirectory = 'not used';
00666                 %                 model.PLOT_RESULTS = 1;
00667                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00668             case 'Reconstruct Layer By Layer' % User selects Sinc.
00669                 set(hdescriptiontext,'String','Reconstruct the image using each layer below and including the input (Model Directory) layer. The layers below are automatically loaded. Note: when saving, it saves the zs so can do inference. If CONTRAST_NORMALIZE==none, then sets TRAIN_Z0 = 1.');
00670                 model.expfile = ' recon';
00671                 %                 model.modeldirectory = '/Results/train/city_100_100/color_filters_9_45/Run_0/epoch25_layer1';
00672                 %                 model.datadirectory =
00673                 %                 '/Datasets/Images/singles/test1/';
00674                 %                 model.PLOT_RESULTS = 1;
00675                 %                 model.SAVE_RESULTS = 5;
00676                 % If you just saved a model and now want to reconstruct with it,
00677                 % fill that in as the default model directory.
00678                 if(isempty(regexp(model.savedirectory,'+','ONCE')))
00679                     model.modeldirectory = strcat(model.savedirectory,'epoch##_phase#.mat');
00680                 end
00681                 %                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00682             case 'Reconstruct 2-Layer Joint Method' % User selects Sinc.
00683                 set(hdescriptiontext,'String','Reconstruct the image using both layers together. Model Directory should point to layer 2. The layers below are automatically loaded. Note: when saving, it saves the zs so can do inference. If CONTRAST_NORMALIZE==none, then sets TRAIN_Z0 = 1.');
00684                 model.expfile = ' recon2';
00685                 %                 model.modeldirectory = '/Results/train/';
00686                 %                 model.datadirectory = '/Datasets/';
00687                 %                 model.PLOT_RESULTS = 1;
00688                 %                 model.SAVE_RESULTS = 5;
00689                 % Copy last save to new reconstruction if it is not /Results/+
00690                 %                 if(isempty(regexp(model.savedirectory,'+','ONCE')))
00691                 %                     model.modeldirectory = strcat(model.savedirectory,'epoch##_layer#.mat');
00692                 %                 end
00693                 %                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00694             case 'Reconstruct Using Trained Model' % User selects Sinc.
00695                 set(hdescriptiontext,'String','Reconstruct the specified images (by inferring new corresponding featur emaps) using a trained model (Model Directory). The number of layers are specified by the model, but number of phases and inference parameters can be different and set in the gui.');
00696                 model.expfile = ' reconAll';
00697                 %                 model.modeldirectory = '/Results/train/';
00698                 %                 model.datadirectory = '/Datasets/';
00699                 %                 model.PLOT_RESULTS = 1;
00700                 %                 model.SAVE_RESULTS = 0;
00701                 % Copy last save to new reconstruction if it is not /Results/+
00702                 %                 if(isempty(regexp(model.savedirectory,'+','ONCE')))
00703                 %                     model.modeldirectory = strcat(model.savedirectory,'epoch##_layer#.mat');
00704                 %                 end
00705                 %                 set(hdatadirectorytext,'String','Data Dir:','Callback',{@hdatadirectorytext_Callback})
00706             case 'Generate Video'
00707                 set(hdescriptiontext,'String','Generates novel motion using a previously trained model on time series data (must be that TIME_LAYER~=0).');
00708                 model.expfile = ' gen_video';
00709                 %                 model.modeldirectory = '/Results/train/';
00710                 %                 model.datadirectory = '/Datasets/';
00711                 %                 model.PLOT_RESULTS = 1;
00712                 %                 model.SAVE_RESULTS = 0;
00713                 %                 if(isempty(regexp(model.savedirectory,'+','ONCE')))
00714                 %                     model.modeldirectory = strcat(model.savedirectory,'epoch##_layer#.mat');
00715                 %                 end
00716                 %                 set(hdatadirectorytext,'String','Data
00717                 %                 Dir:','Callback',{@hdatadirectorytext_Callback})
00718             case 'Load Params From Previous Model'
00719                 set(hdescriptiontext,'String','Loads the model parameters from a previous run into the gui (so you don''t have to reset all the parameters if you find some that work well in previous runs).');
00720                 
00721         end
00722         % Set the model's experment type.
00723         model.exptype = str{val};
00724         
00725         % The previous save directory should be overwritten.
00726         model.savedirectory = '/Results/+';
00727         
00728         % Update all the defaults for the selected experiment.
00729         update_defaults
00730     end
00731 
00732 %%%%%%%%%%
00733 % Setup dropdown for the number of layers.
00734 hnum_layers = uicontrol('Style','popupmenu',...
00735     'String',{'1','2','3','4','5','6','7','8','9','10'},...
00736     'Position',[250,650,60,25],...
00737     'Callback',{@hnum_layers_Callback});
00738 % Set the default for the number of layers dropdown menu.
00739 set(hnum_layers,'Value',find(strcmp(get(hnum_layers,'String'),int2str(model.num_layers))))
00740 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00741 % Callback for setting the number of layers to use.
00742 %
00743 % @param source the gui component that called this.
00744 % @param eventdata relates to the event of activating the gui component.
00745 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00746     function hnum_layers_Callback(source,eventdata)
00747         set(hdescriptiontext,'String','Sets the number of layers the model will be constructed as or is constructed as.');
00748         % Determine the selected data set.
00749         val = get(source,'Value');
00750         
00751         % Set the number of layers.
00752         model.num_layers = val;
00753         
00754         update_visibility;
00755     end
00756 
00757 
00758 
00759 %%%%%%%%%%
00760 % Setup dropdown for the number of layers.
00761 hnum_phases = uicontrol('Style','popupmenu',...
00762     'String',{'1','2','3','4','5','6','7','8','9','10'},...
00763     'Position',[325,650,60,25],...
00764     'Callback',{@hnum_phases_Callback});
00765 % Set the default for the number of layers dropdown menu.
00766 set(hnum_phases,'Value',find(strcmp(get(hnum_phases,'String'),int2str(model.num_phases))))
00767 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00768 % Callback for setting the number of layers to use.
00769 %
00770 % @param source the gui component that called this.
00771 % @param eventdata relates to the event of activating the gui component.
00772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00773     function hnum_phases_Callback(source,eventdata)
00774         set(hdescriptiontext,'String','Sets the number of phases to conduct during training.');
00775         % Determine the selected data set.
00776         val = get(source,'Value');
00777         
00778         % Set the number of layers.
00779         model.num_phases = val;
00780         
00781         update_visibility;
00782     end
00783 
00784 %% Train the 1st layer in Yann's approach first?
00785 hinit1stcheck = uicontrol('Style','checkbox',...
00786     'String','1-Lay Init',...
00787     'Position',[590,650,95,25],...
00788     'Callback',{@hinit1stcheck_Callback});
00789 % Set the check for color or gray images.
00790 set(hinit1stcheck,'Value',model.LAYER1_FIRST);
00791 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00792 % Callback for if you want to initialize the first layer when using Yann's two
00793 % layer inference method.
00794 %
00795 % @param source the gui component that called this.
00796 % @param eventdata relates to the event of activating the gui component.
00797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00798     function hinit1stcheck_Callback(hObject,eventdata)
00799         set(hdescriptiontext,'String','In certain training paradigms, it might be useful to initialize the first layer with training before doign joint training.');
00800         if (get(hObject,'Value') == get(hObject,'Max'))
00801             % Checkbox is checked-take approriate action
00802             model.LAYER1_FIRST = 1;
00803         else
00804             % Checkbox is not checked-take approriate action
00805             model.LAYER1_FIRST = 0;
00806         end
00807     end
00808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00809 
00810 
00811 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00812 %% Preprocessing of the images.
00813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00814 % Use color images?
00815 hcolorcheck = uicontrol('Style','popupmenu',...
00816     'String',{'gray','rgb','ycbcr','hsv'},...
00817     'Position',[25,600,80,25],...
00818     'Callback',[email protected]_Callback});
00819 % Set the check for color or gray images.
00820 set(hcolorcheck,'Value',find(strcmp(get(hcolorcheck,'String'),model.COLOR_IMAGES)))
00821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00822 % Callback for if you want to use color images.
00823 %
00824 % @param source the gui component that called this.
00825 % @param eventdata relates to the event of activating the gui component.
00826 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00827     function hcolorcheck_Callback(source,eventdata)
00828         set(hdescriptiontext,'String','Determines the colorspace or whether to convert the images to grayscale. Grayscale will have a single input map in layer 1 while the others will have 3 input maps in layer 1.');
00829         % Determine the selected data set.
00830         str = get(source, 'String');
00831         
00832         val = get(source,'Value');
00833         
00834         % Set the number of layers.
00835         model.COLOR_IMAGES = str{val};
00836         switch str{val}
00837             case 'gray'
00838                 model.num_input_maps(1) = 1;
00839             otherwise
00840                 model.num_input_maps(1) = 3;
00841         end
00842         hupdate_conmats_Callback([],[])
00843         update_visibility;
00844     end
00845 
00846 
00847 %%%%%%%%%%
00848 % Variance threshold the Images.
00849 hzeromeancheck = uicontrol('Style','checkbox',...
00850     'String','Zero Mean',...
00851     'Position',[100,600,100,25],...
00852     'Callback',[email protected]_Callback});
00853 % Set the check for variance thresholding the images.
00854 set(hzeromeancheck,'Value',model.ZERO_MEAN);
00855 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00856 % Callback for if you want to normalize the images to zero mean (or other such
00857 % normalizations).
00858 %
00859 % @param source the gui component that called this.
00860 % @param eventdata relates to the event of activating the gui component.
00861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00862     function hzeromeancheck_Callback(hObject,eventdata)
00863         set(hdescriptiontext,'String','Adds a zero mean per pixel (over the dataset) preprocessing step on the images..');
00864         if (get(hObject,'Value') == get(hObject,'Max'))
00865             % Checkbox is checked-take approriate action
00866             model.ZERO_MEAN = 1;
00867         else
00868             % Checkbox is not checked-take approriate action
00869             model.ZERO_MEAN = 0;
00870         end
00871     end
00872 
00873 %%%%%%%%%%
00874 % Variance threshold the Images.
00875 hsquarecheck = uicontrol('Style','checkbox',...
00876     'String','Square',...
00877     'Position',[190,600,70,25],...
00878     'Callback',[email protected]_Callback});
00879 % Set the check for variance thresholding the images.
00880 set(hsquarecheck,'Value',model.SQUARE_IMAGES);
00881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00882 % Callback for if you want to normalize the images to zero mean (or other such
00883 % normalizations).
00884 %
00885 % @param source the gui component that called this.
00886 % @param eventdata relates to the event of activating the gui component.
00887 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00888     function hsquarecheck_Callback(hObject,eventdata)
00889         set(hdescriptiontext,'String','Squares the images if checked. This requires each image to have a common maximum dimension (though this could be in x or y differently for each image).');
00890         if (get(hObject,'Value') == get(hObject,'Max'))
00891             % Checkbox is checked-take approriate action
00892             model.SQUARE_IMAGES = 1;
00893         else
00894             % Checkbox is not checked-take approriate action
00895             model.SQUARE_IMAGES = 0;
00896         end
00897     end
00898 
00899 %%%%%%%%%%
00900 % Contrast normalize the image?
00901 if(EXPERIMENTAL)
00902     exp_cn = {'none','local_cn','laplacian_cn','box_cn','PCA_whitening','ZCA_image_whitening','ZCA_patch_whitening','inv_f_whitening','sep_mean'};
00903 else
00904     exp_cn = {'none','local_cn','laplacian_cn'};
00905 end
00906 hcontrastcheck = uicontrol('Style','popupmenu',...
00907     'String',exp_cn,...
00908     'Position',[260,600,130,25],...
00909     'Callback',[email protected]_Callback});
00910 % Set the check for contrast normalizing the image.
00911 set(hcontrastcheck,'Value',find(strcmp(get(hcontrastcheck,'String'),model.CONTRAST_NORMALIZE)))
00912 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00913 % Callback for if you want to Contrast Normalize (whiten) the iamges.
00914 %
00915 % @param source the gui component that called this.
00916 % @param eventdata relates to the event of activating the gui component.
00917 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00918     function hconstrastcheck_Callback(source,eventdata)
00919         set(hdescriptiontext,'String','Contrast normalize/whiten the images with various types of contrast normalization before training.');
00920         % Determine the selected data set.
00921         str = get(source, 'String');
00922         
00923         val = get(source,'Value');
00924         
00925         model.CONTRAST_NORMALIZE = str{val};
00926     end
00927 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00928 
00929 
00930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00931 %% Training Parameters
00932 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00933 %%%%%%%%%%
00934 %%%%%%%%%%
00935 %% Draw images at random
00936 himageordercheck = uicontrol('Style','checkbox',...
00937     'String','Rand Order',...
00938     'Position',[25,550,100,25],...
00939     'Callback',[email protected]_Callback});
00940 % Set the check for contrast normalizing the image.
00941 set(himageordercheck,'Value',model.RANDOM_IMAGE_ORDER);
00942 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00943 % Callback for randomly ordereing input images during training/inference.
00944 %
00945 % @param source the gui component that called this.
00946 % @param eventdata relates to the event of activating the gui component.
00947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00948     function himageordercheck_Callback(hObject,eventdata)
00949         set(hdescriptiontext,'String','If checked, then images from the training set are selected in a trandom order each epoch.');
00950         if (get(hObject,'Value') == get(hObject,'Max'))
00951             % Checkbox is checked-take approriate action
00952             model.RANDOM_IMAGE_ORDER = 1;
00953         else
00954             % Checkbox is not checked-take approriate action
00955             model.RANDOM_IMAGE_ORDER = 0;
00956         end
00957     end
00958 
00959 %%%%%%%%
00960 %% Number of computation threads to use
00961 hcompthreadstext = uicontrol('Style','text',...
00962     'String','Threads:',...
00963     'HorizontalAlignment','left',...
00964     'Position',[130,555,70,15]);
00965 % Text field to set the data directory.
00966 hcompthreads = uicontrol('Style','edit',...
00967     'String','100',...
00968     'HorizontalAlignment','left',...
00969     'BackgroundColor','white',...
00970     'Position',[200,550,40,25],...
00971     'Callback',[email protected]_Callback});
00972 % Set the data directory default.
00973 set(hcompthreads,'String',model.comp_threads);
00974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00975 % Callback for setting the number of computation threads for MATLAB to use.
00976 %
00977 % @param source the gui component that called this.
00978 % @param eventdata relates to the event of activating the gui component.
00979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
00980     function hcompthreads_Callback(hObject, eventdata, handles)
00981         set(hdescriptiontext,'String','This is the number of computation threads to be set in MaxNumCompThreads (for use with CPU mode).');
00982         % Display surf plot of the currently selected data.
00983         user_string = get(hObject,'String');
00984         model.comp_threads = str2double(user_string);
00985     end
00986 
00987 % % IPP LIBRARIES
00988 % hippcheck = uicontrol('Style','checkbox',...
00989 %     'String','IPP Libraries',...
00990 %     'Position',[280,550,115,25],...
00991 %     'Callback',[email protected]_Callback});
00992 % % Set the check for contrast normalizing the image.
00993 % set(hippcheck,'Value',model.USE_IPP);
00994 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
00995 % % Callback for updating the filters in batches (of images).
00996 % %
00997 % % @param source the gui component that called this.
00998 % % @param eventdata relates to the event of activating the gui component.
00999 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01000 %     function hippcheck_Callback(hObject,eventdata)
01001 %         set(hdescriptiontext,'String','If set, then the IPP libraries will be used. Otherwise all functions will be from MATLAB.');
01002 %         if (get(hObject,'Value') == get(hObject,'Max'))
01003 %             % Checkbox is checked-take approriate action
01004 %             model.USE_IPP = 1;
01005 %             if(~exist(strcat('ipp_conv2.',mexext),'file'))
01006 %                 fprintf('You don not have the compiled versions of the IPP Convolutions Toolbox therefore reverting to slower MATLAB only implementation.\n')
01007 %                 model.USE_IPP = 0;
01008 %             end
01009 %         else
01010 %             % Checkbox is not checked-take approriate action
01011 %             model.USE_IPP = 0;
01012 %         end
01013 %     end
01014 
01015 
01016 % GPUMAT LIBRARIES
01017 hgpucheck = uicontrol('Style','checkbox',...
01018     'String','Use GPU',...
01019     'Position',[280,550,115,25],...
01020     'Callback',[email protected]_Callback});
01021 % Set the check for contrast normalizing the image.
01022 set(hgpucheck,'Value',model.USE_GPU);
01023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01024 % Callback for updating the filters in batches (of images).
01025 %
01026 % @param source the gui component that called this.
01027 % @param eventdata relates to the event of activating the gui component.
01028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01029     function hgpucheck_Callback(hObject,eventdata)
01030         set(hdescriptiontext,'String','If set, then the GPUmat libraries will be used. Otherwise all functions will be on CPU.');
01031         if (get(hObject,'Value') == get(hObject,'Max'))
01032             % Checkbox is checked-take approriate action
01033             model.USE_GPU = 1;
01034         else
01035             % Checkbox is not checked-take approriate action
01036             model.USE_GPU = 0;
01037         end
01038     end
01039 
01040 
01041 
01042 
01043 %%%%%%%%
01044 %% Number of computation threads to use
01045 hemailtext = uicontrol('Style','text',...
01046     'String','Email:',...
01047     'HorizontalAlignment','left',...
01048     'Position',[1000,620,40,15]);
01049 % Text field to set the data directory.
01050 hemail = uicontrol('Style','edit',...
01051     'String','100',...
01052     'HorizontalAlignment','left',...
01053     'BackgroundColor','white',...
01054     'Position',[1045,615,145,25],...
01055     'Callback',[email protected]_Callback});
01056 % Set the data directory default.
01057 set(hemail,'String',model.EMAIL_NOTIFICATIONS);
01058 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01059 % Callback for setting the number of computation threads for MATLAB to use.
01060 %
01061 % @param source the gui component that called this.
01062 % @param eventdata relates to the event of activating the gui component.
01063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01064     function hemail_Callback(hObject, eventdata, handles)
01065         user_string = get(hObject,'String');
01066         set(hdescriptiontext,'String',['This is the email address (' user_string ') to be notified at at the start or end of saved runs.']);
01067         % Display surf plot of the currently selected data.
01068         model.EMAIL_NOTIFICATIONS = user_string;
01069     end
01070 
01071 %% Train the 1st layer in Yann's approach first?
01072 hsuppresswarn = uicontrol('Style','checkbox',...
01073     'String','Suppress Warnings',...
01074     'Position',[1000,620,185,25],...
01075     'Callback',{@hsuppresswarn_Callback});
01076 % Set the check for color or gray images.
01077 set(hsuppresswarn,'Value',model.LAYER1_FIRST);
01078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01079 % Callback for if you want to initialize the first layer when using Yann's two
01080 % layer inference method.
01081 %
01082 % @param source the gui component that called this.
01083 % @param eventdata relates to the event of activating the gui component.
01084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01085     function hsuppresswarn_Callback(hObject,eventdata)
01086         set(hdescriptiontext,'String','If checked, warnings create from the included toolboxes will be turned off.');
01087         if (get(hObject,'Value') == get(hObject,'Max'))
01088             % Checkbox is checked-take approriate action
01089             model.SUPPRESS_WARNINGS = 1;
01090         else
01091             % Checkbox is not checked-take approriate action
01092             model.SUPPRESS_WARNINGS = 0;
01093         end
01094     end
01095 
01096 
01097 
01098 %% Draw images at random
01099 hkeypresscheck = uicontrol('Style','checkbox',...
01100     'String','Show Keypress',...
01101     'Position',[807,14,145,25],...
01102     'Callback',[email protected]_Callback});
01103 % Set the check for contrast normalizing the image.
01104 set(hkeypresscheck,'Value',model.SHOW_KEYPRESS);
01105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01106 % Callback for randomly ordereing input images during training/inference.
01107 %
01108 % @param source the gui component that called this.
01109 % @param eventdata relates to the event of activating the gui component.
01110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01111     function hkeypresscheck_Callback(hObject,eventdata)
01112         set(hdescriptiontext,'String','If checked, then figure(123) will be displays and pressing ''s'' will set a breakpoint on the fly.');
01113         if (get(hObject,'Value') == get(hObject,'Max'))
01114             % Checkbox is checked-take approriate action
01115             model.SHOW_KEYPRESS = 1;
01116         else
01117             % Checkbox is not checked-take approriate action
01118             model.SHOW_KEYPRESS = 0;
01119         end
01120     end
01121 
01122 
01123 
01124 
01125 
01126 
01127 
01128 
01129 %%%%%%%%
01130 %% Threshold the gradients so they don't go wild.
01131 hthresholdtext = uicontrol('Style','text',...
01132     'String','Grad Thresh:',...
01133     'HorizontalAlignment','left',...
01134     'Position',[25,475,90,15]);
01135 % Text field to set the data directory.
01136 hthreshold = uicontrol('Style','edit',...
01137     'String','0.01',...
01138     'HorizontalAlignment','left',...
01139     'BackgroundColor','white',...
01140     'Position',[115,475,90,25],...
01141     'Callback',{@hthreshold_Callback});
01142 % Set the data directory default.
01143 set(hthreshold,'String',model.grad_threshold);
01144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01145 % Callback for thresholding the gradients at a certain level.
01146 %
01147 % @param source the gui component that called this.
01148 % @param eventdata relates to the event of activating the gui component.
01149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01150     function hthreshold_Callback(hObject, eventdata, handles)
01151         set(hdescriptiontext,'String','Threshold the gradients so that numerical limitations are avoided.');
01152         % Display surf plot of the currently selected data.
01153         user_string = get(hObject,'String');
01154         model.grad_threshold = str2double(user_string);
01155     end
01156 
01157 
01158 %%%%%%%%
01159 %% Number of times to run the minimization at each step.
01160 hminiterationstext = uicontrol('Style','text',...
01161     'String','Filter Iters:',...
01162     'HorizontalAlignment','left',...
01163     'Position',[25,525,90,15]);
01164 % Text field to set the data directory.
01165 hminiterations = uicontrol('Style','edit',...
01166     'String','100',...
01167     'HorizontalAlignment','left',...
01168     'BackgroundColor','white',...
01169     'Position',[115,525,90,25],...
01170     'Callback',{@hminiterations_Callback});
01171 % Set the data directory default.
01172 set(hminiterations,'String',model.min_iterations);
01173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01174 % Callback for setting the number of conjugate gradient updates.
01175 %
01176 % @param source the gui component that called this.
01177 % @param eventdata relates to the event of activating the gui component.
01178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01179     function hminiterations_Callback(hObject, eventdata, handles)
01180         set(hdescriptiontext,'String','This is the number of iterations that either minimize or conjugate gradient runs for at each step of the optimization.');
01181         % Display surf plot of the currently selected data.
01182         user_string = get(hObject,'String');
01183         model.min_iterations = str2double(user_string);
01184     end
01185 
01186 %%%%%%%%
01187 %% Number of times to run the minimization at each step.
01188 hdisperrortext = uicontrol('Style','text',...
01189     'String','Disp Errs:',...
01190     'HorizontalAlignment','left',...
01191     'Position',[25,500,90,15]);
01192 % Text field to set the data directory.
01193 hdisperror = uicontrol('Style','edit',...
01194     'String','100',...
01195     'HorizontalAlignment','left',...
01196     'BackgroundColor','white',...
01197     'Position',[115,500,90,25],...
01198     'Callback',{@hdisperror_Callback});
01199 % Set the data directory default.
01200 set(hdisperror,'String',model.DISPLAY_ERRORS);
01201 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01202 % Callback for displaying errors in standard out.
01203 %
01204 % @param source the gui component that called this.
01205 % @param eventdata relates to the event of activating the gui component.
01206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01207     function hdisperror_Callback(hObject, eventdata, handles)
01208         set(hdescriptiontext,'String','Set if you want to display the errors (do the top down pass) or not. The number is how many epochs you display it. It may be faster if you dont display at all (set to 0).');
01209         % Display surf plot of the currently selected data.
01210         user_string = get(hObject,'String');
01211         model.DISPLAY_ERRORS = str2double(user_string);
01212     end
01213 
01214 
01215 %%%
01216 % Ramp Lambda
01217 hramplambdatext = uicontrol('Style','text',...
01218     'String','Ramp Lambda:',...
01219     'HorizontalAlignment','left',...
01220     'Position',[210,475,100,15]);
01221 % Text field to set the data directory.
01222 hramplambda = uicontrol('Style','edit',...
01223     'String','100',...
01224     'HorizontalAlignment','left',...
01225     'BackgroundColor','white',...
01226     'Position',[300,475,90,25],...
01227     'Callback',{@hramplambda_Callback});
01228 % Set the data directory default.
01229 set(hramplambda,'String',model.ramp_lambda_amount);
01230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01231 % Callback for setting a nowmalization on beta. (not used)
01232 %
01233 % @param source the gui component that called this.
01234 % @param eventdata relates to the event of activating the gui component.
01235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01236     function hramplambda_Callback(hObject, eventdata, handles)
01237         set(hdescriptiontext,'String','The amount to ramp lambda up at each epoch. If ramp_lambda_amount>0 lambda_end=lambda*ramp_lambda_amount;');
01238         % Display surf plot of the currently selected data.
01239         user_string = get(hObject,'String');
01240         model.ramp_lambda_amount = str2double(user_string);
01241     end
01242 
01243 %%%%%%%%
01244 %% Batch Size
01245 hbatchsizetext = uicontrol('Style','text',...
01246     'String','Batch Size:',...
01247     'HorizontalAlignment','left',...
01248     'Position',[210,500,90,15]);
01249 % Text field to set the data directory.
01250 hbatchsize = uicontrol('Style','edit',...
01251     'String','0.01',...
01252     'HorizontalAlignment','left',...
01253     'BackgroundColor','white',...
01254     'Position',[300,500,90,25],...
01255     'Callback',{@hbatchsize_Callback});
01256 % Set the data directory default.
01257 set(hbatchsize,'String',model.batch_size);
01258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01259 % Callback for setting the number of images to use in the batches. This has no
01260 % effect if batch_filters is set to FALSE.
01261 %
01262 % @param source the gui component that called this.
01263 % @param eventdata relates to the event of activating the gui component.
01264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01265     function hbatchsize_Callback(hObject, eventdata, handles)
01266         set(hdescriptiontext,'String','Sets the batch size for the training. There will be num_images/batch_size number of such batches.');
01267         % Display surf plot of the currently selected data.
01268         user_string = get(hObject,'String');
01269         model.batch_size = str2double(user_string);
01270     end
01271 
01272 %%%
01273 % Frame selection
01274 hframestext = uicontrol('Style','text',...
01275     'String','Frames:',...
01276     'HorizontalAlignment','left',...
01277     'Position',[210,525,90,15]);
01278 % Text field to set the data directory.
01279 hframes1 = uicontrol('Style','edit',...
01280     'String','100',...
01281     'HorizontalAlignment','left',...
01282     'BackgroundColor','white',...
01283     'Position',[300,525,30,25],...
01284     'Callback',{@hframes1_Callback});
01285 % Set the data directory default.
01286 set(hframes1,'String',model.image_frames{1});
01287 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01288 % Callback for setting the kappa coefficient on layer 1 regularizations.
01289 %
01290 % @param source the gui component that called this.
01291 % @param eventdata relates to the event of activating the gui component.
01292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01293     function hframes1_Callback(hObject, eventdata, handles)
01294         set(hdescriptiontext,'String','Frames to select out of all the video frames input. This is of the form (A:B:C), this being A.');
01295         % Display surf plot of the currently selected data.
01296         user_string = get(hObject,'String');
01297         if(strcmp(user_string,'end'))
01298             model.image_frames{1} = user_string;
01299         else
01300             model.image_frames{1} = str2double(user_string);
01301         end
01302     end
01303 
01304 % Text field to set the data directory.
01305 hframes2 = uicontrol('Style','edit',...
01306     'String','100',...
01307     'HorizontalAlignment','left',...
01308     'BackgroundColor','white',...
01309     'Position',[330,525,30,25],...
01310     'Callback',{@hframes2_Callback});
01311 % Set the data directory default.
01312 set(hframes2,'String',model.image_frames{2});
01313 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01314 % Callback for setting the kappa coefficient on layer 1 regularizations.
01315 %
01316 % @param source the gui component that called this.
01317 % @param eventdata relates to the event of activating the gui component.
01318 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01319     function hframes2_Callback(hObject, eventdata, handles)
01320         set(hdescriptiontext,'String','Frames to select out of all the video frames input. This is of the form (A:B:C), this being B.');
01321         % Display surf plot of the currently selected data.
01322         user_string = get(hObject,'String');
01323         if(strcmp(user_string,'end'))
01324             model.image_frames{2} = user_string;
01325         else
01326             model.image_frames{2} = str2double(user_string);
01327         end
01328     end
01329 
01330 % Text field to set the data directory.
01331 hframes3 = uicontrol('Style','edit',...
01332     'String','100',...
01333     'HorizontalAlignment','left',...
01334     'BackgroundColor','white',...
01335     'Position',[360,525,30,25],...
01336     'Callback',{@hframes3_Callback});
01337 % Set the data directory default.
01338 set(hframes3,'String',model.image_frames{3});
01339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01340 % Callback for setting the kappa coefficient on layer 1 regularizations.
01341 %
01342 % @param source the gui component that called this.
01343 % @param eventdata relates to the event of activating the gui component.
01344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01345     function hframes3_Callback(hObject, eventdata, handles)
01346         set(hdescriptiontext,'String','Frames to select out of all the video frames input. This is of the form (A:B:C), this being C.');
01347         % Display surf plot of the currently selected data.
01348         user_string = get(hObject,'String');
01349         if(strcmp(user_string,'end'))
01350             model.image_frames{3} = user_string;
01351         else
01352             model.image_frames{3} = str2double(user_string);
01353         end
01354     end
01355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01356 
01357 
01358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01359 %% Phase Specific Parameters
01360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01361 % Text field to set the data directory.
01362 A = cell(10,6);
01363 % Make logical element logical.
01364 for i=1:10 %#ok<*FXUP>
01365     A{i,1} = model.maxepochs(i);
01366     A{i,2} = model.betaT(i);
01367     A{i,3} = model.SUBSAMPLING_UPDATES(i);
01368     A{i,4} = model.INFERENCE_TYPE{i};
01369     A{i,5} = model.LEARNING_TYPE{i};
01370 end
01371 if(EXPERIMENTAL)
01372     exp_inference = {'CG','ISTA','FISTA','APPROX','SHRINK'};
01373     exp_learning = {'CG','ISTA','FISTA'};
01374 else
01375     exp_inference = {'CG','ISTA','FISTA'};
01376     exp_learning = {'CG','ISTA','FISTA'};
01377 end
01378 hphasespecifictable = uitable('Parent',fgui,...
01379     'Data',A,...
01380     'RowName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01381     'ColumnName',{'Epochs','BetaT','P/UnP','Infer','Learning','PThresh'},...
01382     'Position',[15,253,380,200],...
01383     'ColumnEditable',[true true true true true true true true true true],...
01384     'ColumnWidth',{50,50,50,75,75,75},...
01385     'CellEditCallback',{@hphasespecifictable_Callback},...
01386     'ColumnFormat',{'numeric','numeric','numeric',exp_inference,exp_learning,'numeric'});
01387 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01388 % Callback for setting the phase specific of all layer.
01389 %
01390 % @param source the gui component that called this.
01391 % @param eventdata relates to the event of activating the gui component.
01392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01393     function hphasespecifictable_Callback(source,eventdata)
01394         switch(eventdata.Indices(2))  % Switch based on row.
01395             case 1 % maxepochs
01396                 set(hdescriptiontext,'String',sprintf('This is the number of epochs through the training set for phase %d.',eventdata.Indices(2)));
01397                 model.maxepochs(eventdata.Indices(1)) = eventdata.NewData;
01398             case 2 % beta iterations
01399                 set(hdescriptiontext,'String',sprintf('This is the number of ISTA iterations per epoch (was beta iterations for continuation) for phase %d.',eventdata.Indices(2)));
01400                 model.betaT(eventdata.Indices(1)) = eventdata.NewData;
01401             case 3 % subsampling update on top layer
01402                 set(hdescriptiontext,'String',sprintf('This determines if you want to update the top level by pooling/unpooling each iteration for phase %d. Leave at default of 3.',eventdata.Indices(2)));
01403                 model.SUBSAMPLING_UPDATES(eventdata.Indices(1)) = eventdata.NewData;
01404             case 4 % type of inference to use.
01405                 set(hdescriptiontext,'String',sprintf('The type of inference for phase %d will be %s.',eventdata.Indices(2),eventdata.NewData));
01406                 model.INFERENCE_TYPE{eventdata.Indices(1)} = eventdata.NewData;
01407             case 5 % type of learning to use.
01408                 set(hdescriptiontext,'String',sprintf('The type of learning for phase %d will be %s.',eventdata.Indices(2),eventdata.NewData));
01409                 model.LEARNING_TYPE{eventdata.Indices(1)} = eventdata.NewData;
01410         end
01411         disp(model);
01412     end
01413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01414 
01415 
01416 
01417 
01418 
01419 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01420 %% Layer Specific Parameters
01421 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01422 % Text field to set the data directory.
01423 A = cell(10,17);
01424 for i=1:10
01425     A{i,1} = model.num_feature_maps(i);
01426     A{i,2} = model.filter_size(i,1);
01427     A{i,3} = model.filter_size(i,2);
01428     A{i,4} = model.norm_types{i};
01429     temp = model.norm_sizes{i};
01430     A{i,5} = temp(1);
01431     A{i,6} = temp(2);
01432     A{i,7} = temp(3);
01433     A{i,8} = temp(4);
01434     A{i,9} = temp(5);
01435     A{i,10} = temp(5);
01436     A{i,11} = model.conmat_types{i};
01437     A{i,12} = model.SHIFT_FILTERS(i); % if You want to shift the filters by their center of mass
01438     A{i,13} = model.ZERO_MEAN_FILTERS(i); % if you want to make the filters zero mean before noramlization.
01439     A{i,14} = model.NORMALIZE_FILTERS(i); % If you want to normalize filters by L2 norm.
01440     A{i,15} = model.MAX_FILTERS(i); % If you want to normalize filters by the max filter value for each feature map.
01441     A{i,16} = model.GREEDY_FILTER_SHUTOFF(i); % if you want to greedily turn off filter planes that don't do much.
01442     A{i,17} = model.FILTER_CLIPPING(i);
01443 end
01444 
01445 if(EXPERIMENTAL) % More pooling types are unlocked.
01446     allowed_pooling = {'None','Max','Max3','Max4','OrderMax','Avg','Avg3','Avg4','MaxAvg3','Maxes3','ConvMax','ConvMax3','MaxCN','Max3CN','Maxes3CN','AbsMax','AbsMax3','MaxAbs','Max3Abs','AbsAvg','MaxZero','Max3Zero','Maxes3Zero','SplitMax','SplitKMax','MaxPCA','SplitMaxPCA','Dess3'};
01447 else
01448     allowed_pooling = {'None','Max','Max3','Avg','Avg3','Maxes3','AbsMax','AbsMax3','MaxAbs','Max3Abs','AbsAvg','Dess3'};
01449 end
01450 
01451 
01452 % A = mat2cell([model.num_feature_maps;model.filter_size;model.conmats_types;model.norm_types;model.norm_sizes]',ones(1,10),ones(1,4));
01453 hlayerspecifictable = uitable('Parent',fgui,...
01454     'Data',A,...
01455     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01456     'ColumnName',{'# z Maps','F_x','F_y','Pool Type','P_1','P_2','P_3','Win x (P_4)','Win y','Win k','Conmat','Shift F','Zero Mean F','Norm F','Norm Max F','Greedy F Off','Clip F'},...
01457     'Position',[412,253,770,200],...
01458     'ColumnWidth',{50,40,40,75,40,40,40,40,40,40,200},...
01459     'ColumnEditable',[true true true true true true true true true true true true true true true true true],...
01460     'CellEditCallback',{@hlayerspecifictable_Callback},...
01461     'ColumnFormat',{'numeric','numeric','numeric',...
01462     allowed_pooling,...
01463     'numeric','numeric','numeric','numeric','numeric','numeric',...
01464     {'Full','Exp','Singles','Singles and Some Doubles','Singles and All Doubles','Singles and Random Doubles',...
01465     'Some Doubles','All Doubles','Random Doubles',...
01466     'Some Triples','All Triples','Random Triples','Random Quadruples',...
01467     'Singles, Some Doubles, and Some Triples',...
01468     'Singles, All Doubles, and Some Triples',...
01469     'Singles, Random Doubles, and Some Triples',...
01470     'Singles, Some Doubles, and Random Triples',...
01471     'Singles, All Doubles, and Random Triples',...
01472     'Singles, Random Doubles, and Random Triples',...
01473     'Singles, All Doubles, and All Triples',...
01474     'Some of each (starting with singles)',...
01475     'Some of each (starting with doubles)',...
01476     'Even Number of Rand Sing,Doub,Trip'},'logical','logical','logical','logical','numeric','numeric'});
01477 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01478 % Callback for setting the lambda coefficients of all layer.
01479 %
01480 % @param source the gui component that called this.
01481 % @param eventdata relates to the event of activating the gui component.
01482 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01483     function hlayerspecifictable_Callback(source,eventdata) %#ok<*INUSL>
01484         switch(eventdata.Indices(2))  % Switch based on column.
01485             case 1 % numfeaturemaps
01486                 set(hdescriptiontext,'String',sprintf('This is the number of feature maps for layer %d.',eventdata.Indices(1)));
01487                 model.num_feature_maps(eventdata.Indices(1)) = eventdata.NewData;
01488                 hupdate_conmats_Callback([],[])
01489             case 2 % filter_size x
01490                 set(hdescriptiontext,'String',sprintf('This is the filter size dimenson 1 for layer %d.',eventdata.Indices(1)));
01491                 model.filter_size(eventdata.Indices(1),1) = eventdata.NewData;
01492                 if(EXPERIMENTAL==0) % Make sure 2d filters are square.
01493                     model.filter_size(eventdata.Indices(1),2) = eventdata.NewData;
01494                     update_defaults
01495                 end
01496             case 3 % filter_size y
01497                 set(hdescriptiontext,'String',sprintf('This is the filter size dimension 2 for layer %d.',eventdata.Indices(1)));
01498                 model.filter_size(eventdata.Indices(1),2) = eventdata.NewData;
01499                 if(EXPERIMENTAL==0) % Make sure 2d filters are square.
01500                     model.filter_size(eventdata.Indices(1),1) = eventdata.NewData;
01501                     update_defaults
01502                 end
01503             case 4 % pooling type
01504                 set(hdescriptiontext,'String',sprintf('This is the pooling type for layer %d.',eventdata.Indices(1)));
01505                 model.norm_types{eventdata.Indices(1)} = eventdata.NewData;
01506             case 5 % pooling size in x-dim
01507                 set(hdescriptiontext,'String',sprintf('This is the pooling size in x dimension for layer %d.',eventdata.Indices(1)));
01508                 model.norm_sizes{eventdata.Indices(1)}(1) = eventdata.NewData;
01509             case 6 % pooling size in y-dim
01510                 set(hdescriptiontext,'String',sprintf('This is the pooling size in y dimension for layer %d.',eventdata.Indices(1)));
01511                 model.norm_sizes{eventdata.Indices(1)}(2) = eventdata.NewData;
01512             case 7 % pooling size in k-dim
01513                 set(hdescriptiontext,'String',sprintf('This is the pooling size in the 3rd dimension for layer %d.',eventdata.Indices(1)));
01514                 model.norm_sizes{eventdata.Indices(1)}(3) = eventdata.NewData;
01515             case 8 % Conv max pooling dessimate size in xy-dim
01516                 set(hdescriptiontext,'String',sprintf('This is the pooling size in the 4th dimension for layer %d (or window size in x dimension for ConvMax).',eventdata.Indices(1)));
01517                 model.norm_sizes{eventdata.Indices(1)}(4) = eventdata.NewData;
01518             case 9 % Conv dessimate size in k-dim
01519                 set(hdescriptiontext,'String',sprintf('This is the window size in y dimension for layer %d.',eventdata.Indices(1)));
01520                 model.norm_sizes{eventdata.Indices(1)}(5) = eventdata.NewData;
01521             case 10 % Conv dessimate size in k-dim
01522                 set(hdescriptiontext,'String',sprintf('This is the window size in k dimension for layer %d.',eventdata.Indices(1)));
01523                 model.norm_sizes{eventdata.Indices(1)}(6) = eventdata.NewData;
01524             case 11 % connectivity matrix type (this updates the connectivity matrix.
01525                 % Set current data to the selected data set.
01526                 switch eventdata.NewData;
01527                     case 'Full' % User selects Peaks.
01528                         set(hdescriptiontext,'String','Each input map is connected to each feature map by a filter.');
01529                         [temp_conmat,recommended] = conmat_full(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01530                     case 'Singles' % User selects Membrane.
01531                         set(hdescriptiontext,'String','Each feature map is connected to a single input map. This puts zeros after the diagonal of ones.');
01532                         [temp_conmat,recommended] = conmat_singles(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01533                     case 'Singles and Some Doubles' % User selects Sinc.
01534                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to two input maps along the diagonal. This puts zeros after both diagonals.');
01535                         [temp_conmat,recommended] = conmat_singles_somedoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01536                     case 'Singles and All Doubles' % User selects Sinc.
01537                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to every possible pair of input maps. This puts zeros after diagonal and all pairs.');
01538                         [temp_conmat,recommended] = conmat_singles_alldoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01539                     case 'Singles and Random Doubles' % User selects Sinc.
01540                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to random pairs of input maps.');
01541                         [temp_conmat,recommended] = conmat_singles_randdoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01542                     case 'Some Doubles' % User selects Sinc.
01543                         set(hdescriptiontext,'String','Each feature map is doubly connected to two input maps along the diagonal. This puts zeros after the diagonal.');
01544                         [temp_conmat,recommended] = conmat_somedoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01545                     case 'All Doubles' % User selects Sinc.
01546                         set(hdescriptiontext,'String','Each feature map is doubly connected to every possible pair on input maps. This puts zeros after all the pairs.');
01547                         [temp_conmat,recommended] = conmat_alldoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01548                     case 'Random Doubles' % User selects Sinc.
01549                         set(hdescriptiontext,'String','Each feature map is doubly connected to random pairs of input maps.');
01550                         [temp_conmat,recommended] = conmat_randdoub(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01551                     case 'Some Triples' % User selects Sinc.
01552                         set(hdescriptiontext,'String','Each feature map is triply connected to two input maps along the diagonal. This puts zeros after the diagonal.');
01553                         [temp_conmat,recommended] = conmat_sometrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01554                     case 'All Triples' % User selects Sinc.
01555                         set(hdescriptiontext,'String','Each feature map is triply connected to every possible triple on input maps. This puts zeros after all the pairs.');
01556                         [temp_conmat,recommended] = conmat_alltrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01557                     case 'Random Triples' % User selects Sinc.
01558                         set(hdescriptiontext,'String','Each feature map is triply connected to random triple of input maps.');
01559                         [temp_conmat,recommended] = conmat_randtrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01560                     case 'Random Quadruples' % User selects Sinc.
01561                         set(hdescriptiontext,'String','Each feature map is quadtruply connected to random quad of input maps.');
01562                         [temp_conmat,recommended] = conmat_randquad(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01563                     case 'Singles, Some Doubles, and Some Triples' % User selects Sinc.
01564                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to two input maps along the diagonal and triply connected to input map triples along the diagonal. This puts zeros afterwards.');
01565                         [temp_conmat,recommended] = conmat_singles_somedoub_sometrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01566                     case 'Singles, All Doubles, and Some Triples' % User selects Sinc.
01567                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to every possible pair of input maps and triply connected to input map triples along the diagonal. This puts zeros afterwards.');
01568                         [temp_conmat,recommended] = conmat_singles_alldoub_sometrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01569                     case 'Singles, Random Doubles, and Some Triples' % User selects Sinc.
01570                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to random pairs of input maps and triply connected to input map triples along the diagonal.');
01571                         [temp_conmat,recommended] = conmat_singles_randdoub_sometrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01572                     case 'Singles, Some Doubles, and Random Triples' % User selects Sinc.
01573                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to every possible pair of input maps and triply connected to random input map triples.');
01574                         [temp_conmat,recommended] = conmat_singles_somedoub_randtrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01575                     case 'Singles, All Doubles, and Random Triples' % User selects Sinc.
01576                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to every possible pair of input maps and triply connected to random input map triples.');
01577                         [temp_conmat,recommended] = conmat_singles_alldoub_randtrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01578                     case 'Singles, All Doubles, and All Triples'
01579                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly connected to every possible pair of input maps and triply connected to every possible triples of input maps.');
01580                         [temp_conmat,recommended] = conmat_singles_alldoub_alltrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01581                     case 'Singles, Random Doubles, and Random Triples' % User selects Sinc.
01582                         set(hdescriptiontext,'String','Each feature map is singly connected to an input map and doubly and triply connected to an even number of input maps at random.');
01583                         [temp_conmat,recommended] = conmat_singles_randdoub_randtrip(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01584                     case 'Some of each (starting with singles)' % User selects Sinc.
01585                         set(hdescriptiontext,'String','Feature maps are connected along diagonal to single, double, triple,etc. input maps.');
01586                         [temp_conmat,recommended] = conmat_someall_start_ones(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01587                     case 'Some of each (starting with doubles)' % User selects Sinc.
01588                         set(hdescriptiontext,'String','Feature maps are connected along diagonal to double, triple,etc. input maps.');
01589                         [temp_conmat,recommended] = conmat_someall_start_twos(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01590                     case  'Even Number of Rand Sing,Doub,Trip'
01591                         set(hdescriptiontext,'String','An even number of randomly assigned singles, doubles, and triples are placed. (one third of each)');
01592                         [temp_conmat,recommended] = conmat_someall_start_twos(model.num_input_maps(eventdata.Indices(1)),model.num_feature_maps(eventdata.Indices(1)));
01593                 end
01594                 
01595                 model.conmat_types{eventdata.Indices(1)} = eventdata.NewData;
01596                 model.conmats{eventdata.Indices(1)} = temp_conmat;
01597                 model.num_feature_maps(eventdata.Indices(1)) = recommended;
01598                 model.num_input_maps(eventdata.Indices(1)+1) = recommended;
01599                 hupdate_conmats_Callback([],[])
01600                 
01601             case 12 % shift filters
01602                 set(hdescriptiontext,'String',sprintf('This determines if you want to shift the filters by center of mass for layer %d.',eventdata.Indices(1)));
01603                 model.SHIFT_FILTERS(eventdata.Indices(1)) = eventdata.NewData;
01604             case 13 % zero mean filters
01605                 set(hdescriptiontext,'String',sprintf('This determines if you want to zero mean the filters for layer %d.',eventdata.Indices(1)));
01606                 model.ZERO_MEAN_FILTERS(eventdata.Indices(1)) = eventdata.NewData;
01607             case 14 % normalize filters
01608                 set(hdescriptiontext,'String',sprintf('This determines if you want to normalize the filters by L2-norm over dimensions 1,2,3 for layer %d.',eventdata.Indices(1)));
01609                 model.NORMALIZE_FILTERS(eventdata.Indices(1)) = eventdata.NewData;
01610             case 15 % max filters
01611                 set(hdescriptiontext,'String',sprintf('This determines if you want to normalize the filters so the max value connected to each feature map is 1 for layer %d.',eventdata.Indices(1)));                
01612                 model.MAX_FILTERS(eventdata.Indices(1)) = eventdata.NewData;
01613             case 16 % shutoff weak filters
01614                 set(hdescriptiontext,'String',sprintf('This determines if you want to shutoff this ratio of the weak filters for layer %d.',eventdata.Indices(1)));
01615                 model.GREEDY_FILTER_SHUTOFF(eventdata.Indices(1)) = eventdata.NewData;
01616             case 17 % clip filters
01617                 set(hdescriptiontext,'String',sprintf('This determines if you want to clips abs(F)<FILTER_CLIPPING for layer %d.',eventdata.Indices(1)));
01618                 model.FILTER_CLIPPING(eventdata.Indices(1)) = eventdata.NewData;
01619         end
01620         disp(model);
01621     end
01622 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01623 
01624 
01625 
01626 
01627 
01628 
01629 
01630 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01631 %% Positive feature maps
01632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01633 hposzcheck = uicontrol('Style','checkbox',...
01634     'String','Positive Z',...
01635     'Position',[425,505,90,20],...
01636     'Callback',{@hposz_Callback});
01637 % Set the check for contrast normalizing the image.
01638 set(hposzcheck,'Value',model.POSITIVE_Z);
01639 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01640 % Callback for randomly ordereing input images during training/inference.
01641 %
01642 % @param source the gui component that called this.
01643 % @param eventdata relates to the event of activating the gui component.
01644 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01645     function hposz_Callback(hObject,eventdata)
01646         set(hdescriptiontext,'String','Check this box if you want to constrain the feature maps to be positive.');
01647         if (get(hObject,'Value') == get(hObject,'Max'))
01648             % Checkbox is checked-take approriate action
01649             model.POSITIVE_Z = 1;
01650         else
01651             % Checkbox is not checked-take approriate action
01652             model.POSITIVE_Z = 0;
01653         end
01654     end
01655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01656 
01657 
01658 
01659 
01660 
01661 
01662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01663 %% Lambda Parameters
01664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01665 % Text field to set the data directory.
01666 hlambdatable = uitable('Parent',fgui,...
01667     'Data',model.lambda,...
01668     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01669     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01670     'Position',[15,100,380,140],...
01671     'ColumnEditable',[true true true true true true true true true true],...
01672     'CellEditCallback',{@hlambdatable_Callback},...
01673     'ColumnWidth',{60 60 85 85 45 45 45 45 45 45});
01674 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01675 % Callback for setting the lambda coefficients of all layer.
01676 %
01677 % @param source the gui component that called this.
01678 % @param eventdata relates to the event of activating the gui component.
01679 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01680     function hlambdatable_Callback(source,eventdata)
01681         set(hdescriptiontext,'String',sprintf('This is the parameter weighting the reconstruction error term for layer %d, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01682         model.lambda(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01683         eventdata.NewData = sprintf('%0.5d',eventdata.NewData);
01684     end
01685 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01686 
01687 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01688 %% Alpha Parameters
01689 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01690 % Text field to set the data directory.
01691 halphatable = uitable('Parent',fgui,...
01692     'Data',model.alpha,...
01693     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01694     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01695     'Position',[410,100,100,140],...
01696     'ColumnEditable',[true true true true true true true true true true],...
01697     'CellEditCallback',{@halphatable_Callback},...
01698     'ColumnWidth',{45 45 45 45 45 45 45 45 45 45});
01699 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01700 % Callback for setting the alpha coefficients of all layers.
01701 %
01702 % @param source the gui component that called this.
01703 % @param eventdata relates to the event of activating the gui component.
01704 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01705     function halphatable_Callback(source,eventdata)
01706         set(hdescriptiontext,'String',sprintf('This is the parameter sparsity norm exponent on the feature maps for layer %d, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01707         model.alpha(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01708     end
01709 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01710 
01711 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01712 %% Gamma Parameters
01713 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01714 % Text field to set the data directory.
01715 hgammatable = uitable('Parent',fgui,...
01716     'Data',model.gamma,...
01717     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01718     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01719     'Position',[807,100,380,140],...
01720     'ColumnEditable',[true true true true true true true true true true],...
01721     'CellEditCallback',{@hgammatable_Callback},...
01722     'ColumnWidth',{80 80 80 80 45 45 45 45 45 45});
01723 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01724 % Callback for setting the Gamma coefficients of all layer.
01725 %
01726 % @param source the gui component that called this.
01727 % @param eventdata relates to the event of activating the gui component.
01728 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01729     function hgammatable_Callback(source,eventdata)
01730         set(hdescriptiontext,'String',sprintf('This is the parameter weighting the reconstruction error term for layer %d to the layer below, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01731         model.gamma(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01732     end
01733 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01734 
01735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01736 %% Kappa Parameters
01737 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01738 % Text field to set the data directory.
01739 hkappatable = uitable('Parent',fgui,...
01740     'Data',model.kappa,...
01741     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01742     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01743     'Position',[603,100,100,140],...
01744     'ColumnEditable',[true true true true true true true true true true],...
01745     'CellEditCallback',{@hkappatable_Callback},...
01746     'ColumnWidth',{45 45 45 45 45 45 45 45 45 45});
01747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01748 % Callback for setting the Kappa coefficients of all layer.
01749 %
01750 % @param source the gui component that called this.
01751 % @param eventdata relates to the event of activating the gui component.
01752 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01753     function hkappatable_Callback(source,eventdata)
01754         set(hdescriptiontext,'String',sprintf('This is the coefficient for the sparsity term for layer %d, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01755         model.kappa(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01756     end
01757 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01758 
01759 
01760 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01761 %% Binitial Parameters
01762 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01763 % Text field to set the data directory.
01764 hBinitialtable = uitable('Parent',fgui,...
01765     'Data',model.Binitial,...
01766     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01767     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01768     'Position',[500,100,100,140],...
01769     'ColumnEditable',[true true true true true true true true true true],...
01770     'CellEditCallback',{@hBinitialtable_Callback},...
01771     'ColumnWidth',{45 45 45 45 45 45 45 45 45 45});
01772 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01773 % Callback for setting the Binitial coefficients of all layer.
01774 %
01775 % @param source the gui component that called this.
01776 % @param eventdata relates to the event of activating the gui component.
01777 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01778     function hBinitialtable_Callback(source,eventdata)
01779         set(hdescriptiontext,'String',sprintf('This is the ISTA gradient step size (was starting value of the beta regeme for continuation) for layer %d, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01780         model.Binitial(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01781     end
01782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01783 
01784 
01785 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01786 %% Bmultiplier Parameters
01787 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01788 % Text field to set the data directory.
01789 hBmultipliertable = uitable('Parent',fgui,...
01790     'Data',model.Bmultiplier,...
01791     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01792     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01793     'Position',[700,100,100,140],...
01794     'ColumnEditable',[true true true true true true true true true true],...
01795     'CellEditCallback',{@hBmultipliertable_Callback},...
01796     'ColumnWidth',{45 45 45 45 45 45 45 45 45 45});
01797 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01798 % Callback for setting the Bmultiplier coefficients of all layer.
01799 %
01800 % @param source the gui component that called this.
01801 % @param eventdata relates to the event of activating the gui component.
01802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01803     function hBmultipliertable_Callback(source,eventdata)
01804         set(hdescriptiontext,'String',sprintf('This is the multiplier in the beta regeme for continuation for layer %d, phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01805         model.Bmultiplier(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01806     end
01807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01808 
01809 
01810 
01811 
01812 
01813 % Text field to set the data directory.
01814 hnotes = uicontrol('Style','edit',...
01815     'String','1',...
01816     'HorizontalAlignment','left',...
01817     'BackgroundColor','white',...
01818     'Position',[1000,463,190,140],...
01819     'Callback',{@hnotes_Callback},...
01820     'Max',1000,...
01821     'Min',1);
01822 % Set the data directory default.
01823 set(hnotes,'String',model.notes);
01824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01825 % Callback for setting the coefficient weighting the updated image at each
01826 % iteration against the input image.
01827 %
01828 % @param source the gui component that called this.
01829 % @param eventdata relates to the event of activating the gui component.
01830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01831     function hnotes_Callback(hObject, eventdata, handles) %#ok<*INUSD>
01832         set(hdescriptiontext,'String','Type some description of the experiment for later recalling it. This will be emailed as well if the emailing is turned on and setup properly.');
01833         % Display surf plot of the currently selected data.
01834         user_string = get(hObject,'String');
01835         model.notes = user_string;
01836     end
01837 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01838 
01839 
01840 
01841 
01842 
01843 
01844 
01845 
01846 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01847 %% Fabove Parameters
01848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01849 % Text field to set the data directory.
01850 hFabovetable = uitable('Parent',fgui,...
01851     'Data',logical(model.Fabove),...
01852     'ColumnName',{'P1','P2','P3','P4','P5','P6','P7','P8','P9','P10'},...
01853     'RowName',{'L1','L2','L3','L4','L5','L6','L7','L8','L9','L10'},...
01854     'Position',[805,460,188,140],...
01855     'ColumnEditable',[true true true true true true true true true true],...
01856     'CellEditCallback',{@hFabovetable_Callback},...
01857     'ColumnWidth',{45 45 45 45 45 45 45 45 45 45},....
01858     'ColumnFormat',{'logical','logical','logical','logical','logical','logical','logical','logical','logical','logical'});
01859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01860 % Callback for setting the Fabove of all layer.
01861 %
01862 % @param source the gui component that called this.
01863 % @param eventdata relates to the event of activating the gui component.
01864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01865     function hFabovetable_Callback(source,eventdata)
01866         set(hdescriptiontext,'String',sprintf('This specifies if the filters for layer %d should be updated by reconstructions from layers above in phase %d.',eventdata.Indices(1),eventdata.Indices(2)));
01867         model.Fabove(eventdata.Indices(1),eventdata.Indices(2)) = eventdata.NewData;
01868     end
01869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01870 
01871 
01872 
01873 
01874 
01875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01876 %% Video Stuff
01877 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01878 htime_layertext = uicontrol('Style','text',...
01879     'String','Time Layer:',...
01880     'HorizontalAlignment','left',...
01881     'Position',[605,505,90,15]);
01882 % Text field to set the data directory.
01883 htime_layer = uicontrol('Style','popupmenu',...
01884     'String',{'0','1','2','3','4','5','6','7','8'},...
01885     'HorizontalAlignment','left',...
01886     'BackgroundColor','white',...
01887     'Position',[695,503,90,25],...
01888     'Callback',{@htime_layer_Callback});
01889 % Set the data directory default.
01890 set(htime_layer,'Value',find(strcmp(get(htime_layer,'String'),int2str(model.TIME_LAYER))))
01891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01892 % Callback for setting the kappa coefficient on layer 1 regularizations.
01893 %
01894 % @param source the gui component that called this.
01895 % @param eventdata relates to the event of activating the gui component.
01896 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01897     function htime_layer_Callback(hObject, eventdata, handles)
01898         set(hdescriptiontext,'String','Specify which layer to learn transitions through time in. 0 is regular static model, 1 is just a 1-layer model with each input plane being different time. 2,3 just make time at top layers (static below).');
01899         
01900         % Determine the selected data set.
01901         val = get(hObject,'Value');
01902         
01903         if(val-1 > model.num_layers)
01904             model.num_layers = val-1;
01905         end
01906         %         update_defaults
01907         set(hnum_layers,'Value',find(strcmp(get(hnum_layers,'String'),int2str(model.num_layers))))
01908         update_visibility
01909         
01910         % Set the number of layers.
01911         model.TIME_LAYER = val-1;
01912     end
01913 
01914 
01915 
01916 
01917 hprev_framestext = uicontrol('Style','text',...
01918     'String','Prev Frames:',...
01919     'HorizontalAlignment','left',...
01920     'Position',[425,480,90,15]);
01921 % Text field to set the data directory.
01922 hprev_frames = uicontrol('Style','edit',...
01923     'String','100',...
01924     'HorizontalAlignment','left',...
01925     'BackgroundColor','white',...
01926     'Position',[515,480,40,25],...
01927     'Callback',{@hprev_frames_Callback});
01928 % Set the data directory default.
01929 set(hprev_frames,'String',model.prev_frames);
01930 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01931 % Callback for setting the number of time steps in past for video modelling.
01932 %
01933 % @param source the gui component that called this.
01934 % @param eventdata relates to the event of activating the gui component.
01935 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01936     function hprev_frames_Callback(hObject, eventdata, handles)
01937         set(hdescriptiontext,'String','Previous frames of video sequence to use when modelling video.');
01938         % Display surf plot of the currently selected data.
01939         user_string = get(hObject,'String');
01940         model.prev_frames = str2double(user_string);
01941         user_string = get(hinfer_using,'String');
01942         if(strcmp(user_string,'all'))
01943             model.INFER_USING = 1:model.prev_frames+1;
01944         end
01945         if(max(model.INFER_USING)>model.prev_frames+1)
01946             model.INFER_USING = 1:model.prev_frames+1;
01947         end
01948     end
01949 
01950 
01951 hgen_framestext = uicontrol('Style','text',...
01952     'String','Frames2Gen:',...
01953     'HorizontalAlignment','left',...
01954     'Position',[425,480,90,15]);
01955 % Text field to set the data directory.
01956 hgen_frames = uicontrol('Style','edit',...
01957     'String','100',...
01958     'HorizontalAlignment','left',...
01959     'BackgroundColor','white',...
01960     'Position',[515,480,40,25],...
01961     'Callback',{@hgen_frames_Callback});
01962 % Set the data directory default.
01963 set(hgen_frames,'String',model.gen_frames);
01964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01965 % Callback for setting the number of time steps in past for video modelling.
01966 %
01967 % @param source the gui component that called this.
01968 % @param eventdata relates to the event of activating the gui component.
01969 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01970     function hgen_frames_Callback(hObject, eventdata, handles)
01971         set(hdescriptiontext,'String','Specify the number of new frames to generate.');
01972         % Display surf plot of the currently selected data.
01973         user_string = get(hObject,'String');
01974         model.gen_frames = str2double(user_string);
01975     end
01976 
01977 
01978 hinfer_usingtext = uicontrol('Style','text',...
01979     'String','Infer Times:',...
01980     'HorizontalAlignment','left',...
01981     'Position',[555,480,70,15]);
01982 % Text field to set the data directory.
01983 hinfer_using = uicontrol('Style','edit',...
01984     'String','100',...
01985     'HorizontalAlignment','left',...
01986     'BackgroundColor','white',...
01987     'Position',[620,480,80,25],...
01988     'Callback',{@hinfer_using_Callback});
01989 % Set the data directory default.
01990 set(hinfer_using,'String',model.INFER_USING);
01991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
01992 % Callback for setting the number of time steps in past for video modelling.
01993 %
01994 % @param source the gui component that called this.
01995 % @param eventdata relates to the event of activating the gui component.
01996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
01997     function hinfer_using_Callback(hObject, eventdata, handles)
01998         set(hdescriptiontext,'String','These are the frames to use for inference (the remaining ones still have reconstruction errors computed on them during training or are used for reconstruction during recon). Format is [1:2],[1 3 4], etc. Dont use end keyword.');
01999         % Display surf plot of the currently selected data.
02000         user_string = get(hObject,'String');
02001         if(strcmp(user_string,'all'))
02002             model.INFER_USING = 1:model.prev_frames+1;
02003         else
02004             eval(strcat('model.INFER_USING = ',user_string,';'));
02005         end
02006         
02007         %         if(max(model.INFER_USING) > model.prev_frames+1)
02008         %             set(hdescriptiontext,'String','ERROR: You cannot select previous time steps for inference more than the specified number of previous time steps used.');
02009         %         end
02010     end
02011 
02012 
02013 
02014 % Limit the time layer connections.
02015 hlimittimecheck = uicontrol('Style','checkbox',...
02016     'String','Limit Time',...
02017     'Position',[700,480,90,25],...
02018     'Callback',{@hlimittimecheck_Callback});
02019 % Set the check for contrast normalizing the image.
02020 set(hlimittimecheck,'Value',model.LIMIT_TIME_LAYER_THROUGH_TIME);
02021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02022 % Callback for updating the filters in batches (of images).
02023 %
02024 % @param source the gui component that called this.
02025 % @param eventdata relates to the event of activating the gui component.
02026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02027     function hlimittimecheck_Callback(hObject,eventdata)
02028         set(hdescriptiontext,'String','If 1 then top layer only connects to the same feature maps (from previous layer) through time, otherwise uses model.conamts{top_layer}');
02029         if (get(hObject,'Value') == get(hObject,'Max'))
02030             % Checkbox is checked-take approriate action
02031             model.LIMIT_TIME_LAYER_THROUGH_TIME = 1;
02032         else
02033             % Checkbox is not checked-take approriate action
02034             model.LIMIT_TIME_LAYER_THROUGH_TIME = 0;
02035         end
02036     end
02037 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02039 
02040 
02041 
02042 %
02043 % %% Train the 1st layer in Yann's approach first?
02044 % hfiltercontcheck = uicontrol('Style','checkbox',...
02045 %     'String','Filter Continuation',...
02046 %     'Position',[1000,615,105,25],...
02047 %     'Callback',[email protected]_Callback});
02048 % % Set the check for color or gray images.
02049 % set(hfiltercontcheck,'Value',model.FILTER_CONTINUATION);
02050 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02051 % % Callback for if you want to initialize the first layer when using Yann's two
02052 % % layer inference method.
02053 % %
02054 % % @param source the gui component that called this.
02055 % % @param eventdata relates to the event of activating the gui component.
02056 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02057 %     function hfiltercontcheck_Callback(hObject,eventdata)
02058 %         set(hdescriptiontext,'String','If checked at filter continuation (beta regeme) will occur. Setttings are still in train_recon_phase_all.m');
02059 %         if (get(hObject,'Value') == get(hObject,'Max'))
02060 %             % Checkbox is checked-take approriate action
02061 %             model.FILTER_CONTINUATION = 1;
02062 %         else
02063 %             % Checkbox is not checked-take approriate action
02064 %             model.FILTER_CONTINUATION = 0;
02065 %         end
02066 %     end
02067 
02068 
02069 
02070 
02071 
02072 
02073 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02074 %% z0 Filter Parameters
02075 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02076 hpsitext = uicontrol('Style','text',...
02077     'String','Psi:',...
02078     'HorizontalAlignment','left',...
02079     'Position',[425,565,90,15]);
02080 % Text field to set the data directory.
02081 hpsi = uicontrol('Style','edit',...
02082     'String','1',...
02083     'HorizontalAlignment','left',...
02084     'BackgroundColor','white',...
02085     'Position',[500,565,90,25],...
02086     'Callback',[email protected]_Callback});
02087 % Set the data directory default.
02088 set(hpsi,'String',model.psi);
02089 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02090 % Callback for setting the psi coefficient on z0 feature map reconstructions.
02091 %
02092 % @param source the gui component that called this.
02093 % @param eventdata relates to the event of activating the gui component.
02094 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02095     function hpsi_Callback(hObject, eventdata, handles)
02096         set(hdescriptiontext,'String','The Psi weighting of z0 map that attempts to reconstruct the non-contrast normalized poritono of the image. Set to zero if not used.');
02097         % Display surf plot of the currently selected data.
02098         user_string = get(hObject,'String');
02099         model.psi = str2double(user_string);
02100     end
02101 
02102 %% L2-norm on the dummy variable - feature map term.
02103 hzsizetext = uicontrol('Style','text',...
02104     'String','z0 Size:',...
02105     'HorizontalAlignment','left',...
02106     'Position',[610,565,90,15]);
02107 % Text field to set the data directory.
02108 hzsize = uicontrol('Style','edit',...
02109     'String','1',...
02110     'HorizontalAlignment','left',...
02111     'BackgroundColor','white',...
02112     'Position',[680,565,90,25],...
02113     'Callback',{@hzsize_Callback});
02114 % Set the data directory default.
02115 set(hzsize,'String',model.z0_filter_size);
02116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02117 % Callback for setting the size of the z0 feature maps.
02118 %
02119 % @param source the gui component that called this.
02120 % @param eventdata relates to the event of activating the gui component.
02121 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02122     function hzsize_Callback(hObject, eventdata, handles)
02123         set(hdescriptiontext,'String','The size of the z0 filter. The default is the default filter size. Note: there is one z0 feature map per input plane.');
02124         % Display surf plot of the currently selected data.
02125         user_string = get(hObject,'String');
02126         model.z0_filter_size = str2double(user_string);
02127     end
02128 
02129 %%%%%%%%%%
02130 %% Do you want to train the z0 map?
02131 htrainz0check = uicontrol('Style','checkbox',...
02132     'String','Train z0 Maps',...
02133     'Position',[425,540,120,25],...
02134     'Callback',{@htrainz0check_Callback});
02135 % Set the check for the plotting of results.
02136 set(htrainz0check,'Value',model.TRAIN_Z0);
02137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02138 % Callback for setting whether to use the z0 feature maps or not.
02139 %
02140 % @param source the gui component that called this.
02141 % @param eventdata relates to the event of activating the gui component.
02142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02143     function htrainz0check_Callback(hObject,eventdata)
02144         set(hdescriptiontext,'String','When checked, the z0 map will be learned during training, otherwise z0 is ignored during training. Note: when equal to 1 this overwrites CONTRAST_NORMALIZE to 0 during training. When Reconstructing, Contrast Normalize overwrites this.');
02145         if (get(hObject,'Value') == get(hObject,'Max'))
02146             % Checkbox is checked-take approriate action
02147             model.TRAIN_Z0 = 1;
02148         else
02149             % Checkbox is not checked-take approriate action
02150             model.TRAIN_Z0 = 0;
02151         end
02152     end
02153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02154 
02155 
02156 
02157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02158 %% Update Image?
02159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02160 hupdate_inputcheck = uicontrol('Style','checkbox',...
02161     'String','Update Image?',...
02162     'Position',[425,615,120,25],...
02163     'Callback',{@hupdate_inputcheck_Callback});
02164 % Set the check for the plotting of results.
02165 set(hupdate_inputcheck,'Value',model.UPDATE_INPUT);
02166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02167 % Callback for setting if the images is updated at each iteration.
02168 %
02169 % @param source the gui component that called this.
02170 % @param eventdata relates to the event of activating the gui component.
02171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02172     function hupdate_inputcheck_Callback(hObject,eventdata)
02173         set(hdescriptiontext,'String','When checked, the image is updated at each iteration. This is good for recosntructing noisy images.');
02174         if (get(hObject,'Value') == get(hObject,'Max'))
02175             % Checkbox is checked-take approriate action
02176             model.UPDATE_INPUT = 1;
02177         else
02178             % Checkbox is not checked-take approriate action
02179             model.UPDATE_INPUT = 0;
02180         end
02181     end
02182 
02183 %% lambda on the reconstructionb between the original and updated images.
02184 hlambda_inputtext = uicontrol('Style','text',...
02185     'String','Input Lambda:',...
02186     'HorizontalAlignment','left',...
02187     'Position',[590,620,90,15]);
02188 % Text field to set the data directory.
02189 hlambda_input = uicontrol('Style','edit',...
02190     'String','1',...
02191     'HorizontalAlignment','left',...
02192     'BackgroundColor','white',...
02193     'Position',[680,615,90,25],...
02194     'Callback',{@hlambda_input_Callback});
02195 % Set the data directory default.
02196 set(hlambda_input,'String',model.lambda_input);
02197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02198 % Callback for setting the coefficient weighting the updated image at each
02199 % iteration against the input image.
02200 %
02201 % @param source the gui component that called this.
02202 % @param eventdata relates to the event of activating the gui component.
02203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02204     function hlambda_input_Callback(hObject, eventdata, handles) %#ok<*INUSD>
02205         set(hdescriptiontext,'String','The coefficient in front of the reconstruction L2-norm between the updated image and the input image. Note: setting this to zero does not turn off this effect because of the weighted summation.');
02206         % Display surf plot of the currently selected data.
02207         user_string = get(hObject,'String');
02208         model.lambda_input = str2double(user_string);
02209     end
02210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02211 
02212 
02213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02214 %% Dataset and Save Directories
02215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02216 %%%%%%%%
02217 %% Model or Dataset Directory Directory
02218 % Title for the data directory.
02219 hmodeldirectorytext = uicontrol('Style','pushbutton',...
02220     'String','Model Dir:',...
02221     'HorizontalAlignment','left',...
02222     'Position',[25,65,100,15],...
02223     'Callback',{@hmodeldirectorytext_Callback});
02224 % Text field to set the model directory.
02225 hmodeldirectory = uicontrol('Style','edit',...
02226     'String',[START_RESULTS_DIRECTORY '/Results/'],...
02227     'HorizontalAlignment','left',...
02228     'BackgroundColor','white',...
02229     'Position',[115,60,670,25],...
02230     'Callback',{@hmodeldirectory_Callback});
02231 % Set the model directory default.
02232 set(hmodeldirectory,'String',model.modeldirectory);
02233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02234 % Callback for setting where the model is located.
02235 %
02236 % @param source the gui component that called this.
02237 % @param eventdata relates to the event of activating the gui component.
02238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02239     function hmodeldirectory_Callback(hObject, eventdata, handles)
02240         set(hdescriptiontext,'String','Set the location where to load a previously trained model from. This is the top layer/phase of the model from which you can infer feature maps/reconstruct new images or training aditional layers on top of. Do not put any dots before the first slash. This must be a path to a epoch##_phase##.mat file.');
02241         % Display surf plot of the currently selected model.
02242         user_string = get(hObject,'String');
02243         model.modeldirectory = user_string;
02244         %         if(exist(strcat(LAPTOP_RESULTS_DIRECTORY(1:end-1),model.modeldirectory),'file')==0 &&...
02245         %                 exist(strcat(SERVER_RESULTS_DIRECTORY(1:end-1),model.modeldirectory),'file')==0)
02246         %             error('Model Directory set in gui does not exist.\n')
02247         %         end
02248     end
02249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02250 % Callback for opening directory in gui.
02251 %
02252 % @param source the gui component that called this.
02253 % @param eventdata relates to the event of activating the gui component.
02254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02255     function hmodeldirectorytext_Callback(hObject, eventdata, handles)
02256         savedpath = model.modeldirectory;
02257         % These experiments need directories (usually).
02258         if(strcmp(model.exptype,'View Figures') || strcmp(model.exptype,'List Results'))
02259             %             if(strcmp(model.machine,' laptop'))
02260             
02261             uipath = uigetdir(strcat(START_RESULTS_DIRECTORY,parentdir(model.modeldirectory)),'Select Folder to Search for Results in');
02262             uipath = uipath(length(START_RESULTS_DIRECTORY)+1:end);
02263             %             else
02264             %                 uipath = uigetdir(strcat(SERVER_RESULTS_DIRECTORY,parentdir(model.modeldirectory)),'Select Folder to Search for Results in');
02265             %                 uipath = uipath(length(SERVER_RESULTS_DIRECTORY):end);
02266             %             end
02267             if(isempty(uipath)) % User hit the cancel button.
02268                 model.modeldirectory = savedpath;
02269             else
02270                 model.modeldirectory = strcat(uipath,'/');
02271             end
02272             set(hmodeldirectory,'String',model.modeldirectory)
02273         else % the rest of teh experiments need files.
02274             savedpwd = pwd;
02275             
02276             %             if(strcmp(model.machine,' laptop'))
02277             if(exist(strcat(START_RESULTS_DIRECTORY,parentdir(model.modeldirectory)),'dir'))
02278                 cd(strcat(START_RESULTS_DIRECTORY,parentdir(model.modeldirectory))) % Go to the Results directory.
02279             else
02280                 cd(START_RESULTS_DIRECTORY);
02281             end
02282             
02283             [uifile,uipath] = uigetfile
02284             uipath = strcat(uipath,uifile);
02285             uipath = uipath(length(START_RESULTS_DIRECTORY)+1:end);
02286             %             else
02287             %                 cd(strcat(SERVER_RESULTS_DIRECTORY,parentdir(model.modeldirectory))) % Go to the Results directory.
02288             %                 [uifile,uipath] = uigetfile;
02289             %                 uipath = strcat(uipath,uifile);
02290             %                 uipath = uipath(length(SERVER_RESULTS_DIRECTORY):end);
02291             %             end
02292             if(isempty(uipath)) % User hit the cancel button.
02293                 model.modeldirectory = savedpath;
02294             else
02295                 model.modeldirectory = uipath;
02296             end
02297             cd(savedpwd)
02298             
02299             set(hmodeldirectory,'String',model.modeldirectory)
02300         end
02301         %         if(exist(strcat(LAPTOP_RESULTS_DIRECTORY(1:end-1),model.modeldirectory),'file')==0 &&...
02302         %                 exist(strcat(SERVER_RESULTS_DIRECTORY(1:end-1),model.modeldirectory),'file')==0)
02303         %             error('Model Directory set in gui does not exist.\n')
02304         %         end
02305     end
02306 
02307 % Title for the data directory.
02308 hdatadirectorytext = uicontrol('Style','pushbutton',...
02309     'String','Data Dir:',...
02310     'HorizontalAlignment','left',...
02311     'Position',[25,37,100,18],...
02312     'Callback',{@hdatadirectorytext_Callback});
02313 % Text field to set the data directory.
02314 hdatadirectory = uicontrol('Style','edit',...
02315     'String',[START_DATASET_DIRECTORY '/Images/'],...
02316     'HorizontalAlignment','left',...
02317     'BackgroundColor','white',...
02318     'Position',[115,35,670,25],...
02319     'Callback',{@hdatadirectory_Callback});
02320 % Set the data directory default.
02321 set(hdatadirectory,'String',model.datadirectory);
02322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02323 % Callback for setting where data is located.
02324 %
02325 % @param source the gui component that called this.
02326 % @param eventdata relates to the event of activating the gui component.
02327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02328     function hdatadirectory_Callback(hObject, eventdata, handles)
02329         set(hdescriptiontext,'String','Set the location where to get the images from for training. These images are used for training, reconstruction, or other experiments involving data directly. Do not put any dots before the first slash. This folder can contain image files, a single .mat with I (image) variable in it, or be a path to a single image or .mat.');
02330         % Display surf plot of the currently selected data.
02331         user_string = get(hObject,'String');
02332         if(check_imgs_path([START_DATASET_DIRECTORY,model.datadirectory])==0)
02333             warning('Data Directory set in gui does not exist or does not contain image files or a .mat file.\n')
02334             set(hdescriptiontext,'String','WARNING: data directory does not exist. Make sure the start paths at the top of gui.m are set and you datadirectory below is set.');
02335         end
02336         model.datadirectory = user_string;
02337     end
02338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02339 % Callback for open directory finding gui.
02340 %
02341 % @param source the gui component that called this.
02342 % @param eventdata relates to the event of activating the gui component.
02343 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02344     function hdatadirectorytext_Callback(hObject, eventdata, handles)
02345         savedpath = model.datadirectory;
02346         uipath = uigetdir(strcat(START_DATASET_DIRECTORY,parentdir(model.datadirectory)),'Select Folder than contains images');
02347         starting = 0;
02348         
02349         uipath = uipath(length(START_DATASET_DIRECTORY)+1:end);
02350         if(isempty(uipath)) % User hit the cancel button.
02351             model.datadirectory = savedpath;
02352         else
02353             model.datadirectory = strcat(uipath,'/');
02354         end
02355         set(hdatadirectory,'String',model.datadirectory)        
02356     end
02357 
02358 %%%%%%%%%%
02359 %% Save Directory
02360 hsavedirectorytext = uicontrol('Style','pushbutton',...
02361     'String','Save Dir:',...
02362     'HorizontalAlignment','left',...
02363     'Position',[25,12,100,18],...
02364     'Callback',{@hsavedirectorytext_Callback});
02365 hsavedirectory = uicontrol('Style','edit',...
02366     'String',[START_RESULTS_DIRECTORY '/Results/'],...
02367     'HorizontalAlignment','left',...
02368     'BackgroundColor','white',...
02369     'Position',[115,10,670,25],...
02370     'Callback',{@hsavedirectory_Callback});
02371 % Set the save direcotry default.
02372 set(hsavedirectory,'String',model.savedirectory);
02373 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02374 % Callback for setting where to save the results.
02375 %
02376 % @param source the gui component that called this.
02377 % @param eventdata relates to the event of activating the gui component.
02378 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02379     function hsavedirectory_Callback(hObject, eventdata, handles)
02380         set(hdescriptiontext,'String','Set the location where to save the results to in the Results/ directory. Do not put any dots before the first slash. It is recommended to use /Results/+ here as the + signals the code to autogenerate a descriptive hierarchy of folders based on the dataset and certain model parameters.');
02381         % Display surf plot of the currently selected data.
02382         user_string = get(hObject,'String');
02383         model.savedirectory = user_string;
02384     end
02385 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02386 % Callback for opening directory in gui.
02387 %
02388 % @param source the gui component that called this.
02389 % @param eventdata relates to the event of activating the gui component.
02390 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02391     function hsavedirectorytext_Callback(hObject, eventdata, handles)
02392         savedpath = model.savedirectory;
02393         
02394         %         if(strcmp(model.machine,' laptop'))
02395         uipath = uigetdir(strcat(START_RESULTS_DIRECTORY,parentdir(model.savedirectory)));
02396         uipath = uipath(length(START_RESULTS_DIRECTORY)+1:end);
02397         %         else
02398         %             uipath = uigetdir(strcat(SERVER_RESULTS_DIRECTORY,parentdir(model.savedirectory)));
02399         %             uipath = uipath(length(SERVER_RESULTS_DIRECTORY):end);
02400         %         end
02401         if(isempty(uipath)) % User hit the cancel button.
02402             model.savedirectory = savedpath;
02403         else
02404             model.savedirectory = strcat(uipath,'/');
02405         end
02406         set(hsavedirectory,'String',model.savedirectory)
02407     end
02408 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02409 
02410 
02411 
02412 
02413 
02414 
02415 %%%%%%%%%%
02416 %% Update the number of filters.
02417 % hupdateconmats = uicontrol('Style','pushbutton',...
02418 %     'String','Update Connectivity Matrices',...
02419 %     'Position',[425,500,200,25],...
02420 %     'Callback',{@hupdate_conmats_Callback});
02421 % Callback is at the bottom because it depends on other things.
02422 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02423 
02424 
02425 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02426 %% NOISE SETTINGS
02427 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02428 % Setup dropdown for the experiment type.
02429 hnoisetype = uicontrol('Style','popupmenu',...
02430     'String',{'None (Reconstruct)','Random','Repmat Random','Random Gray','Energy of City vs Fruit','Energy of Scenes','Half Clean Half Random','Erase Corners','Erase Corner Boxes','Erase Half of Image','Scattered Lines','Scattered Boxes','Scattered Crosses','Rotate Image','Blur Image','Repmat Blur','Residual Image'},...
02431     'Position',[810,617,180,25],...
02432     'Callback',{@hnoisetype_Callback});
02433 % Set the default for the experiment dropdown menu.
02434 set(hnoisetype,'Value',find(strcmp(get(hnoisetype,'String'),model.noisetype)))
02435 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02436 % Callback for setting the type of noise to add to the input images.
02437 %
02438 % @param source the gui component that called this.
02439 % @param eventdata relates to the event of activating the gui component.
02440 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02441     function hnoisetype_Callback(source,eventdata)
02442         % Determine the selected data set.
02443         str = get(source, 'String');
02444         val = get(source,'Value');
02445         % Set current data to the selected data set.
02446         model.noisetype = str{val};
02447         
02448         set(hdescriptiontext,'String','The type of noise to be added to the image when doing reconstructions (and therefore denoising). The types are processed in reconAll.m. This does ntohing for training.');
02449     end
02450 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02451 
02452 
02453 
02454 
02455 
02456 
02457 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02458 % How often to save and plot.
02459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02460 %%%%%%%%%%
02461 %% Plot Results?
02462 hplotchecktext = uicontrol('Style','text',...
02463     'String','Plot Results?',...
02464     'HorizontalAlignment','left',...
02465     'Position',[810,63,100,15]);
02466 % Value to save results or not. 0 for not, value indicates umber of epochs.
02467 hplotcheck = uicontrol('Style','edit',...
02468     'String','0',...
02469     'Position',[900,58,90,25],...
02470     'BackgroundColor',[0.7 0.8 0.7],...
02471     'Callback',{@hplotcheck_Callback});
02472 % Set the check for the plotting of results.
02473 set(hplotcheck,'Value',model.PLOT_RESULTS);
02474 set(hplotcheck,'String',num2str(model.PLOT_RESULTS));
02475 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02476 % Callback for setting if you want to plot the results.
02477 %
02478 % @param source the gui component that called this.
02479 % @param eventdata relates to the event of activating the gui component.
02480 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02481     function hplotcheck_Callback(hObject,eventdata)
02482         set(hdescriptiontext,'String','When checked, figures will be plotted. This may require to run with jvm activated. Which figures to plot should be set in train_recon_phase_all.m. They are plotted after each batch for each of this many epochs.');
02483         % Display surf plot of the currently selected data.
02484         user_string = get(hObject,'String');
02485         model.PLOT_RESULTS = str2double(user_string);
02486         model.PLOT_RESULTS
02487     end
02488 
02489 %%%%%%%%%%
02490 %% Save the .mat files.
02491 hsavechecktext = uicontrol('Style','text',...
02492     'String','Save Results:',...
02493     'HorizontalAlignment','left',...
02494     'Position',[810,38,100,15]);
02495 % Value to save results or not. 0 for not, value indicates umber of epochs.
02496 hsavecheck = uicontrol('Style','edit',...
02497     'String','0',...
02498     'Position',[900,33,90,25],...
02499     'BackgroundColor',[0.7 0.8 0.7],...
02500     'Callback',{@hsavecheck_Callback});
02501 % Set the check for saving results or not.
02502 set(hsavecheck,'Value',model.SAVE_RESULTS);
02503 set(hsavecheck,'String',num2str(model.SAVE_RESULTS));
02504 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02505 % Callback for setting if you want to save the results.
02506 %
02507 % @param source the gui component that called this.
02508 % @param eventdata relates to the event of activating the gui component.
02509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02510     function hsavecheck_Callback(hObject,eventdata)
02511         set(hdescriptiontext,'String','If set greater than 0, then results will be saved each set number of epochs.');
02512         
02513         % Display surf plot of the currently selected data.
02514         user_string = get(hObject,'String');
02515         model.SAVE_RESULTS = str2double(user_string);
02516         
02517     end
02518 
02519 
02520 
02521 
02522 
02523 
02524 
02525 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02526 % Where to run and run button
02527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02528 %% Dropdown for where to launch Job?
02529 hmachine = uicontrol('Style','popupmenu',...
02530     'String',{' laptop',' local_server',' blakey',' dizz',' django',' hamlet',' horatio',' humair',' monk',' texier',' greendotblade1',' greendotblade3',' greendotblade4',' ceres',' iris',' juno'},...
02531     'Position',[1025,58,150,25],...
02532     'Callback',{@hmachine_Callback});
02533 % Set the default for the location to run the experiment.
02534 set(hmachine,'Value',find(strcmp(get(hmachine,'String'),model.machine)))
02535 machine_temp = model.machine; % Defuault for the name of the xterm window.
02536 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02537 % Callback for setting the location to run the experiment.
02538 %
02539 % @param source the gui component that called this.
02540 % @param eventdata relates to the event of activating the gui component.
02541 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02542     function hmachine_Callback(source,eventdata) %#ok<INUSD>
02543         % Determine the selected data set.
02544         str = get(source, 'String');
02545         val = get(source,'Value');
02546         
02547         % Set where to launch it when Run is pressed.
02548         model.machine = str;
02549         % Set current data to the selected data set.
02550         switch str{val};
02551             case ' laptop' % User selects Local Processing
02552                 model.machine = ' laptop';
02553                 set(hdescriptiontext,'String',strcat('Run the job on the local machine in a new window if Run is pressed. Alternatively press save and type the expfile name to run. Note: this cannot be run from the servers.'));
02554             case ' local_server'
02555                 model.machine = ' local_server';
02556                 set(hdescriptiontext,'String',strcat('Run will not do anything when this machine is selected. Just press Save and then type the experiment you want to run. Note: this cannot be run from the laptop.'));
02557             case ' blakey'
02558                 model.machine = ' [email protected]';
02559                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02560             case ' dizz'
02561                 model.machine = ' [email protected]';
02562                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02563             case ' django'
02564                 model.machine = ' [email protected]';
02565                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02566             case ' hamlet'
02567                 model.machine = ' [email protected]';
02568                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02569             case ' horatio'
02570                 model.machine = ' [email protected]';
02571                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02572             case ' humair'
02573                 model.machine = ' [email protected]';
02574                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02575             case ' monk'
02576                 model.machine = ' [email protected]';
02577                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02578             case ' texier'
02579                 model.machine = ' [email protected]';
02580                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02581             case ' greendotblade1'
02582                 model.machine = ' [email protected]';
02583                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02584             case ' greendotblade3'
02585                 model.machine = ' [email protected]';
02586                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02587             case ' greendotblade4'
02588                 model.machine = ' [email protected]';
02589                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02590             case ' ceres'
02591                 model.machine = ' [email protected]';
02592                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02593             case ' iris'
02594                 model.machine = ' [email protected]';
02595                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02596             case ' juno'
02597                 model.machine = ' [email protected]';
02598                 set(hdescriptiontext,'String',strcat('Run the job on ',model.machine));
02599         end
02600         machine_temp = str{val}; % to set the default back afterwards
02601         
02602         
02603         
02604     end
02605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02606 
02607 
02608 
02609 
02610 % %%%%%%%%%%
02611 % %% Plot Last button
02612 % hplot_last = uicontrol('Style','pushbutton',...
02613 %     'String','LastFigs',...
02614 %     'Position',[625,10,50,25],...
02615 %     'Callback',[email protected]_last_Callback});
02616 %     function hplot_last_Callback(source,eventdata)
02617 %         plot_last % Doesn't work since the workspace is within this gui
02618 %         function.
02619 %     end
02620 
02621 %%%%%%%%%%
02622 %% History GUI button
02623 hhistorybutton = uicontrol('Style','pushbutton',...
02624     'String','History',...
02625     'Position',[1025,35,50,25],...
02626     'Callback',[email protected]_Callback});
02627 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02628 % Callback for closing all windows except the gui.
02629 %
02630 % @param source the gui component that called this.
02631 % @param eventdata relates to the event of activating the gui component.
02632 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02633     function hhistory_Callback(source,eventdata)
02634         set(hdescriptiontext,'String','A list of the runs created by this gui will be shown in the command window (along with their important parameters).')
02635         if(exist([GUI_DIRECTORY 'history.txt'],'file'))
02636             type([GUI_DIRECTORY 'history.txt']);
02637         else
02638             set(hdescriptiontext,'String','No history.txt file exists.')
02639         end
02640     end
02641 
02642 
02643 %%%%%%%%%%
02644 %% Close Except GUI button
02645 hcloseexceptbutton = uicontrol('Style','pushbutton',...
02646     'String','Close Ex',...
02647     'Position',[1075,35,50,25],...
02648     'Callback',[email protected]_except_Callback});
02649 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02650 % Callback for closing all windows except the gui.
02651 %
02652 % @param source the gui component that called this.
02653 % @param eventdata relates to the event of activating the gui component.
02654 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02655     function hclose_except_Callback(source,eventdata)
02656         handles.figure1 = source;
02657         pos_size = get(handles.figure1,'Position');
02658         % Call modaldlg with the argument 'Position'.
02659         user_response = clrlast('Title','Close Other Figures?','String','Do you want to close other windows except for this current gui window and window 999 (standard gui window)?');
02660         switch user_response
02661             case {'No'}
02662                 % take no action
02663                 set(hdescriptiontext,'String','No Windows Closed.');
02664             case 'Yes'
02665                 closeexcept(fgui,999);
02666                 set(hdescriptiontext,'String','Closed other windows except for this current gui window and window 999 (standard gui window).')
02667                 
02668         end
02669     end
02670 
02671 % %%%%%%%%%%
02672 % %% Cluster Usage button
02673 % uicontrol('Style','pushbutton',...
02674 %     'String','Usage',...
02675 %     'Position',[1075,10,50,25],...
02676 %     'Callback',[email protected]_usage_Callback});
02677 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02678 % % Callback for running cluster_usage.
02679 % %
02680 % % @param source the gui component that called this.
02681 % % @param eventdata relates to the event of activating the gui component.
02682 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02683 %     function hcluster_usage_Callback(source,eventdata)
02684 %         set(hdescriptiontext,'String','See Command Window for updated cluster usage.')
02685 %
02686 %         eval('!/home/gwtaylor/bin/cluster_usage --refresh');
02687 %     end
02688 
02689 %%%%%%%%%%
02690 %% Cluster Usage button
02691 hloadbutton = uicontrol('Style','pushbutton',...
02692     'String','Load',...
02693     'Position',[1075,10,50,25],...
02694     'Callback',{@hload_Callback});
02695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02696 % Callback for running cluster_usage.
02697 %
02698 % @param source the gui component that called this.
02699 % @param eventdata relates to the event of activating the gui component.
02700 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02701     function hload_Callback(source,eventdata)
02702         set(hdescriptiontext,'String',['Load model parameters from file (located at the Model Directory location): ' model.fullmodelpath'.'])
02703                 
02704         handles.figure1 = source;
02705         pos_size = get(handles.figure1,'Position');
02706         % Call modaldlg with the argument 'Position'.
02707         if(exist([START_RESULTS_DIRECTORY model.modeldirectory])==0 && exist(model.fullmodelpath,'file')==0)
02708             set(hdescriptiontext,'String',['Model Directory: ' model.fullmodelpath ' Does Not Exist']);
02709             model.load_from_previous = 0;
02710         else
02711             user_response = clrlast('Title','Load Params from Model Directory?','String',['Model Directory is set as: ',model.fullmodelpath,'    Click Yes to use these parameters in the GUI.']);
02712             switch user_response
02713                 case {'No'}
02714                     % take no action
02715                     set(hdescriptiontext,'String','No Params Loaded.');
02716                     model.load_from_previous = 0;        
02717                 case 'Yes'
02718                     model.load_from_previous = 1;
02719                     update_defaults
02720             end
02721         end                
02722     end
02723 
02724 % %%%%%%%%%%
02725 % %% Clean the ./Reslts directory button
02726 % uicontrol('Style','pushbutton',...
02727 %     'String','Clean',...
02728 %     'Position',[1075,35,50,25],...
02729 %     'Callback',[email protected]_results_Callback});
02730 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02731 % % Callback for cleaning the results directory.
02732 % %
02733 % % @param source the gui component that called this.
02734 % % @param eventdata relates to the event of activating the gui component.
02735 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02736 %     function hclean_results_Callback(source,eventdata)
02737 %         if(strcmp(model.machine,' laptop'))
02738 %             %             clean_results_dir('./Results')
02739 %             set(hdescriptiontext,'String','Cleaning /A/Results directories of empty subdirectories and empty runs.')
02740 %         else
02741 %             %             clean_results_dir('/misc/FergusGroup/zeiler/Results/trainAll')
02742 %             set(hdescriptiontext,'String','Cleaning /misc/FergusGroup/zeiler/Results directories of empty subdirectories and empty runs.')
02743 %         end
02744 %     end
02745 
02746 %%%%%%%%%
02747 %% Clear the last saved run directory the ./Reslts directory button
02748 hclrlastbutton = uicontrol('Style','pushbutton',...
02749     'String','Clr Last',...
02750     'Position',[1125,35,50,25],...
02751     'Callback',{@hclear_last_results_Callback});
02752 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02753 % Callback for clearning the last experiment.
02754 %
02755 % @param source the gui component that called this.
02756 % @param eventdata relates to the event of activating the gui component.
02757 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02758     function hclear_last_results_Callback(source,eventdata,handles)
02759         % to pass to the modal dialog.
02760         
02761         handles.figure1 = source;
02762         pos_size = get(handles.figure1,'Position');
02763         % Call modaldlg with the argument 'Position'.
02764         if(exist(model.fullsavepath,'dir')==0)
02765             set(hdescriptiontext,'String',['Previous Run Directory: ' model.fullsavepath ' Does Not Exist']);
02766         else
02767             user_response = clrlast('Title','Delete Last Saved Directory?','String',['Last Save was: ',model.fullsavepath]);
02768             switch user_response
02769                 case {'No'}
02770                     % take no action
02771                     set(hdescriptiontext,'String','No Run Cleared');
02772                 case 'Yes'
02773                     % Prepare to close GUI application window
02774                     if(model.SAVE_RESULTS>0)
02775                         set(hdescriptiontext,'String',sprintf('Cleared the %s directory.',clear_last('gui_has_set_the_params')))
02776                     else
02777                         set(hdescriptiontext,'String','No Run Cleared');
02778                     end
02779             end
02780         end
02781     end
02782 
02783 
02784 %%%%%%%%%
02785 %% Set the parameters to defaults.
02786 hdefaultsbutton = uicontrol('Style','pushbutton',...
02787     'String','Defaults',...
02788     'Position',[1025,10,50,25],...
02789     'Callback',{@hdefaults_Callback});
02790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02791 % Callback for setting the parameters to defaults.
02792 %
02793 % @param source the gui component that called this.
02794 % @param eventdata relates to the event of activating the gui component.
02795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02796     function hdefaults_Callback(source,eventdata,handles)
02797         % to pass to the modal dialog.
02798         handles.figure1 = source;
02799         pos_size = get(handles.figure1,'Position');
02800         % Call modalfig 
02801         user_response = clrlast('Title','Set all parameters to defaults?','String',[' Do you want to overwrite the current paramters with the default parameters in gui_defaults.mat?']);
02802         switch user_response
02803             case {'No'}
02804                 % take no action
02805                 set(hdescriptiontext,'String','No Parameters Overwritten');
02806             case 'Yes'
02807                 % Prepare to close GUI application window
02808                 A = load('gui_defaults.mat');
02809                 model = A.model;
02810                 model.savedirectory = '/Results/+';
02811                 rmfield(model,'fullsavepath');
02812                 rmfield(model,'fullmodelpath');
02813                 rmfield(model,'fulldatapath');
02814                
02815                 clear A
02816                 update_defaults
02817                 set(hdescriptiontext,'String','Parameters set to defaults successfully.');
02818                 
02819         end
02820         
02821     end
02822 
02823 
02824 
02825 %%%%%%%%%%
02826 %% Save button
02827 % Does everything the run button dows, except running the experiment.
02828 hsavebutton = uicontrol('Style','pushbutton',...
02829     'String','Save',...
02830     'Position',[1125,10,50,25],...
02831     'Callback',{@hsave_Callback});
02832 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02833 % Callback for saving the model parameters to run in a separate window (at a
02834 % later time).
02835 %
02836 % @param source the gui component that called this.
02837 % @param eventdata relates to the event of activating the gui component.
02838 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02839     function hsave_Callback(source,eventdata)
02840         
02841         % Update the Connectivity Matrices
02842         hupdate_conmats_Callback([],[])
02843         
02844         % Clean the results directory before generating a new save directory.
02845         % hclean_results_Callback([],[])
02846         
02847         % Make sure the save directory is reset to the current gui one.
02848         % This is needed when doing multiple runs from the gui.
02849         model.savedirectory = get(hsavedirectory,'String');
02850         % Same with the data directory.
02851         model.datadirectory = get(hdatadirectory,'String');
02852         % Same with the model directory
02853         model.modeldirectory = get(hmodeldirectory,'String');
02854                                                                   
02855         % Remove training slash in directory names.
02856         if(strcmp(START_RESULTS_DIRECTORY(end),'/'))
02857             START_RESULTS_DIRECTORY = START_RESULTS_DIRECTORY(1:end-1);
02858         end
02859         if(strcmp(START_DATASET_DIRECTORY(end),'/'))
02860             START_DATASET_DIRECTORY = START_DATASET_DIRECTORY(1:end-1);
02861         end                
02862         
02863         %%%%%%%%%
02864         % Check paths exist
02865         %%%%%%%%%
02866         % Data path can be a file or directory.
02867         if(check_imgs_path([START_DATASET_DIRECTORY,model.datadirectory])==0)
02868             warning(sprintf('Data Directory set in gui: \n%s\ndoes not exist or does not contain any files.\n',[START_DATASET_DIRECTORY,model.datadirectory]))
02869             set(hdescriptiontext,'String','WARNING: data directory does not exist. Make sure the start paths at the top of gui.m are set and your datadirectory below is set.');
02870             fprintf('XXXXX\nModel parameters not saved due to above errors.\nXXXXX\n');
02871             return;
02872         end
02873         % Save path can have a '+' at end or has to be a directory
02874         if(strcmp(model.savedirectory(end),'+')==0 && ...
02875                 exist([START_DATASET_DIRECTORY,model.savedirectory],'dir')==0)
02876             warning(sprintf('Save Directory set in gui:\n%s\ndoes not exist and is not /Results/+ (set to auto-gen).\n',[START_DATASET_DIRECTORY,model.savedirectory]))
02877             set(hdescriptiontext,'String','WARNING: save directory does not exist. Make sure the start paths at the top of gui.m are set and your savedirectory below is set to a real directory or /Results/+ (to autogen a path)');
02878             fprintf('XXXXX\nModel parameters not saved due to above errors.\nXXXXX\n');
02879             return;
02880         end        
02881         % Model path has to be a previous .mat file.
02882         % Don't know when you need the modeldirectory.
02883 %         if(exist([START_DATASET_DIRECTORY,model.modeldirectory],'file')==0)
02884 %             warning(sprintf('Model File path set in gui:\n%s\n does not exist.\n',[START_DATASET_DIRECTORY,model.modeldirectory]))
02885 %             set(hdescriptiontext,'String','WARNING: model path does not exist. Make sure the start paths at the top of gui.m are set and your modeldirectory points to a valid .mat file.');
02886 %             fprintf('XXXXX\nModel parameters not saved due to above errors.\nXXXXX\n');
02887 %             return;
02888 %         end                
02889         
02890         
02891         % Generate the fullsavepath, fullmodelpath, and fulldatapath.
02892         model = gen_directories(model,START_RESULTS_DIRECTORY,START_DATASET_DIRECTORY);
02893         
02894         try
02895             [header,impparams] = model_summary(model);
02896         catch %#ok<*CTCH>
02897             %             summary = '';
02898             header = sprintf('model_summary generation failed, still continuing with:\n%s',model.fullsavepath);
02899             impparams = [];
02900         end
02901         
02902         % Save the parameters, then load them for the experiment to run.
02903         % This is done regardless of saving the results or not.
02904         %         if(strcmp(model.machine,' laptop'))
02905         save(strcat(GUI_DIRECTORY,'gui_has_set_the_params.mat'),'model');
02906         historypath = [GUI_DIRECTORY 'history.txt'];
02907         %         else
02908         %             save(strcat(SERVER_GUI_DIRECTORY,'GUI/gui_has_set_the_params.mat'),'model');
02909         %             historypath = [SERVER_GUI_DIRECTORY 'GUI/history.txt'];
02910         %         end
02911         
02912         % Record the model params in the history file.
02913 %         if(model.SAVE_RESULTS>0)
02914             appendhistory = sprintf('\n------------------------------------------------------------------------------------------------------------------------------------------------------\n%s:\n%s\n%s',current_time(now),header,impparams);
02915             historyfile = fopen(historypath,'a');
02916             fprintf(historyfile,'%s',appendhistory);
02917             fclose(historyfile);
02918 %         end
02919         
02920         disp(model.fullmodelpath)
02921         disp(model.fulldatapath)
02922         disp(model.fullsavepath)
02923         
02924         
02925 
02926         if(model.SAVE_RESULTS>0)
02927             fprintf('%s\n',appendhistory);
02928         end
02929         % Update teh description display to say which
02930         % expereiment is run where.
02931         if(model.SAVE_RESULTS>0)
02932             savedescstring = ['model params saved to:./GUI/gui_has_set_the_params.mat so now run: ''',model.expfile,''' at the matlab command. ',...
02933                 'Results will save to: ',' ...',model.savedirectory];
02934         else
02935             savedescstring = ['model params saved to:./GUI/gui_has_set_the_params.mat so now run: ''',model.expfile,''' at the matlab command. ',...
02936                 'Not saving results, this is good for debugging, running interactively, or saving disk space!'];
02937         end
02938         
02939         set(hdescriptiontext,'String',savedescstring);        
02940         if(strcmp(model.exptype,'Continue Training On Top'))
02941             fprintf('\nSave Complete\n\nType "%s" at the matlab command prompt to run.\n','trainAll');
02942         else
02943             fprintf('\nSave Complete\n\nType "%s" at the matlab command prompt to run.\n',model.expfile(2:end));
02944         end
02945     end
02946 
02947 %%%%%%%%%%
02948 % Run button
02949 hrunbutton = uicontrol('Style','pushbutton',...
02950     'String','Run',...
02951     'Position',[1125,35,50,25],...
02952     'Callback',{@hrun_Callback});
02953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
02954 % Callback for opening a new window to run the saved parameter's experiment.
02955 %
02956 % @param source the gui component that called this.
02957 % @param eventdata relates to the event of activating the gui component.
02958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
02959     function hrun_Callback(source,eventdata)
02960         
02961         % To just view the results, you don't launch xterms.
02962         if(strcmp(model.exptype,'View Figures')==0 &&...
02963                 strcmp(model.exptype,'List Results')==0)
02964             
02965             % Call the saveing routine to save to ./GUI/ser_parameters.mat
02966             hsave_Callback([],[])
02967             
02968             
02969             
02970             %%%%%%%%
02971             %% Customize the window title here
02972             % Have to remove the space for the title of the new xterm window.
02973             %         window_title = str2mat(model.expfile);
02974             %         window_title = window_title(2:end);
02975             %         window_title = mat2str(window_title);
02976             window_title = model.savedirectory;
02977             %%%%%%%%
02978             
02979             % if you are plotting the results, you need the jvm on.
02980             % Or if you're not training then you need java to save the result figures.
02981             if(model.PLOT_RESULTS>0 || ...
02982                     model.SAVE_RESULTS>0 ||...  % Saving needs the figures now.
02983                     (strcmp(model.exptype,'Train Layer By Layer')==0 && ...
02984                     strcmp(model.exptype,'Continue Training On Top')==0 && ...
02985                     model.SAVE_RESULTS>0))
02986                 jvm_string = ' ';
02987             else
02988                 jvm_string = ' -nojvm ';
02989             end
02990             
02991             % If running on laptop machine it is a little different (no ssh
02992             % needed).
02993             if(strcmp(model.machine,' laptop'))
02994                 %             eval(strcat('! xterm -T ',model.machine,'-',window_title,' -e matlab -nojvm -nosplash -r ',model.expfile,' &'));
02995                 eval(strcat('! xterm -T ',machine_temp,'-',window_title,' -e matlab ',jvm_string,' -nosplash -r ',model.expfile,' &'));
02996                 %         elseif(strcmp(model.machine,' laptop(new window)'))
02997                 %             eval(strcat('! xterm -T ',model.machine,'-',window_title,' -e matlab ',jvm_string,' -nosplash -r ',model.expfile,' &'));
02998             elseif(strcmp(model.machine,' local_server'))
02999                 % eval(strcat('! xterm -e matlab ',jvm_string,' -nosplash -r ',model.expfile,' &'));
03000                 eval(strcat('! xterm -T ',machine_temp,'-',window_title,' -e matlab ',jvm_string,' -nosplash -r ',model.expfile,' &'));
03001                 %            fprintf(strcat('Just type "',model.expfile,'" at the matlab command line since running on "local_server".\n'));
03002             else
03003                 if(strcmp(jvm_string,' ')) % need to start with java
03004                     %                     eval(strcat('! xterm -T ',machine_temp,'-',window_title,' -e bash ',char(32),SERVER_GUI_DIRECTORY,'GUI/start_server_java.sh ',model.machine,' ',model.expfile,' &'))
03005                     
03006                     eval(['! xterm -T ',machine_temp,'-',window_title,' -e bash ',GUI_DIRECTORY,'start_server_java.sh ',model.machine,' ',model.expfile,' &'])
03007                     %eval(strcat('! mrxvt -desktop 0 -title ',model.machine,' -e bash ./GUI/start_server_java.sh ',model.machine,' ',model.expfile,' &'))
03008                     
03009                 else
03010                     
03011                     %eval(strcat('! mrxvt -desktop 0 -title ',model.machine,' -e bash ./GUI/start_server.sh ',model.machine,' ',model.,' &'))
03012                     % Opens a new terminal window, name it with the server-experiment_name, sets the present working directory to this one, and starts the expfile on the server of choice in model.machine.
03013                     eval(['! xterm -ls -T ',machine_temp,'-',window_title,' -e bash ',GUI_DIRECTORY,'start_server.sh ',model.machine,' ',model.expfile,' &'])
03014                 end
03015             end
03016             
03017             % Update teh description display to say which
03018             % expereiment is run where.
03019             set(hdescriptiontext,'String',...
03020                 strcat(model.exptype,' will be run on the ',model.machine,' machine, with results saved in: ',model.savedirectory));
03021             
03022         else % Launch the viewing of results in the command line.
03023             
03024             %%%%%%%%%
03025             % Setup fullmodelpath
03026             % Loading a model specified the full model path to the file.
03027             if(strcmp(model.modeldirectory,'not used'))
03028                 model.fullmodelpath = model.modeldirectory;
03029             else
03030                 % If running locally, then use the pwd which contains Results
03031                 if(strcmp(model.machine,' laptop'))
03032                     model.fullmodelpath = strcat(LAPTOP_RESULTS_DIRECTORY,model.modeldirectory);
03033                 else % Otherwise, use the raid array.
03034                     model.fullmodelpath = strcat(SERVER_RESULTS_DIRECTORY,model.modeldirectory);
03035                 end
03036             end
03037             %%%%%%%%%%
03038             
03039             % To just view the results, you don't set up any save directories.
03040             if(strcmp(model.exptype,'View Figures'))
03041                 fprintf('\n\n')
03042                 if(isempty(model.datadirectory))
03043                     view_results(model.fullmodelpath,'list')
03044                     
03045                     user_entry = input('Do you want to plot all these figures? (y/n):\n','s');
03046                     if(strcmp(user_entry,'y') || strcmp(user_entry,'yes'))
03047                         % Show them
03048                         view_results(model.fullmodelpath);
03049                     end
03050                 elseif(strcmp(model.datadirectory,'recurse'))
03051                     view_results(model.fullmodelpath,'list recurse')
03052                     user_entry = input('Do you want to plot all these figures? (y/n):\n','s');
03053                     if(strcmp(user_entry,'y') || strcmp(user_entry,'yes'))
03054                         % Show them
03055                         view_results(model.fullmodelpath,'recurse');
03056                     end
03057                 else
03058                     view_results(model.fullmodelpath,model.datadirectory)
03059                 end
03060                 fprintf('\n\n')
03061             elseif(strcmp(model.exptype,'List Results'))
03062                 fprintf('\n\n')
03063                 if(isempty(model.datadirectory))
03064                     
03065                     list_results(model.fullmodelpath)
03066                 else
03067                     saved_datadirectory = model.datadirectory;
03068                     lenparams = length(model.datadirectory);
03069                     
03070                     % Copy the string fo paraemters into a cell array.
03071                     index = 1;
03072                     for i = lenparams:-1:1
03073                         if(strcmp(model.datadirectory(i),','))
03074                             paramsCell{index} = model.datadirectory(i+1:end);
03075                             index = index+1;
03076                             model.datadirectory = model.datadirectory(1:i-1);
03077                         end
03078                     end
03079                     % Get the last paraemter.
03080                     paramsCell{index} = model.datadirectory;
03081                     % Restore the datadirectory.
03082                     model.datadirectory = saved_datadirectory;
03083                     
03084                     newstr = '';
03085                     for i=1:length(paramsCell)
03086                         if(i==length(paramsCell))
03087                             newstr = strcat(char(39),paramsCell{i},char(39),newstr);
03088                         else
03089                             newstr = strcat(',',char(39),paramsCell{i},char(39),newstr);
03090                         end
03091                     end
03092                     eval(strcat('list_results(model.fullmodelpath,',newstr,');'))
03093                     
03094                     
03095                     %                     list_results(model.fullmodelpath,model.datadirectory);
03096                 end
03097                 fprintf('\n\n')
03098                 
03099             end
03100             
03101         end
03102         
03103         
03104     end
03105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03106 
03107 
03108 
03109 
03110 
03111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03112 %% Set other defaults that depend on the above
03113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
03115 % Update the visibility of gui components based on the experiment and settings.
03116 %
03117 % @param source the gui component that called this.
03118 % @param eventdata relates to the event of activating the gui component.
03119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03120     function update_visibility()
03121         
03122         
03123         layers = get(hnum_layers,'Value');
03124         phases = get(hnum_phases,'Value');
03125         layerNames = cell(1,10);
03126         phaseNames = cell(1,10);
03127         for i=1:10
03128             if(i<=layers)
03129                 layerNames{i} = strcat('L',num2str(i));
03130             else
03131                 layerNames{i} = 'Off';
03132             end
03133             
03134             if(i<=phases)
03135                 phaseNames{i} = strcat('P',num2str(i));
03136             else
03137                 phaseNames{i} = 'Off';
03138             end
03139         end
03140         set(hlayerspecifictable,'RowName',layerNames);
03141         set(hphasespecifictable,'RowName',phaseNames);
03142         
03143         set(hlambdatable,'RowName',layerNames);
03144         set(halphatable,'RowName',layerNames);
03145         set(hgammatable,'RowName',layerNames);
03146         set(hkappatable,'RowName',layerNames);
03147         set(hBinitialtable,'RowName',layerNames);
03148         set(hBmultipliertable,'RowName',layerNames);
03149         set(hFabovetable,'RowName',layerNames);
03150         set(hlambdatable,'ColumnName',phaseNames);
03151         set(halphatable,'ColumnName',phaseNames);
03152         set(hgammatable,'ColumnName',phaseNames);
03153         set(hkappatable,'ColumnName',phaseNames);
03154         set(hBinitialtable,'ColumnName',phaseNames);
03155         set(hBmultipliertable,'ColumnName',phaseNames);
03156         set(hFabovetable,'ColumnName',phaseNames);
03157         
03158         
03159         % Visibility of parameters only for training
03160         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03161                 strcmp(model.exptype,'Train 2-Layer Joint Method'))
03162             set(hnum_layers,'Visible','on')
03163             set(hnum_phases,'Visible','off')
03164             set(hp1,'Title','Type of Experiment:                           Layers:')
03165         elseif(strcmp(model.exptype,'Train New Model') ||...
03166                 strcmp(model.exptype,'Continue Training On Top'))
03167             set(hp1,'Title','Type of Experiment:                        Layers:           Phases:')
03168             set(hnum_layers,'Visible','on')
03169             set(hnum_phases,'Visible','on')
03170         elseif(strcmp(model.exptype,'Reconstruct Using Trained Model') || strcmp(model.exptype,'Generate Video'))
03171             set(hnum_layers,'Visible','off')
03172             set(hnum_phases,'Visible','on')
03173         else
03174             % 'Top Down', 'Top Down Sampling'
03175             set(hnum_layers,'Visible','off')
03176             set(hp1,'Title','Type of Experiment:                             Noise Type:')
03177             set(hnum_phases,'Visible','off')
03178         end
03179         
03180         if(strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03181                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method'))
03182             set(hinit1stcheck,'Visible','on');
03183         else
03184             set(hinit1stcheck,'Visible','off');
03185         end
03186         
03187         % Image procesing parameters.
03188         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03189                 strcmp(model.exptype,'Continue Training On Top') ||...
03190                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03191                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03192                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03193                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03194                 strcmp(model.exptype,'Generate Video') ||...
03195                 strcmp(model.exptype,'Train New Model'))
03196             set(hcolorcheck,'Visible','on');
03197             set(hzeromeancheck,'Visible','on');
03198             set(hsquarecheck,'Visible','on');
03199             set(hcontrastcheck,'Visible','on');
03200             set(hdisperror,'Visible','on');
03201             set(hdisperrortext,'Visible','on');
03202             set(hgpucheck,'Visible','on');
03203         else
03204             set(hcolorcheck,'Visible','off');
03205             set(hzeromeancheck,'Visible','off');
03206             set(hsquarecheck,'Visible','off');
03207             set(hcontrastcheck,'Visible','off');
03208             set(hdisperror,'Visible','off');
03209             set(hdisperrortext,'Visible','off');
03210             set(hgpucheck,'Visible','off');
03211         end
03212         % Don't show that GPU can be used if is
03213         if(~exist('GPUstart.m','file') || ~exist('startGPU.m','file') ||...
03214                 ~exist([fileparts(which('GPUstart.m')) '/modules/mdz'],'dir'))
03215             set(hgpucheck,'Visible','off');
03216             model.USE_GPU = 0;
03217         end
03218         
03219         
03220         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03221                 strcmp(model.exptype,'Continue Training On Top') ||...
03222                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03223                 strcmp(model.exptype,'Train New Model'))
03224             
03225             %             set(hippcheck,'Visible','on');
03226             set(htime_layertext,'Visible','on');
03227             set(htime_layer,'Visible','on');
03228             set(hprev_frames,'Visible','on');
03229             set(hprev_framestext,'Visible','on');
03230             set(hlimittimecheck,'Visible','on');
03231         else
03232             %             set(hippcheck,'Visible','off');
03233             set(htime_layertext,'Visible','off');
03234             set(htime_layer,'Visible','off');
03235             set(hprev_frames,'Visible','off');
03236             set(hprev_framestext,'Visible','off');
03237             set(hlimittimecheck,'Visible','off');
03238         end
03239         
03240         
03241         % Only different parameter for Generate Video
03242         if(strcmp(model.exptype,'Generate Video'))
03243             set(hgen_frames,'Visible','on');
03244             set(hgen_framestext,'Visible','on');
03245         else
03246             set(hgen_frames,'Visible','off');
03247             set(hgen_framestext,'Visible','off');
03248         end
03249         
03250         
03251         set(hbatchsizetext,'Visible','on');
03252         set(hemailtext,'Visible','on');
03253         
03254         
03255         % Training Parameters
03256         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03257                 strcmp(model.exptype,'Continue Training On Top') ||...
03258                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03259                 strcmp(model.exptype,'Train New Model'))
03260             %             set(hbatchsize,'Visible','on');
03261             set(hthreshold,'Visible','on');
03262             set(hthresholdtext,'Visible','on');
03263             set(hposzcheck,'Visible','on');
03264         else
03265             %             set(hbatchsize,'Visible','off');
03266             set(hthreshold,'Visible','off');
03267             %             set(hbatchsizetext,'Visible','off');
03268             set(hthresholdtext,'Visible','off');
03269             set(hposzcheck,'Visible','off');
03270         end
03271         
03272         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03273                 strcmp(model.exptype,'Continue Training On Top') ||...
03274                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03275                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03276                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03277                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03278                 strcmp(model.exptype,'Generate Video')||...
03279                 strcmp(model.exptype,'Train New Model'))
03280             set(hminiterationstext,'Visible','on');
03281             set(hminiterations,'Visible','on');
03282             set(himageordercheck,'Visible','on');
03283         else
03284             set(hminiterations,'Visible','off');
03285             set(hminiterationstext,'Visible','off');
03286             set(himageordercheck,'Visible','off');
03287         end
03288         
03289         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03290                 strcmp(model.exptype,'Train 2-Layer Joint Method') || ...
03291                 strcmp(model.exptype,'Continue Training On Top')||....
03292                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03293                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03294                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03295                 strcmp(model.exptype,'Generate Video')||...
03296                 strcmp(model.exptype,'Train New Model'))
03297             set(hframestext,'Visible','on');
03298             set(hframes1,'Visible','on');
03299             set(hframes2,'Visible','on');
03300             set(hframes3,'Visible','on');
03301         else
03302             set(hframestext,'Visible','off');
03303             set(hframes1,'Visible','off');
03304             set(hframes2,'Visible','off');
03305             set(hframes3,'Visible','off');
03306         end
03307         
03308         % Set Model parameters
03309         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03310                 strcmp(model.exptype,'Continue Training On Top') ||...
03311                 strcmp(model.exptype,'Train 2-Layer Joint Method') || ...
03312                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03313                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03314                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03315                 strcmp(model.exptype,'Generate Video')||...
03316                 strcmp(model.exptype,'Train New Model'))
03317             
03318             set(hramplambda,'Visible','on');
03319             
03320             set(hlambdatable,'Visible','on');
03321             set(halphatable,'Visible','on');
03322             set(hgammatable,'Visible','on');
03323             set(hkappatable,'Visible','on');
03324             set(hBinitialtable,'Visible','on');
03325             set(hBmultipliertable,'Visible','on');
03326             set(hFabovetable,'Visible','on');
03327             
03328             set(hinfer_usingtext,'Visible','on');
03329             set(hinfer_using,'Visible','on');
03330             set(hramplambdatext,'Visible','on');
03331         else
03332             set(hlambdatable,'Visible','off');
03333             set(halphatable,'Visible','off');
03334             set(hgammatable,'Visible','off');
03335             set(hkappatable,'Visible','off');
03336             set(hBinitialtable,'Visible','off');
03337             set(hBmultipliertable,'Visible','off');
03338             set(hFabovetable,'Visible','off');
03339             
03340             set(hinfer_usingtext,'Visible','off');
03341             set(hinfer_using,'Visible','off');
03342             set(hramplambdatext,'Visible','off');
03343         end
03344         
03345         
03346         
03347         % z0 parameters
03348         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03349                 strcmp(model.exptype,'Continue Training On Top') ||...
03350                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03351                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03352                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03353                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03354                 strcmp(model.exptype,'Generate Video')||...
03355                 strcmp(model.exptype,'Train New Model'))
03356             set(hpsi,'Visible','on');
03357             set(hzsize,'Visible','on');
03358             set(htrainz0check,'Visible','on');
03359             set(hpsitext,'Visible','on');
03360             set(hzsizetext,'Visible','on');
03361         else
03362             set(hpsi,'Visible','off');
03363             set(hzsize,'Visible','off');
03364             set(htrainz0check,'Visible','off');
03365             set(hpsitext,'Visible','off');
03366             set(hzsizetext,'Visible','off');
03367         end
03368         % Model directoryies.
03369         if(strcmp(model.exptype,'Continue Training On Top') ||...
03370                 strcmp(model.exptype,'Top Down Visualize')||...
03371                 strcmp(model.exptype,'Top Down Sampling') ||...
03372                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03373                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method') ||...
03374                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03375                 strcmp(model.exptype,'Generate Video')||...
03376                 strcmp(model.exptype,'View Figures') ||...
03377                 strcmp(model.exptype,'List Results') ||...
03378                 strcmp(model.exptype,'Load Params From Previous Model'))
03379             set(hmodeldirectory,'Visible','on');
03380             set(hmodeldirectorytext,'Visible','on');
03381         else
03382             set(hmodeldirectory,'Visible','off');
03383             set(hmodeldirectorytext,'Visible','off');
03384         end
03385         % Data directoryies.
03386         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03387                 strcmp(model.exptype,'Continue Training On Top') ||...
03388                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03389                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03390                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method') ||...
03391                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03392                 strcmp(model.exptype,'Generate Video')||...
03393                 strcmp(model.exptype,'View Figures') ||...
03394                 strcmp(model.exptype,'List Results')||...
03395                 strcmp(model.exptype,'Train New Model'))
03396             set(hdatadirectory,'Visible','on');
03397             set(hdatadirectorytext,'Visible','on');
03398         else
03399             set(hdatadirectory,'Visible','off');
03400             set(hdatadirectorytext,'Visible','off');
03401         end
03402         % Save directoryies.
03403         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03404                 strcmp(model.exptype,'Continue Training On Top') ||...
03405                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03406                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03407                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03408                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03409                 strcmp(model.exptype,'Generate Video')||...
03410                 strcmp(model.exptype,'Train New Model'))
03411             set(hsavedirectory,'Visible','on');
03412             set(hsavedirectorytext,'Visible','on');
03413         else
03414             set(hsavedirectory,'Visible','off');
03415             set(hsavedirectorytext,'Visible','off');
03416         end
03417         % Save epochs
03418         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03419                 strcmp(model.exptype,'Continue Training On Top') ||...
03420                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03421                 strcmp(model.exptype,'Top Down Visualize')||...
03422                 strcmp(model.exptype,'Top Down Sampling') ||...
03423                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03424                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03425                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03426                 strcmp(model.exptype,'Generate Video')||...
03427                 strcmp(model.exptype,'Train New Model'))
03428             set(hsavecheck,'Visible','on');
03429             set(hsavechecktext,'Visible','on');
03430         else
03431             set(hsavecheck,'Visible','off');
03432             set(hsavechecktext,'Visible','off');
03433         end
03434         
03435         % Just for the viewing of the results functions
03436         if(strcmp(model.exptype,'View Figures') ||...
03437                 strcmp(model.exptype,'List Results'))
03438             set(hplotcheck,'Visible','off')
03439             set(hplotchecktext,'Visible','off')
03440             set(hcompthreads,'Visible','off');
03441             set(hcompthreadstext,'Visible','off');
03442         else
03443             set(hplotcheck,'Visible','on')
03444             set(hplotchecktext,'Visible','on')
03445             set(hcompthreads,'Visible','on');
03446             set(hcompthreadstext,'Visible','on');
03447         end
03448         
03449         
03450         %         % Connectivity Matrix update button
03451         %         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03452         %                 strcmp(model.exptype,'Continue Training On Top') ||...
03453         %                 strcmp(model.exptype,'Train 2-Layer Joint Method') ||...
03454         %                 strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03455         %                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03456         %                 strcmp(model.exptype,'Generate Video')||...
03457         %                 strcmp(model.exptype,'Train New Model'))
03458         %             set(hupdateconmats,'Visible','on')
03459         %         else
03460         %             set(hupdateconmats,'Visible','off')
03461         %         end
03462         
03463         
03464         
03465         
03466         
03467         % Visibility of the layer configurations.
03468         if(strcmp(model.exptype,'Train Layer By Layer') ||...
03469                 strcmp(model.exptype,'Continue Training On Top') ||...
03470                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03471                 strcmp(model.exptype,'Train New Model'))
03472             set(hphasespecifictable,'Visible','on');
03473             set(hlayerspecifictable,'Visible','on');
03474         else
03475             set(hphasespecifictable,'Visible','off');
03476             set(hlayerspecifictable,'Visible','off');
03477         end
03478         
03479         
03480         % Types of noise to add
03481         if(strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03482                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03483                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03484                 strcmp(model.exptype,'Generate Video')||...
03485                 strcmp(model.exptype,'Train Layer By Layer')||...
03486                 strcmp(model.exptype,'Continue Training On Top')||...
03487                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03488                 strcmp(model.exptype,'Train New Model'))
03489             set(hupdate_inputcheck,'Visible','on')
03490             set(hlambda_input,'Visible','on')
03491             set(hlambda_inputtext,'Visible','on')
03492         else
03493             set(hupdate_inputcheck,'Visible','off')
03494             set(hlambda_input,'Visible','off')
03495             set(hlambda_inputtext,'Visible','off')
03496         end
03497         
03498         if(strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03499                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03500                 strcmp(model.exptype,'Reconstruct Using Trained Model')||...
03501                 strcmp(model.exptype,'Generate Video'))
03502             set(hnoisetype,'Visible','on')
03503         else
03504             set(hnoisetype,'Visible','off')
03505         end
03506         
03507         if(exist('startGPU.m','file') && exist('GPUstart.m','file') && exist([fileparts(which('GPUstart.m')) '/modules/mdz'],'dir'))
03508             set(hgpucheck,'Visible','on');
03509         else
03510             set(hgpucheck,'Visible','off');
03511         end
03512         
03513         % Turn off the buggy stuff.
03514         if(EXPERIMENTAL==0)
03515             set(hupdate_inputcheck,'Visible','off');
03516             set(hlambda_input,'Visible','off');
03517             set(hlambda_inputtext,'Visible','off');
03518             
03519             set(hpsi,'Visible','off');
03520             set(hzsize,'Visible','off');
03521             set(htrainz0check,'Visible','off');
03522             set(hpsitext,'Visible','off');
03523             set(hzsizetext,'Visible','off');
03524             
03525             set(hposzcheck,'Visible','off');
03526             
03527             set(hprev_frames,'Visible','off');
03528             set(hprev_framestext,'Visible','off');
03529             set(htime_layer,'Visible','off');
03530             set(htime_layertext,'Visible','off');
03531             set(hinfer_using,'Visible','off');
03532             set(hinfer_usingtext,'Visible','off');
03533             set(hlimittimecheck,'Visible','off');
03534             set(hFabovetable,'Visible','off');
03535             
03536             
03537             %             set(hlaphabox,'Visible','off');
03538             set(hBmultbox,'Visible','off');
03539             set(hkappabox,'Visible','off');
03540             set(hgammabox,'Visible','off');
03541             set(hkappatable,'Visible','off');
03542             set(hgammatable,'Visible','off');
03543             set(hBmultipliertable,'Visible','off');
03544             
03545             
03546             % Resize row.
03547             set(halphabox,'Position',[.34 .14 .32 0.22]);
03548             set(halphatable,'Position',[410,100,380,140]);
03549             set(hBinitbox,'Title','Beta');
03550             set(hBinitbox,'Position',[.67 .14 .32 0.22]);
03551             set(hBinitialtable,'Position',[810,100,380,140]);
03552             
03553             % Turn of the panels
03554             set(hz0box,'Visible','off');
03555             set(hFabovebox,'Visible','off');
03556             set(hupdateybox,'Visible','off');
03557             set(hvideobox,'Visible','off');
03558             
03559             % Turn off emailing
03560             set(hemail,'Visible','off');
03561             set(hemailtext,'Visible','off');
03562             % Turn on suppress warnings flag.
03563             set(hsuppresswarn,'Visible','on');
03564             
03565             set(hthresholdtext,'Visible','off');
03566             set(hthreshold,'Visible','off');
03567             
03568             set(hramplambda,'Visible','off');
03569             set(hramplambdatext,'Visible','off');
03570             
03571             set(hrunbutton,'Visible','off');  
03572             set(hmachine,'Visible','off');
03573             
03574             set(hhistorybutton,'Position',[1125,60,50,25]);
03575             set(hloadbutton,'Position',[1075,60,50,25]);
03576             set(hsavebutton,'Position',[1075,10,100,25]);
03577             set(hloadbutton,'Position',[1075,60,50,25]);
03578             set(hloadbutton,'Position',[1075,60,50,25]);
03579 
03580             
03581         else
03582             set(hsuppresswarn,'Visible','off');
03583             
03584         end
03585     end
03586 
03587 
03588 
03589 
03590 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
03591 % Updates the number of mpas at each layer based on the connectivity matrices.
03592 %
03593 % @param source the gui component that called this.
03594 % @param eventdata relates to the event of activating the gui component.
03595 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03596     function hupdate_conmats_Callback(source,eventdata)
03597         [model,hlayerspecifictable] = update_conmats(model,hlayerspecifictable,1);
03598     end
03599 
03600 
03601 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%>
03602 % Updates the gui with the model parameters.
03603 %
03604 % @param source the gui component that called this.
03605 % @param eventdata relates to the event of activating the gui component.
03606 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03607     function update_defaults()
03608         %         hupdate_conmats_Callback([],[])
03609         
03610         if(isfield(model,'load_from_previous') && model.load_from_previous && exist([START_RESULTS_DIRECTORY model.modeldirectory]))
03611             temp = load([START_RESULTS_DIRECTORY model.modeldirectory],'model');
03612             model = temp.model;
03613             model.load_from_previous = 0;
03614             model = backwards_compatible(model);
03615         end
03616         
03617         if(strcmp(model.exptype,'Reconstruct Layer By Layer')||...
03618                 strcmp(model.exptype,'Reconstruct 2-Layer Joint Method')||...
03619                 strcmp(model.exptype,'Reconstruct Using Trained Model'))
03620             model.expfile = ' reconAll';
03621         elseif(strcmp(model.exptype,'Generate Video'))
03622             model.expfile = ' gen_video';
03623         elseif(strcmp(model.exptype,'Train Layer By Layer')||...
03624                 strcmp(model.exptype,'Train 2-Layer Joint Method')||...
03625                 strcmp(model.exptype,'Train New Model'))
03626             model.expfile = ' trainAll';
03627         elseif(strcmp(model.exptype,'Continue Training On Top'))
03628             model.expfile = ' train_remaining_layers';
03629         end
03630         
03631         % Update all the parameter values in the gui.
03632         % MUST ADD HERE
03633         set(hexptype,'Value',find(strcmp(get(hexptype,'String'),model.exptype)))
03634         set(hnum_layers,'Value',find(strcmp(get(hnum_layers,'String'),int2str(model.num_layers))))
03635         set(hinit1stcheck,'Value',model.LAYER1_FIRST);
03636         %         set(hfiltercontcheck,'Value',model.FILTER_CONTINUATION);
03637         
03638         set(hcolorcheck,'Value',find(strcmp(get(hcolorcheck,'String'),model.COLOR_IMAGES)))
03639         set(htime_layer,'Value',find(strcmp(get(htime_layer,'String'),int2str(model.TIME_LAYER))))
03640         set(hzeromeancheck,'Value',model.ZERO_MEAN);
03641         set(hsquarecheck,'Value',model.SQUARE_IMAGES);
03642         set(hcontrastcheck,'Value',find(strcmp(get(hcontrastcheck,'String'),model.CONTRAST_NORMALIZE)))
03643         
03644         %         set(hippcheck,'Value',model.USE_IPP);
03645         set(hgpucheck,'Value',model.USE_GPU);
03646         set(himageordercheck,'Value',model.RANDOM_IMAGE_ORDER);
03647         
03648         
03649         set(hbatchsize,'String',model.batch_size);
03650         set(hthreshold,'String',model.grad_threshold);
03651         set(hminiterations,'String',model.min_iterations);
03652         set(hcompthreads,'String',model.comp_threads);
03653         set(hemail,'String',model.EMAIL_NOTIFICATIONS);
03654         set(hkeypresscheck,'Value',model.SHOW_KEYPRESS);
03655         
03656         set(hposzcheck,'Value',model.POSITIVE_Z);
03657         set(hlambdatable,'Data',model.lambda);
03658         set(halphatable,'Data',model.alpha);
03659         set(hgammatable,'Data',model.gamma);
03660         set(hkappatable,'Data',model.kappa);
03661         set(hBinitialtable,'Data',model.Binitial);
03662         set(hBmultipliertable,'Data',model.Bmultiplier);
03663         set(hFabovetable,'Data',logical(model.Fabove));
03664         
03665         % UPdate the phase and layer specific variables.
03666         A = cell(10,4);
03667         for i=1:10
03668             A{i,1} = model.maxepochs(i);
03669             A{i,2} = model.betaT(i);
03670             A{i,3} = model.SUBSAMPLING_UPDATES(i);
03671             A{i,4} = model.INFERENCE_TYPE{i};
03672             A{i,5} = model.LEARNING_TYPE{i};
03673         end
03674         set(hphasespecifictable,'Data',A);
03675         A = cell(10,17);
03676         for i=1:10
03677             A{i,1} = model.num_feature_maps(i);
03678             A{i,2} = model.filter_size(i,1);
03679             A{i,3} = model.filter_size(i,2);
03680             A{i,4} = model.norm_types{i};
03681             temp = model.norm_sizes{i};
03682             A{i,5} = temp(1);
03683             A{i,6} = temp(2);
03684             A{i,7} = temp(3);
03685             A{i,8} = temp(4);
03686             A{i,9} = temp(5);
03687             A{i,10} = temp(5);
03688             A{i,11} = model.conmat_types{i};
03689             A{i,12} = model.SHIFT_FILTERS(i); % if You want to shift the filters by their center of mass
03690             A{i,13} = model.ZERO_MEAN_FILTERS(i); % if you want to make the filters zero mean before noramlization.
03691             A{i,14} = model.NORMALIZE_FILTERS(i); % If you want to normalize filters by L2 norm.
03692             A{i,15} = model.MAX_FILTERS(i); % If you want to normalize filters by the max filter value for each feature map.
03693             A{i,16} = model.GREEDY_FILTER_SHUTOFF(i); % if you want to greedily turn off filter planes that don't do much.
03694             A{i,17} = model.FILTER_CLIPPING(i);
03695         end
03696         
03697         set(hlayerspecifictable,'Data',A);
03698         
03699         set(hframes1,'String',model.image_frames{1});
03700         set(hframes2,'String',model.image_frames{2});
03701         set(hframes3,'String',model.image_frames{3});
03702         set(hinfer_using,'String',mat2str(model.INFER_USING));
03703         set(hlimittimecheck,'Value',model.LIMIT_TIME_LAYER_THROUGH_TIME);
03704         set(hprev_frames,'String',model.prev_frames);
03705         set(hgen_frames,'String',model.gen_frames);
03706         
03707         set(hramplambda,'String',model.ramp_lambda_amount);
03708         
03709         set(hpsi,'String',model.psi);
03710         set(hzsize,'String',model.z0_filter_size);
03711         set(htrainz0check,'Value',model.TRAIN_Z0);
03712         set(hmodeldirectory,'String',model.modeldirectory);
03713         set(hdatadirectory,'String',model.datadirectory);
03714         set(hsavedirectory,'String',model.savedirectory);
03715         
03716         
03717         set(hnoisetype,'Value',find(strcmp(get(hnoisetype,'String'),model.noisetype)))
03718         set(hsavecheck,'Value',model.SAVE_RESULTS);
03719         set(hsavecheck,'String',num2str(model.SAVE_RESULTS));
03720         set(hplotcheck,'Value',model.PLOT_RESULTS);
03721         set(hplotcheck,'String',num2str(model.PLOT_RESULTS));
03722         set(hlambda_input,'String',model.lambda_input);
03723         set(hupdate_inputcheck,'Value',model.UPDATE_INPUT);
03724         
03725         set(hnotes,'String',model.notes);
03726         
03727         if(exist('startGPU.m','file') && exist('GPUstart.m','file') && exist([fileparts(which('GPUstart.m')) '/modules/mdz'],'dir'))
03728         else
03729             model.USE_GPU = 0;
03730         end
03731         
03732         % If the paths are changed then set the Directories panel title to
03733         % reflect that.
03734         set(hdirpanel,'Title',['Directories (append to these): (Datasets: ' START_DATASET_DIRECTORY '...  Results: ' START_RESULTS_DIRECTORY, '...)']);
03735         
03736         % Update the connectivity matrices and the visibility.
03737         %         hupdate_conmats_Callback([],[])
03738         update_visibility;
03739         %        model
03740     end
03741 
03742 
03743 %%%%%%%%%%%
03744 %% Call the update initially to initialize the connectivity matrices.
03745 hupdate_conmats_Callback([],[])
03746 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
03747 update_visibility;
03748 update_defaults;
03749 
03750 
03751 
03752 % Move the GUI to the center of the screen.
03753 % movegui(fgui,'center')
03754 % Make the GUI visible.
03755 set(fgui,'Visible','on');
03756 
03757 
03758 end
03759 
03760 
03761 
 All Files Functions Variables Typedefs Enumerations Enumerator Defines