read_files_neo_io.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. This is an example for reading files with neo.io
  3. """
  4. import urllib
  5. import neo
  6. url_repo = 'https://web.gin.g-node.org/NeuralEnsemble/ephy_testing_data/raw/master/'
  7. # Plexon files
  8. distantfile = url_repo + 'plexon/File_plexon_3.plx'
  9. localfile = './File_plexon_3.plx'
  10. urllib.request.urlretrieve(distantfile, localfile)
  11. # create a reader
  12. reader = neo.io.PlexonIO(filename='File_plexon_3.plx')
  13. # read the blocks
  14. blks = reader.read(lazy=False)
  15. print(blks)
  16. # access to segments
  17. for blk in blks:
  18. for seg in blk.segments:
  19. print(seg)
  20. for asig in seg.analogsignals:
  21. print(asig)
  22. for st in seg.spiketrains:
  23. print(st)
  24. # CED Spike2 files
  25. distantfile = url_repo + 'spike2/File_spike2_1.smr'
  26. localfile = './File_spike2_1.smr'
  27. urllib.request.urlretrieve(distantfile, localfile)
  28. # create a reader
  29. reader = neo.io.Spike2IO(filename='File_spike2_1.smr')
  30. # read the block
  31. bl = reader.read(lazy=False)[0]
  32. print(bl)
  33. # access to segments
  34. for seg in bl.segments:
  35. print(seg)
  36. for asig in seg.analogsignals:
  37. print(asig)
  38. for st in seg.spiketrains:
  39. print(st)