-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcompute_AJI.m
59 lines (44 loc) · 1.85 KB
/
compute_AJI.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% Script to compute Aggregated Jaccard Index
% Created by Ruchika Verma, please cite the following paper if you use this code-
% N. Kumar, R. Verma, S. Sharma, S. Bhargava, A. Vahadane and A. Sethi,
% "A Dataset and a Technique for Generalized Nuclear Segmentation for
% Computational Pathology," in IEEE Transactions on Medical Imaging,
% vol. 36, no. 7, pp. 1550-1560, July 2017
clc;
clear all;
close all;
% Set path
dirname = 'D:\Research work\MONUSEG\Monuseg results';
addpath('D:\Research work\MONUSEG\Monuseg results');
listing = dir(dirname);
patient_names = listing(3:end);
main_aji = zeros(36,14);% Number of participants, Number of testing_images
for k = 1:36 % participants
% Predicted patient name
participant = (strcat(dirname,'\',patient_names(k).name));
cd(participant);
participant_name = dir();
participant_name(~[participant_name.isdir]) = [];
participant_name = strcat(participant,'\',participant_name(3).name);
% GT name
GT_dirname = 'D:\Research work\MONUSEG\GT';
GT_listing = dir([GT_dirname,'\*.mat']);
aji_individual = [];
for j = 1:14 %GT file name
load(strcat(GT_dirname,'\',GT_listing(j).name));
gt_map = binary_mask;
cd(participant_name);
if exist(strcat(GT_listing(j).name(1:end-7),'_predicted_map.mat'))
predicted = load(strcat(participant_name,'\',GT_listing(j).name(1:end-7),'_predicted_map.mat'));
elseif exist(strcat(GT_listing(j).name(1:end-7),'.mat'))
predicted = load(strcat(participant_name,'\',GT_listing(j).name(1:end-7),'.mat'));
else
predicted = load(strcat(participant_name,'\',GT_listing(j).name(1:end-7),'_predicated.mat'));
end
predicted_map = double(cell2mat(struct2cell(predicted)));
aji_individual = [aji_individual;Aggregated_Jaccard_Index_v1_0(gt_map,predicted_map)];
predicted=[];
end
main_aji(k,:) = aji_individual;
end
% mean_aji(k) = mean(aji_individual);