|
a |
|
b/evaluateMBIMDS.m |
|
|
1 |
function [t_pred, score, y_target] = evaluateMBIMDS(network,imds) |
|
|
2 |
|
|
|
3 |
%% |
|
|
4 |
% To be run on the following networks: |
|
|
5 |
% network = '1024x1024_34_true_5_class_prostate.onnx' |
|
|
6 |
% network = '1024x1024_50_true_5_class_prostate.onnx' |
|
|
7 |
% network = '1024x1024_152_true_5_class_prostate.onnx' |
|
|
8 |
%% |
|
|
9 |
% Use michaels original test set for 1024 images |
|
|
10 |
% imds = imageDatastore('ABSOLUTE_PATH','IncludeSubfolders',true,'labelsource','foldernames'); |
|
|
11 |
% Absolute path should be the top level folder containing folders that |
|
|
12 |
% seperate classes |
|
|
13 |
%% |
|
|
14 |
% For ease of use, set code directory as available path and run each |
|
|
15 |
% network in its own network folder. This will ensure the saves are |
|
|
16 |
% appropriately placed. |
|
|
17 |
|
|
|
18 |
warning off |
|
|
19 |
net = importONNXNetwork(network,'OutputLayerType','classification'); |
|
|
20 |
warning on |
|
|
21 |
|
|
|
22 |
imdsT = transform(imds,@(x) preNetNorm(x)); |
|
|
23 |
|
|
|
24 |
[t_pred, score] = classify(net,imdsT); |
|
|
25 |
|
|
|
26 |
y_target = imdsT.UnderlyingDatastores{1,1}.Labels; |
|
|
27 |
|
|
|
28 |
csvwrite(sprintf('%s_prediction.csv',network(1:end-5)),grp2idx(t_pred)); |
|
|
29 |
csvwrite(sprintf('%s_score.csv',network(1:end-5)),score); |
|
|
30 |
csvwrite(sprintf('%s_target.csv',network(1:end-5)),grp2idx(y_target)); |