code: def log_to_dict(logfile):
      """
      Function to extract log node dictionaries into a list of python
      dictionaries and return the list as well as the final node
  
      Parameters
      ----------
      logfile : string
          path to the json-formatted log file generated from a nipype
          workflow execution
  
      Returns
      -------
      nodes_list : list
          a list of python dictionaries containing the runtime info
          for each nipype node
      """
  
      # Init variables
      with open(logfile) as content:
          # read file separating each line
          lines = content.readlines()
  
      nodes_list = [json.loads(l) for l in lines]
  
      def _convert_string_to_datetime(datestring):
          try:
              datetime_object: datetime.datetime = (
                  datetime.datetime.strptime(
                      datestring, "%Y-%m-%dT%H:%M:%S.%f"
                  )
              )
              return datetime_object
          except Exception as _:
              pass
          return datestring
  
      date_object_node_list: list = list()
      for n in nodes_list:
          if "start" in n.keys():
              n["start"] = _convert_string_to_datetime(n["start"])
          if "finish" in n.keys():
              n["finish"] = _convert_string_to_datetime(n["finish"])
          date_object_node_list.append(n)
  
      # Return list of nodes
      return date_object_node_list
  
file_path: nipype/nipype/utils/draw_gantt_chart.py
imports: import sys
  import random
  import datetime
  import simplejson
  from collections import OrderedDict
label_desc: Use image node_id 2 for calling a global function with example usage: log_to_dict(logfile) and returns: date_object_node_list, datestring, datetime_object