%% Initialize:
GT = convertAssafFormat( 'C:\Users\Topaz\Google Drive\Academy\Thesis\Code\Data\Inputs\GT\Broad\SaveDataWithSeg.mat' );

% Frames range:
startFrame = 1; endFrame = 200; startSeg = 0;
maxFrameDiff = 10;

% Debug mode flag:
DEBUG = 0;

% Create Mitodix object:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Initialize Mitodix object...\n', timeTag);
mtdx = Mitodix(DEBUG);

%% Read Frames:
% Read all Frames:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Read input sequance images...\n', timeTag);
mtdx.ReadFrames(startFrame, endFrame, startSeg);

%% Calculate initial candidates:
% Calculate initial candidates:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Calculate initial candidates...\n', timeTag);
mtdx.CalcInitialCandidates();

%% Calculate Features:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Calculate candidates features...\n', timeTag);
mtdx.CalcCandidatesFeatures();

%% Detect Mitosis:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Mitosis detection...\n', timeTag);
mtdx.GetMitosisInSequance();

%% Performance evaluation:
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Performance evaluation...\n', timeTag);
test = mtdx.Test(GT);
save(fullfile(mtdx.OutputPath, 'test.mat'), 'test');

%% Create video:
if(mtdx.CreateVideoFlag)
    timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
    fprintf('%s : Creating video...\n', timeTag);
    mtdx.CreateOutputVideo();
end

%%
timeTag = datestr(now,'yyyy-mm-dd HH:MM:SS.FFF');
fprintf('%s : Done!\n', timeTag);