__init__.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. # -*- coding: utf-8 -*-
  2. """
  3. :mod:`neo.io` provides classes for reading and/or writing
  4. electrophysiological data files.
  5. Note that if the package dependency is not satisfied for one io, it does not
  6. raise an error but a warning.
  7. neo.io.iolist provides a list of succesfully imported io classes.
  8. Classes:
  9. .. autoclass:: neo.io.AlphaOmegaIO
  10. .. autoclass:: neo.io.AsciiSignalIO
  11. .. autoclass:: neo.io.AsciiSpikeTrainIO
  12. .. autoclass:: neo.io.AxonIO
  13. .. autoclass:: neo.io.BlackrockIO
  14. .. autoclass:: neo.io.BrainVisionIO
  15. .. autoclass:: neo.io.BrainwareDamIO
  16. .. autoclass:: neo.io.BrainwareF32IO
  17. .. autoclass:: neo.io.BrainwareSrcIO
  18. .. autoclass:: neo.io.ElanIO
  19. ..
  20. .. autoclass:: neo.io.ElphyIO
  21. .. autoclass:: neo.io.IgorIO
  22. .. autoclass:: neo.io.KlustaKwikIO
  23. .. autoclass:: neo.io.KwikIO
  24. .. autoclass:: neo.io.MicromedIO
  25. .. autoclass:: neo.io.NeoHdf5IO
  26. .. autoclass:: neo.io.NeoMatlabIO
  27. .. autoclass:: neo.io.NestIO
  28. .. autoclass:: neo.io.NeuralynxIO
  29. .. autoclass:: neo.io.NeuroExplorerIO
  30. .. autoclass:: neo.io.NeuroScopeIO
  31. .. autoclass:: neo.io.NeuroshareIO
  32. .. autoclass:: neo.io.NixIO
  33. .. autoclass:: neo.io.NSDFIO
  34. .. autoclass:: neo.io.PickleIO
  35. .. autoclass:: neo.io.PlexonIO
  36. .. autoclass:: neo.io.PyNNNumpyIO
  37. .. autoclass:: neo.io.PyNNTextIO
  38. .. autoclass:: neo.io.RawBinarySignalIO
  39. .. autoclass:: neo.io.StimfitIO
  40. .. autoclass:: neo.io.TdtIO
  41. .. autoclass:: neo.io.WinEdrIO
  42. .. autoclass:: neo.io.WinWcpIO
  43. """
  44. import os.path
  45. #try to import the neuroshare library.
  46. #if it is present, use the neuroshareapiio to load neuroshare files
  47. #if it is not present, use the neurosharectypesio to load files
  48. try:
  49. import neuroshare as ns
  50. except ImportError as err:
  51. from neo.io.neurosharectypesio import NeurosharectypesIO as NeuroshareIO
  52. #print("\n neuroshare library not found, loading data with ctypes" )
  53. #print("\n to use the API be sure to install the library found at:")
  54. #print("\n www.http://pythonhosted.org/neuroshare/")
  55. else:
  56. from neo.io.neuroshareapiio import NeuroshareapiIO as NeuroshareIO
  57. #print("neuroshare library successfully imported")
  58. #print("\n loading with API...")
  59. from neo.io.alphaomegaio import AlphaOmegaIO
  60. from neo.io.asciisignalio import AsciiSignalIO
  61. from neo.io.asciispiketrainio import AsciiSpikeTrainIO
  62. from neo.io.axonio import AxonIO
  63. from neo.io.blackrockio import BlackrockIO
  64. from neo.io.brainvisionio import BrainVisionIO
  65. from neo.io.brainwaredamio import BrainwareDamIO
  66. from neo.io.brainwaref32io import BrainwareF32IO
  67. from neo.io.brainwaresrcio import BrainwareSrcIO
  68. from neo.io.elanio import ElanIO
  69. #from neo.io.elphyio import ElphyIO
  70. from neo.io.exampleio import ExampleIO
  71. from neo.io.igorproio import IgorIO
  72. from neo.io.klustakwikio import KlustaKwikIO
  73. from neo.io.kwikio import KwikIO
  74. from neo.io.micromedio import MicromedIO
  75. from neo.io.hdf5io import NeoHdf5IO
  76. from neo.io.neomatlabio import NeoMatlabIO
  77. from neo.io.nestio import NestIO
  78. from neo.io.neuralynxio import NeuralynxIO
  79. from neo.io.neuroexplorerio import NeuroExplorerIO
  80. from neo.io.neuroscopeio import NeuroScopeIO
  81. from neo.io.nixio import NixIO
  82. from neo.io.nsdfio import NSDFIO
  83. from neo.io.pickleio import PickleIO
  84. from neo.io.plexonio import PlexonIO
  85. from neo.io.pynnio import PyNNNumpyIO
  86. from neo.io.pynnio import PyNNTextIO
  87. from neo.io.rawbinarysignalio import RawBinarySignalIO
  88. from neo.io.spike2io import Spike2IO
  89. from neo.io.stimfitio import StimfitIO
  90. from neo.io.tdtio import TdtIO
  91. from neo.io.winedrio import WinEdrIO
  92. from neo.io.winwcpio import WinWcpIO
  93. iolist = [
  94. AlphaOmegaIO,
  95. AsciiSignalIO,
  96. AsciiSpikeTrainIO,
  97. AxonIO,
  98. BlackrockIO,
  99. BrainVisionIO,
  100. BrainwareDamIO,
  101. BrainwareF32IO,
  102. BrainwareSrcIO,
  103. ElanIO,
  104. #ElphyIO,
  105. ExampleIO,
  106. IgorIO,
  107. KlustaKwikIO,
  108. KwikIO,
  109. MicromedIO,
  110. NixIO, # place NixIO before NeoHdf5IO to make it the default for .h5 files
  111. NeoHdf5IO,
  112. NeoMatlabIO,
  113. NestIO,
  114. NeuralynxIO,
  115. NeuroExplorerIO,
  116. NeuroScopeIO,
  117. NeuroshareIO,
  118. NSDFIO,
  119. PickleIO,
  120. PlexonIO,
  121. PyNNNumpyIO,
  122. PyNNTextIO,
  123. RawBinarySignalIO,
  124. Spike2IO,
  125. StimfitIO,
  126. TdtIO,
  127. WinEdrIO,
  128. WinWcpIO
  129. ]
  130. def get_io(filename, *args, **kwargs):
  131. """
  132. Return a Neo IO instance, guessing the type based on the filename suffix.
  133. """
  134. extension = os.path.splitext(filename)[1][1:]
  135. for io in iolist:
  136. if extension in io.extensions:
  137. return io(filename, *args, **kwargs)
  138. raise IOError("File extension %s not registered" % extension)