-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapplymodel.m
More file actions
executable file
·29 lines (23 loc) · 946 Bytes
/
applymodel.m
File metadata and controls
executable file
·29 lines (23 loc) · 946 Bytes
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
% inputniftifilepath - input full path to nifti file
% mynetwork - input full path to the NN we will use
% outputpath - output path where files will be written
function applymodel( inputniftifilepath, mynetwork, outputpath )
disp( ['inputniftifilepath= ''',inputniftifilepath,''';']);
disp( ['mynetwork = ''',mynetwork ,''';']);
disp( ['outputpath = ''',outputpath ,''';']);
%% load nifti file
info = niftiinfo(inputniftifilepath );
niivolume = niftiread(info);
%% load trained network
trainedNN = load(mynetwork )
%% apply trained network to nifti image
tStart = tic;
tempSeg = semanticseg(niivolume ,trainedNN.net,'ExecutionEnvironment','gpu');
tEnd = toc(tStart)
%% write output to disk as a nifti file
outputlabel = fullfile(outputpath,'label')
infoout = info;
infoout.Filename = outputlabel;
infoout.Datatype = 'uint8';
niftiwrite(uint8(tempSeg) ,outputlabel ,infoout,'Compressed',true)
end