code: def write_fieldtrip(data, filename):
      
      n_trl = data.number_of('trial')
      trial = empty(n_trl, dtype='O')
      time = empty(n_trl, dtype='O')
  
      for trl in range(n_trl):
          trial[trl] = data.data[trl]
          time[trl] = data.axis['time'][trl]
  
      ft_data = {'fsample': float(data.s_freq),
                 'label': data.axis['chan'][0].astype('O'),
                 'trial': trial,
                 'time': time,
                 'cfg': 'Converted from wonambi on ' + str(datetime.now()),
                 }
  
      savemat(filename, {VAR: ft_data})
docs: Export data to FieldTrip.
  
      Parameters
      ----------
      data : instance of ChanTime
          data with only one trial
      filename : path to file
          file to export to (include '.mat')
  
      Notes
      -----
      It saves mat file using Version 6 ('-v7') because it relies on scipy.io
      functions. Therefore it cannot store data larger than 2 GB.