function modality=GetModality_OUH(filename,pathToDCMTK)
% This function uses DCMTK to get the value of the Modality tag in a
% DICOM-file.
% 2019-12-03 SLK
    if exist(filename,'file')~=2
        return
    end
  
    if nargin==1
        dcmdump=RecursiveDir_OUH(fullfile('..','..','external-research-tools','dcmtk'),'dcmdump.exe',true);
        
        if isempty(dcmdump)
            dcmdump=RecursiveDir_OUH('.','dcmdump.exe',true);
        end
        if isempty(dcmdump)
            warning('The DCMTK program dcmdump is needed either in the external research path or as a local file');
        return;
        end

        dcmdump=dcmdump(1);
    else
        dcmdump{1} = fullfile(pathToDCMTK,'dcmdump');
    end
    
    if ispc
        cmdstr = ['"' dcmdump{1} '"'];
    elseif isunix
        cmdstr = dcmdump{1};
    end
    
    cmdstr = [cmdstr ' +st "0008,0060" ' filename];
    
    [status,my_output] = system(cmdstr);
    
    idx = strfind(my_output, '(0008,0060) CS');
    
    tmp_str = my_output(idx:end);
    
    idx = strfind(tmp_str, '[');
    idx2 = strfind(tmp_str, ']');
    
    modality = tmp_str(idx+1:idx2-1);
end