code: def match_first_degree(name_list1, name_list2):
      """
      First immediate matching between two possible name lists (exact equality
      between one item of list1 and of list2
      :param name_list1: First list of names to match
      :param name_list2: Second list of names where to find a match
      :return init_match1:
      :return init_match2:
      :return ind_match1: Indices of second list that correspond to each given
      item of list 1 if exists (-1 otherwise)
      :return ind_match2: Indices of first list that correspond to each given
      item of list 2 if exists (-1) otherwise
      """
      if name_list1 is None or name_list2 is None:
          return None, None, None, None
      init_match1 = [""] * len(name_list1)
      init_match2 = [""] * len(name_list2)
      ind_match1 = [-1] * len(name_list1)
      ind_match2 = [-1] * len(name_list2)
      flatten_list1 = [
          item for sublist in name_list1 for item in sublist
      ]
      flatten_list2 = [
          item for sublist in name_list2 for item in sublist
      ]
      indflat_1 = [
          i
          for i in range(0, len(init_match1))
          for item in name_list1[i]
          if init_match1[i] == ""
      ]
      indflat_2 = [
          i
          for i in range(0, len(init_match2))
          for item in name_list2[i]
          if init_match2[i] == ""
      ]
      for i in range(0, len(name_list1)):
          for name in name_list1[i]:
              if name in flatten_list2:
                  init_match1[i] = name
                  ind_match1[i] = indflat_2[flatten_list2.index(name)]
                  break
      for i in range(0, len(name_list2)):
          for name in name_list2[i]:
              if name in flatten_list1:
                  init_match2[i] = name
                  ind_match2[i] = indflat_1[flatten_list1.index(name)]
                  break
      return init_match1, init_match2, ind_match1, ind_match2
  
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 1 for calling a global function with example usage: match_first_degree(name_list1, name_list2) and returns: init_match1,  init_match2,  ind_match1,  ind_match2, None,  None,  None,  None