function I=ReadLargePinnacleStructFile_OUH(filename,pathToDCMTK)
  %There is a bug in Matlab which for some Pinnacle struct files result in a
  %read error using dicominfo. The cause of the error is that Pinnacle does
  %not round coordinates of struct points. The following file will replace
  %the inputfile (filename) with a similar dicom file but with all
  %coordinates rounded with no figures after the decimal point (1
  %mm). Having made this change dicominfo will accept the struct file. The
  %function uses dmctk to read the file round the positions and rewrite the
  %file 
  %CaB 2015-04-06
  
  % Added option to pass path to DCMTK as parameter, for compatibility with
  % cluster.
  % 2016-02-26 RST
  
  % Changed eval('!...') to system(...) to accomodate for paths with white
  % spaces.
  % 2019-03-12 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
      dump2dcm=RecursiveDir_OUH(fullfile('..','..','external-research-tools','dcmtk'),'dump2dcm.exe',true);
      if isempty(dump2dcm)
          dump2dcm=RecursiveDir_OUH('.','dump2dcm.exe',true);
      end
      if isempty(dump2dcm)
          warning('The DCMTK program dump2dcm is needed either in the external research path or as a local file');
          return;
      end
      dcmdump=dcmdump(1);
      dump2dcm=dump2dcm(1);
  else
      dcmdump{1} = fullfile(pathToDCMTK,'dcmdump');
      dump2dcm{1} = fullfile(pathToDCMTK,'dump2dcm');
  end
  
  tempdir=tempname;
  mkdir(tempdir);
  
  %stringcommand='!C:\home\cab\DICOM_tools\dcmtk\dcmtk-3.5.4-win32-i386\bin\dcmdump.exe +M +L';
  if ispc
    stringcommand=['"' dcmdump{1} '" +M +L'];
  elseif isunix
    stringcommand=['' dcmdump{1} ' +M +L'];
  end
  stringcommand=[stringcommand ' ' filename];
  stringcommand=[stringcommand ' > ' fullfile(tempdir,'tempdata.txt')];
  system(stringcommand);
  fid = fopen(fullfile(tempdir,'tempdata.txt'),'r');
  
  FileText=textscan(fid, '%s', 'Delimiter', sprintf('\n'));
  fclose(fid);
  index=cellfun(@(x) ~isempty(strfind(x, '(3006,0050) DS ')),FileText{1});
  maxlength=0;
  %counter=0;
  for i=find(index)'
    %counter=counter+1;
    %disp(counter);
    text=FileText{1}{i};
    dataseperators=[strfind(text,'[') strfind(text,']')];
    data=textscan(text(dataseperators(1)+1:dataseperators(2)-1),'%f','Delimiter','\\');
    data=data{1};
    temp = arrayfun(@(x) [sprintf('%.1f',x) '\'],data,'UniformOutput',false);
    outputstring=[];
    for j=1:size(temp,1)
      outputstring=[outputstring temp{j}];
    end
    outputstring=['[' outputstring];
    outputstring=[outputstring(1:end-1) ']'];
    number=2*ceil((size(outputstring,2)-2)/2);
    outputstring=[outputstring '  # ' num2str(number) ',' num2str(size(data,1)) ' ContourData'];
    outputstring=[ text(1:dataseperators(1)-1) outputstring];
    FileText{1}{i}=outputstring;
    if maxlength<size(outputstring,2) 
      maxlength=size(outputstring,2);
    end
  end
  fout= fopen(fullfile(tempdir,'modifieddata.txt'),'w');
  fprintf(fout,'%s\n',FileText{1}{:});
  fclose(fout);
  
  if ispc
    stringcommand=['"' dump2dcm{1} '"'];
  elseif isunix
      stringcommand=dump2dcm{1};
  end
  stringcommand=[stringcommand ' --line ' num2str(maxlength+2)];
  stringcommand = [stringcommand ' ' fullfile(tempdir,'modifieddata.txt') ' ' fullfile(tempdir,'Dicom.dcm')];
  system(stringcommand);
  I=dicominfo(fullfile(tempdir,'Dicom.dcm'));
  rmdir(tempdir,'s');
end