prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Use plot_event in a example
  The function `plot_event` has currently no example linked to its [doc](https://nilearn.github.io/modules/generated/nilearn.plotting.plot_event.html#nilearn.plotting.plot_event). 
  It wouldn't be too costly to use it in one example somewhere.
  
  </issue>
  <code>
  [start of examples/04_glm_first_level/write_events_file.py]
  1 """Example of a events.tsv file generation: the neurospin/localizer events.
  2 =============================================================================
  3 
  4 The protocol described is the so-called "archi standard" localizer
  5 event sequence.  See Pinel et al., BMC neuroscience 2007 for reference.
  6 """
  7 
  8 print(__doc__)
  9 
  10 #########################################################################
  11 # Define the onset times in seconds. Those are typically extracted
  12 # from the stimulation software used.
  13 import numpy as np
  14 onset = np.array([
  15     0., 2.4, 8.7, 11.4, 15., 18., 20.7, 23.7, 26.7, 29.7, 33., 35.4, 39.,
  16     41.7, 44.7, 48., 56.4, 59.7, 62.4, 69., 71.4, 75., 83.4, 87., 89.7,
  17     96., 108., 116.7, 119.4, 122.7, 125.4, 131.4, 135., 137.7, 140.4,
  18     143.4, 146.7, 149.4, 153., 156., 159., 162., 164.4, 167.7, 170.4,
  19     173.7, 176.7, 188.4, 191.7, 195., 198., 201., 203.7, 207., 210.,
  20     212.7, 215.7, 218.7, 221.4, 224.7, 227.7, 230.7, 234., 236.7, 246.,
  21     248.4, 251.7, 254.7, 257.4, 260.4, 264., 266.7, 269.7, 275.4, 278.4,
  22     284.4, 288., 291., 293.4, 296.7])
  23 
  24 #########################################################################
  25 # Associated trial types: these are numbered between 0 and 9, hence
  26 # correspond to 10 different conditions.
  27 trial_idx = np.array(
  28     [7, 7, 0, 2, 9, 4, 9, 3, 5, 9, 1, 6, 8, 8, 6, 6, 8, 0, 3, 4, 5, 8, 6,
  29      2, 9, 1, 6, 5, 9, 1, 7, 8, 6, 6, 1, 2, 9, 0, 7, 1, 8, 2, 7, 8, 3, 6,
  30      0, 0, 6, 8, 7, 7, 1, 1, 1, 5, 5, 0, 7, 0, 4, 2, 7, 9, 8, 0, 6, 3, 3,
  31      7, 1, 0, 0, 4, 1, 9, 8, 4, 9, 9])
  32 
  33 #########################################################################
  34 # We may want to map these indices to explicit condition names.
  35 # For that, we define a list of 10 strings.
  36 condition_ids = ['horizontal checkerboard',
  37                  'vertical checkerboard',
  38                  'right button press, auditory instructions',
  39                  'left button press, auditory instructions',
  40                  'right button press, visual instructions',
  41                  'left button press, visual instructions',
  42                  'mental computation, auditory instructions',
  43                  'mental computation, visual instructions',
  44                  'visual sentence',
  45                  'auditory sentence']
  46 
  47 trial_type = np.array([condition_ids[i] for i in trial_idx])
  48 
  49 #########################################################################
  50 # We also define a duration (required by BIDS conventions).
  51 duration = np.ones_like(onset)
  52 
  53 
  54 #########################################################################
  55 # Form an event dataframe from these information.
  56 import pandas as pd
  57 events = pd.DataFrame({'trial_type': trial_type,
  58                        'onset': onset,
  59                        'duration': duration})
  60 
  61 #########################################################################
  62 # Export them to a tsv file.
  63 tsvfile = 'localizer_events.tsv'
  64 events.to_csv(tsvfile, sep='\t', index=False)
  65 print("Created the events file in %s " % tsvfile)
  66
  [end of examples/04_glm_first_level/write_events_file.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/04_glm_first_level/write_events_file.py b/examples/04_glm_first_level/write_events_file.py
  --- a/examples/04_glm_first_level/write_events_file.py
  +++ b/examples/04_glm_first_level/write_events_file.py
  @@ -63,3 +63,10 @@
   tsvfile = 'localizer_events.tsv'
   events.to_csv(tsvfile, sep='\t', index=False)
   print("Created the events file in %s " % tsvfile)
  +
  +#########################################################################
  +# Optionally, the events can be visualized using the plot_event function.
  +from matplotlib import pyplot as plt
  +from nilearn.plotting import plot_event
  +plot_event(events, figsize=(15, 5))
  +plt.show()
  
verification_info: {"golden_diff": "diff --git a/examples/04_glm_first_level/write_events_file.py b/examples/04_glm_first_level/write_events_file.py\n--- a/examples/04_glm_first_level/write_events_file.py\n+++ b/examples/04_glm_first_level/write_events_file.py\n@@ -63,3 +63,10 @@\n tsvfile = 'localizer_events.tsv'\n events.to_csv(tsvfile, sep='\\t', index=False)\n print(\"Created the events file in %s \" % tsvfile)\n+\n+#########################################################################\n+# Optionally, the events can be visualized using the plot_event function.\n+from matplotlib import pyplot as plt\n+from nilearn.plotting import plot_event\n+plot_event(events, figsize=(15, 5))\n+plt.show()\n", "issue": "Use plot_event in a example\nThe function `plot_event` has currently no example linked to its [doc](https://nilearn.github.io/modules/generated/nilearn.plotting.plot_event.html#nilearn.plotting.plot_event). \r\nIt wouldn't be too costly to use it in one example somewhere.\n", "before_files": [{"content": "\"\"\"Example of a events.tsv file generation: the neurospin/localizer events.\n=============================================================================\n\nThe protocol described is the so-called \"archi standard\" localizer\nevent sequence.  See Pinel et al., BMC neuroscience 2007 for reference.\n\"\"\"\n\nprint(__doc__)\n\n#########################################################################\n# Define the onset times in seconds. Those are typically extracted\n# from the stimulation software used.\nimport numpy as np\nonset = np.array([\n    0., 2.4, 8.7, 11.4, 15., 18., 20.7, 23.7, 26.7, 29.7, 33., 35.4, 39.,\n    41.7, 44.7, 48., 56.4, 59.7, 62.4, 69., 71.4, 75., 83.4, 87., 89.7,\n    96., 108., 116.7, 119.4, 122.7, 125.4, 131.4, 135., 137.7, 140.4,\n    143.4, 146.7, 149.4, 153., 156., 159., 162., 164.4, 167.7, 170.4,\n    173.7, 176.7, 188.4, 191.7, 195., 198., 201., 203.7, 207., 210.,\n    212.7, 215.7, 218.7, 221.4, 224.7, 227.7, 230.7, 234., 236.7, 246.,\n    248.4, 251.7, 254.7, 257.4, 260.4, 264., 266.7, 269.7, 275.4, 278.4,\n    284.4, 288., 291., 293.4, 296.7])\n\n#########################################################################\n# Associated trial types: these are numbered between 0 and 9, hence\n# correspond to 10 different conditions.\ntrial_idx = np.array(\n    [7, 7, 0, 2, 9, 4, 9, 3, 5, 9, 1, 6, 8, 8, 6, 6, 8, 0, 3, 4, 5, 8, 6,\n     2, 9, 1, 6, 5, 9, 1, 7, 8, 6, 6, 1, 2, 9, 0, 7, 1, 8, 2, 7, 8, 3, 6,\n     0, 0, 6, 8, 7, 7, 1, 1, 1, 5, 5, 0, 7, 0, 4, 2, 7, 9, 8, 0, 6, 3, 3,\n     7, 1, 0, 0, 4, 1, 9, 8, 4, 9, 9])\n\n#########################################################################\n# We may want to map these indices to explicit condition names.\n# For that, we define a list of 10 strings.\ncondition_ids = ['horizontal checkerboard',\n                 'vertical checkerboard',\n                 'right button press, auditory instructions',\n                 'left button press, auditory instructions',\n                 'right button press, visual instructions',\n                 'left button press, visual instructions',\n                 'mental computation, auditory instructions',\n                 'mental computation, visual instructions',\n                 'visual sentence',\n                 'auditory sentence']\n\ntrial_type = np.array([condition_ids[i] for i in trial_idx])\n\n#########################################################################\n# We also define a duration (required by BIDS conventions).\nduration = np.ones_like(onset)\n\n\n#########################################################################\n# Form an event dataframe from these information.\nimport pandas as pd\nevents = pd.DataFrame({'trial_type': trial_type,\n                       'onset': onset,\n                       'duration': duration})\n\n#########################################################################\n# Export them to a tsv file.\ntsvfile = 'localizer_events.tsv'\nevents.to_csv(tsvfile, sep='\\t', index=False)\nprint(\"Created the events file in %s \" % tsvfile)\n", "path": "examples/04_glm_first_level/write_events_file.py"}]}