-
Notifications
You must be signed in to change notification settings - Fork 25
/
demo_optThresh.m
41 lines (31 loc) · 1.44 KB
/
demo_optThresh.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%% Demo showing how to find best area and probability thresholds from processing
%% the probability maps of trained data generated by the network
addpath(genpath('Software'))
%% Set names and directories for training data
name = {'501484643','501271265','524691284'};
DirProbMap = ['Results',filesep,'ABO',filesep,'Probability map'];
DirData = ['Dataset',filesep,'ABO'];
DirGTMasks = ['Markings',filesep,'ABO',filesep,'Layer275',filesep,'Grader1'];
%% Setting parameters
pixSize = 0.78; %um
meanR = 5.85; %um
AvgArea = round(pi*(meanR/pixSize)^2);
JThresh = 0.5;
% Hyperparameters
probthresh = 0.5:0.05:1;
minArea = [15:5:70]; %pixels:
%Should be in ascending order for the current code version
%% run postprocessinga and performance evaluation for every combination of thresholds
Recall = zeros(numel(name),numel(probthresh),numel(minArea));
Precision = Recall; F1 = Recall;
for i = 1:numel(name)
[Recall(i,:,:),Precision(i,:,:),F1(i,:,:)] = multiple_postProcessJaccard([487,487],DirProbMap,DirGTMasks,...
name{i},AvgArea,minArea,probthresh,JThresh);
end
% Compute mean F1 across train data to find best performance
meanF1 = squeeze(mean(F1,1));
[BestF1,~] = max(meanF1(:));
[indP,indA] = find(meanF1==BestF1,1);
% Thresholds yielding the best performance
minA = minArea(indA);
ProbThresh = probthresh(indP);