read_files_neo_io.py 1.1 KB

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