% IFCB Training with Heidi M. Sosik at WHOI
% Created: 4th august 2015
% Last updated: 6h august 2015
% Author: Nils Haentjens - nils.haentjens+m@maine.edu

% SVN Repository
% URL: https://beagle.whoi.edu/svn/ifcb/trunk
% Repository Root: https://beagle.whoi.edu/svn/ifcb
% Repository UUID: 9f5e5bc8-6430-4f94-ad00-aad15e9f9366
% Revision: 1379

addpath(genpath('trunk'));
set(0,'DefaultFigureWindowStyle','normal');

%% Start Manual Classifier
% when done with classification can visualize classification in the startMC
% checking the option start from classifier
startMC

%% Build blob mask
% need to specify directory inside
% temporary directory created which are deleted unless there is an error
% script to call the batch wrapper
start_blob_batch_user_training

%% Build feature for every pictures
% need to specify directory inside
% temporary directory created which are deleted unless there is an error

% it's unzipping every folder which is not efficient because we zip them on
% the start_blob_batch_user_training, need to go arround
% look at bin_features function

% One persistant variable in this script : # getRW_fast precomputing
% add to deal with computation of 2D diffraction pattern
start_feature_batch_user_training

%% Export PNG
% export images in png to share
% specify location of data and class to export
export_png_manual_fromROI

%% Building classifier
% decision to take for this part of code
% select the classifier we want
% miht need to modify parameters and code to do what we want
% need an even training set but might be discussable
% by default pic randomly "maxn" examples
% might need to rename the file if multiple run a day

% create the classifier file in manual/summary/
open compile_train_features_user_training

%% Make TreeBaggerClassifier
% use tree to get score of affiliation with every class
% powerfull because you cannot overfit a classifier
%           don't need a validation set to compute errors
%           
% when playing with the function put less tree in TreeBagger
% more tree, less error and more accurate etimation of error
% figure 1 plot the error and is a good estimate of the number of tree required

% fair_diameter is wrong, there is an error in the matlab code computing it

% figure 4:pd probability of detection and pr precision

open make_TreeBaggerClassifier_user_training

%% Classify the data
% apply the classifier built previoulsy on all the dataset
start_classify_batch_user_training

%% Count cells in the manual selection
% output data in manual/summary
open countcells_manual_user_training

%% Count cells in the automatic selection
% adhocthresh 
%     threshold to select or not the element
%     if not selected will go in unclassified
%   this threshold can be automatic (2 ways) or manual
open countcells_allTBnew_user_training
