code: def join_subject_id_and_filename_list(name_list, list_files):
      """
      From the list of list of names and the list of list of files
      corresponding to each constraint find the association between a single
      name id and the different file lists
      :param name_list: list of list of names
      :param list_files: list of list of files (one list per constraint)
      :return list_combined: List per subject of name and list of files given
      by the constraints
      """
      ind_max = np.argmax([len(names) for names in name_list])
      name_max = name_list[ind_max]
      name_tot = []
      ind_tot = []
      name_max_to_use = []
      for c in range(0, len(list_files)):
          name_match, ind_match = match_second_degree(
              name_max, name_list[c]
          )
          if c == ind_max:
              name_max_to_use = name_match
          name_tot.append(name_match)
          ind_tot.append(ind_match)
  
      list_combined = []
      for i, name in enumerate(name_max_to_use):
          list_temp = [name]
          # To do : Taking care of the case when the list of a constraint is
          # completely empty
          for c in range(0, len(list_files)):
              output = (
                  list_files[c][ind_tot[c][i]]
                  if ind_tot[c][i] > -1
                  else ""
              )
              list_temp.append(output)
          list_combined.append(list_temp)
      return list_combined
  
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 4 for calling a global function with example usage: join_subject_id_and_filename_list(name_list, list_files) and returns: list_combined