code: def gen4(dirName):
    
    # Generate images similar to those used in the first plot for the section
    # "Simulations with Pure Temporal Sequences"
    try:
      resultsFig4A = os.path.join(dirName, "pure_sequences_example.pkl")
      with open(resultsFig4A, "rb") as f:
        results = cPickle.load(f)
  
      for trialNum, stat in enumerate(results["statistics"]):
        plotOneInferenceRun(
          stat,
          itemType="a single sequence",
          fields=[
            ("L4 PredictedActive", "Predicted active cells in sensorimotor layer"),
            ("TM NextPredicted", "Predicted cells in temporal sequence layer"),
            ("TM PredictedActive",
             "Predicted active cells in temporal sequence layer"),
          ],
          basename="pure_sequences",
          trialNumber=trialNum,
          plotDir=os.path.join(os.path.dirname(os.path.realpath(__file__)),
                               "detailed_plots")
        )
      print "Plots for Fig 4A generated in 'detailed_plots'"
    except Exception, e:
      print "\nCould not generate plots for Fig 4A: "
      traceback.print_exc()
      print
  
    # Generate the second plot for the section "Simulations with Pure
    # Temporal Sequences"
    try:
      plotAccuracyDuringSequenceInference(
        dirName,
        title="Relative performance of layers while inferring temporal sequences",
        yaxis="Accuracy (%)")
  
      print "Plots for Fig 4B generated in 'plots'"
    except Exception, e:
      print "\nCould not generate plots for Fig 4B: "
      traceback.print_exc()
      print
  
    # Generate the accuracy vs number of sequences
    try:
      plotAccuracyVsSequencesDuringSequenceInference(
        dirName,
        title="Relative performance of layers while inferring temporal sequences",
        yaxis="Accuracy (%)")
  
      print "Plots for Fig 4C generated in 'plots'"
    except Exception, e:
      print "\nCould not generate plots for Fig 4C: "
      traceback.print_exc()
      print
docs: Plots 4A and 4B