docs: def install_tool(app, Cnt):
      ''' Install the requested software from the git 'repo'
          and check out the version given by 'sha1'.
      '''
  
      # get the current working directory
      cwd = os.getcwd()
  
      # pick the target installation folder for tools
      if 'PATHTOOLS' in Cnt and Cnt['PATHTOOLS']!='':
          path_tools = Cnt['PATHTOOLS']
      elif ('PATHTOOLS' not in Cnt or Cnt['PATHTOOLS']!=''):
          if 'DISPLAY' in os.environ and platform.system() in ['Linux', 'Windows']:
              print '>>>>> DISPLAY', os.environ['DISPLAY']
              Tk().withdraw()
              dircore = askdirectory(title='choose a place for NiftyPET tools', initialdir=os.path.expanduser('~'))
              Tk().destroy()
              # get the full (combined path)
              path_tools = os.path.join(dircore, Cnt['DIRTOOLS'])
          else:
              try:
                  path_tools = input_path('Enter path for NiftyPET tools (registration, etc):')
              except:
                  print 'enter the intended PATHTOOLS in resources.py located in ~/.niftypet/'
                  raise ValueError('\n e> could not get the path for NiftyPET_tools \n')
          Cnt['PATHTOOLS'] = path_tools
  
      else:
          if platform.system() == 'Linux' :
              path_tools = os.path.join( os.path.expanduser('~'), Cnt['DIRTOOLS'] )
          elif platform.system() == 'Windows' :
              path_tools = os.path.join( os.getenv('LOCALAPPDATA'), Cnt['DIRTOOLS'] )
          else:
              print '\n=========================================================='
              print 'e> only Linux and Windows operating systems are supported!'
              print '==========================================================\n'
              raise SystemError('OS not supported!')      
          Cnt['PATHTOOLS'] = path_tools
  
      #create the main tools folder
      if not os.path.isdir(path_tools):
          os.mkdir(path_tools)
      # identify the specific path for the requested app
      if app=='niftyreg':
          repo = repo_reg
          sha1 = sha1_reg
          path = os.path.join(path_tools, 'niftyreg')
      elif app=='dcm2niix':
          repo = repo_dcm
          sha1 = sha1_dcm
          path = os.path.join(path_tools, 'dcm2niix')
  
          if not Cnt['CMPL_DCM2NIIX']:
              # avoid installing from source, instead download the full version:
              Cnt = download_dcm2niix(Cnt, path)
              return Cnt
  
      # Check if the source folder exists and delete it, if it does
      if os.path.isdir(path): shutil.rmtree(path)
      # Create an empty folder and enter it
      os.mkdir(path)
      os.chdir(path)
  
      # clone the git repository
      call(['git', 'clone', repo, dirsrc])
      os.chdir(dirsrc)
      print 'i> checking out the specific git version of the software...'
      call(['git', 'checkout', sha1])
      os.chdir('../')
  
      # create the building folder
      if not os.path.isdir(dirbld):
          os.mkdir(dirbld)
      # go inside the build folder
      os.chdir(dirbld)
  
      # run cmake with arguments
      if platform.system()=='Windows':
          cmd = ['cmake', '../'+dirsrc,
              '-DBUILD_ALL_DEP=ON',
              '-DCMAKE_INSTALL_PREFIX='+path,
              '-G', Cnt['MSVC_VRSN']]
          call(cmd)
          call(['cmake', '--build', './', '--config', 'Release', '--target', 'install'])
      elif platform.system() in ['Linux', 'Darwin']:
          cmd = ['cmake', '../'+dirsrc,
              '-DBUILD_ALL_DEP=ON',
              '-DCMAKE_INSTALL_PREFIX='+path]
          if Cnt['CMAKE_TLS_PAR']!='': cmd.append(Cnt['CMAKE_TLS_PAR'])
          call(cmd)
          call(
              ['cmake', '--build', './',
              '--config', 'Release',
              '--target', 'install',
              '--','-j', str(ncpu)]
          )
  
      # restore the current working directory
      os.chdir(cwd)
  
      if app=='niftyreg':
          try:
              Cnt['RESPATH'] = glob.glob(os.path.join(os.path.join(path,'bin'), 'reg_resample*'))[0]
              Cnt['REGPATH'] = glob.glob(os.path.join(os.path.join(path,'bin'), 'reg_aladin*'))[0]
          except IndexError:
              print 'e> NiftyReg has NOT been successfully installed.'
              raise SystemError('Failed Installation (NiftyReg)')
          # updated the file resources.py
          Cnt = update_resources(Cnt)
          # check the installation:
          chck_niftyreg = check_version(Cnt, chcklst=['RESPATH','REGPATH'])
          if not all([chck_niftyreg[k] for k in chck_niftyreg.keys()]):
              print 'e> NiftyReg has NOT been successfully installed.'
              raise SystemError('Failed Installation (NiftyReg)')
  
      elif app=='dcm2niix':
          try:
              Cnt['DCM2NIIX'] = glob.glob(os.path.join(os.path.join(path,'bin'), 'dcm2niix*'))[0]
          except IndexError:
              print 'e> dcm2niix has NOT been successfully installed.'
              Cnt = download_dcm2niix(Cnt, path)
          # check the installation:
          if not check_version(Cnt, chcklst=['DCM2NIIX']):
              print 'e> dcm2niix has NOT been successfully compiled from github.'
              Cnt = download_dcm2niix(Cnt, path)
      return Cnt