code: def __find_max_overlap_in_list(name, list_names):
      """
      Given a name and list of names to match it to, find the maximum overlap
      existing
  
      :param name: string to match to any of list_names
      :param list_names: list of candidate strings
      :return match_seq: matched substring
      :return index: index of element in list_names to which the match is
      associated. Returns -1 if there is no found match
      """
      match_max = 0
      match_seq = ""
      match_orig = ""
      match_ratio = 0
      if not list_names:
          return "", -1
      for test in list_names:
          if test:
              match = SequenceMatcher(
                  None, name, test
              ).find_longest_match(0, len(name), 0, len(test))
              if (
                  match.size >= match_max
                  and match.size / len(test) >= match_ratio
              ):
                  match_max = match.size
                  match_seq = test[match.b : (match.b + match.size)]
                  match_ratio = match.size / len(test)
                  match_orig = test
      if match_max == 0:
          return "", -1
      other_list = [
          name
          for name in list_names
          if match_seq in name and match_max / len(name) == match_ratio
      ]
      if len(other_list) > 1:
          return "", -1
      return match_seq, list_names.index(match_orig)
  
file_path: NiftyNet/niftynet/utilities/util_csv.py
imports: from __future__ import absolute_import, print_function, division
  import csv
  import os
  import sys
  from difflib import SequenceMatcher
  import numpy
  from niftynet.io.misc_io import touch_folder
  from niftynet.utilities.filename_matching import KeywordsMatching
label_desc: Use image node_id 2 for calling a global function with example usage: __find_max_overlap_in_list(name, list_names) and returns: match_seq,  list_names, str,  unknown, str,  unknown, str,  unknown