plotnix.py 554 B

123456789101112131415161718192021222324
  1. import sys
  2. import matplotlib.pyplot as plt
  3. import nixio as nix
  4. fname = sys.argv[1]
  5. nixfile = nix.File(fname, mode=nix.FileMode.ReadOnly)
  6. block = nixfile.blocks[0]
  7. # plot all signals
  8. data = block.data_arrays["EEG Data"]
  9. time = data.dimensions[1].ticks
  10. for idx, row in enumerate(data):
  11. plt.plot(time, row + idx * 0.001)
  12. stim = block.multi_tags["Stimuli"]
  13. for idx, p in enumerate(stim.positions):
  14. if stim.positions.dimensions[0].labels[idx] == "Stimulus/S 2":
  15. plt.plot([p, p], [0, len(data) * 0.001], "k")
  16. plt.show()
  17. nixfile.close()