code: def export_3_column(stimfunction,
                      filename,
                      temporal_resolution=100.0
                      ):
      
  
      # Iterate through the stim function
      stim_counter = 0
      event_counter = 0
      while stim_counter < stimfunction.shape[0]:
  
          # Is it an event?
          if stimfunction[stim_counter, 0] != 0:
  
              # When did the event start?
              event_onset = str(stim_counter / temporal_resolution)
  
              # The weight of the stimulus
              weight = str(stimfunction[stim_counter, 0])
  
              # Reset
              event_duration = 0
  
              # Is the event still ongoing?
              while stimfunction[stim_counter, 0] != 0 & stim_counter <= \
                      stimfunction.shape[0]:
  
                  # Add one millisecond to each duration
                  event_duration = event_duration + 1
  
                  # Increment
                  stim_counter = stim_counter + 1
  
              # How long was the event in seconds
              event_duration = str(event_duration / temporal_resolution)
  
              # Append this row to the data file
              with open(filename, "a") as file:
                  file.write(event_onset + '\t' + event_duration + '\t' +
                             weight + '\n')
  
              # Increment the number of events
              event_counter = event_counter + 1
  
          # Increment
          stim_counter = stim_counter + 1
docs: Output a tab separated three column timing file
  
      This produces a three column tab separated text file, with the three
      columns representing onset time (s), event duration (s) and weight,
      respectively. Useful if you want to run the simulated data through FEAT
      analyses. In a way, this is the reverse of generate_stimfunction
  
      Parameters
      ----------
  
      stimfunction : timepoint by 1 array
          The stimulus function describing the time course of events. For
          instance output from generate_stimfunction.
  
      filename : str
          The name of the three column text file to be output
  
      temporal_resolution : float
          How many elements per second are you modeling with the
          stimfunction?