docs: def _get_image_paths(im1, im2):
      """ If the images are paths to a file, checks whether the file exist
      and return the paths. If the images are numpy arrays, writes them
      to disk and returns the paths of the new files.
      """
      
      paths = []
      for im in [im1, im2]:
          if im is None:
              # Groupwise registration: only one image (ndim+1 dimensions)
              paths.append(paths[0])
              continue
          
          if isinstance(im, str):
              # Given a location
              if os.path.isfile(im1):
                  paths.append(im)
              else:
                  raise ValueError('Image location does not exist.')
          
          elif isinstance(im, np.ndarray):
              # Given a numpy array
              id = len(paths)+1
              p = _write_image_data(im, id)
              paths.append(p)
          
          else:
              # Given something else ...
              raise ValueError('Invalid input image.')
      
      # Done
      return tuple(paths)