read_files.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. # Plexon files
  8. distantfile = 'https://portal.g-node.org/neo/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(cascade=True, 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 = 'https://portal.g-node.org/neo/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(cascade=True, 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)