function downloadTrainedLD2HDCTUNITNet(url,destination)
% The downloadTrainedLD2HDCTUNITNet function downloads the 
% pretrained UNIT generator network that translates low dose CT images into 
% high dose CT images.
%
% Copyright 2021 The MathWorks, Inc.

[~,name,~] = fileparts(url);
netDirFullPath = destination;
netZipFileFullPath = fullfile(destination,name+".zip");
netMATFileFullPath = fullfile(destination,name+".mat");
if ~exist(netMATFileFullPath,"file")
    if ~exist(netZipFileFullPath,"file")
        disp("Downloading pretrained UNIT generator network for low dose to high dose CT translation.");
        disp("This can take several minutes to download...");
        if ~exist(netDirFullPath,'dir')
            mkdir(netDirFullPath);
        end
        websave(netZipFileFullPath,url);
        disp("Done.");
    end
    unzip(netZipFileFullPath,netDirFullPath)
else
    disp("Pretrained UNIT generator network for low dose to high dose CT translation already exists.");
end
end