__init__.py 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. """
  2. :mod:`neo.io` provides classes for reading and/or writing
  3. electrophysiological data files.
  4. Note that if the package dependency is not satisfied for one io, it does not
  5. raise an error but a warning.
  6. :attr:`neo.io.iolist` provides a list of successfully imported io classes.
  7. Functions:
  8. .. autofunction:: neo.io.get_io
  9. Classes:
  10. * :attr:`AlphaOmegaIO`
  11. * :attr:`AsciiImageIO`
  12. * :attr:`AsciiSignalIO`
  13. * :attr:`AsciiSpikeTrainIO`
  14. * :attr:`AxographIO`
  15. * :attr:`AxonIO`
  16. * :attr:`BCI2000IO`
  17. * :attr:`BlackrockIO`
  18. * :attr:`BlkIO`
  19. * :attr:`BrainVisionIO`
  20. * :attr:`BrainwareDamIO`
  21. * :attr:`BrainwareF32IO`
  22. * :attr:`BrainwareSrcIO`
  23. * :attr:`ElanIO`
  24. * :attr:`IgorIO`
  25. * :attr:`IntanIO`
  26. * :attr:`KlustaKwikIO`
  27. * :attr:`KwikIO`
  28. * :attr:`MicromedIO`
  29. * :attr:`NeoHdf5IO`
  30. * :attr:`NeoMatlabIO`
  31. * :attr:`NestIO`
  32. * :attr:`NeuralynxIO`
  33. * :attr:`NeuroExplorerIO`
  34. * :attr:`NeuroScopeIO`
  35. * :attr:`NeuroshareIO`
  36. * :attr:`NixIO`
  37. * :attr:`NSDFIO`
  38. * :attr:`OpenEphysIO`
  39. * :attr:`PickleIO`
  40. * :attr:`PlexonIO`
  41. * :attr:`RawBinarySignalIO`
  42. * :attr:`RawMCSIO`
  43. * :attr:`Spike2IO`
  44. * :attr:`StimfitIO`
  45. * :attr:`TdtIO`
  46. * :attr:`TiffIO`
  47. * :attr:`WinEdrIO`
  48. * :attr:`WinWcpIO`
  49. .. autoclass:: neo.io.AlphaOmegaIO
  50. .. autoattribute:: extensions
  51. .. autoclass:: neo.io.AsciiImageIO
  52. .. autoattribute:: extensions
  53. .. autoclass:: neo.io.AsciiSignalIO
  54. .. autoattribute:: extensions
  55. .. autoclass:: neo.io.AsciiSpikeTrainIO
  56. .. autoattribute:: extensions
  57. .. autoclass:: neo.io.AxographIO
  58. .. autoattribute:: extensions
  59. .. autoclass:: neo.io.AxonIO
  60. .. autoattribute:: extensions
  61. .. autoclass:: neo.io.BCI2000IO
  62. .. autoattribute:: extensions
  63. .. autoclass:: neo.io.BlackrockIO
  64. .. autoattribute:: extensions
  65. .. autoclass:: neo.io.BlkIO
  66. .. autoattribute:: extensions
  67. .. autoclass:: neo.io.BrainVisionIO
  68. .. autoattribute:: extensions
  69. .. autoclass:: neo.io.BrainwareDamIO
  70. .. autoattribute:: extensions
  71. .. autoclass:: neo.io.BrainwareF32IO
  72. .. autoattribute:: extensions
  73. .. autoclass:: neo.io.BrainwareSrcIO
  74. .. autoattribute:: extensions
  75. .. autoclass:: neo.io.ElanIO
  76. .. autoattribute:: extensions
  77. .. .. autoclass:: neo.io.ElphyIO
  78. .. autoattribute:: extensions
  79. .. autoclass:: neo.io.IgorIO
  80. .. autoattribute:: extensions
  81. .. autoclass:: neo.io.IntanIO
  82. .. autoattribute:: extensions
  83. .. autoclass:: neo.io.KlustaKwikIO
  84. .. autoattribute:: extensions
  85. .. autoclass:: neo.io.KwikIO
  86. .. autoattribute:: extensions
  87. .. autoclass:: neo.io.MicromedIO
  88. .. autoattribute:: extensions
  89. .. autoclass:: neo.io.NeoHdf5IO
  90. .. autoattribute:: extensions
  91. .. autoclass:: neo.io.NeoMatlabIO
  92. .. autoattribute:: extensions
  93. .. autoclass:: neo.io.NestIO
  94. .. autoattribute:: extensions
  95. .. autoclass:: neo.io.NeuralynxIO
  96. .. autoattribute:: extensions
  97. .. autoclass:: neo.io.NeuroExplorerIO
  98. .. autoattribute:: extensions
  99. .. autoclass:: neo.io.NeuroScopeIO
  100. .. autoattribute:: extensions
  101. .. autoclass:: neo.io.NeuroshareIO
  102. .. autoattribute:: extensions
  103. .. autoclass:: neo.io.NixIO
  104. .. autoattribute:: extensions
  105. .. autoclass:: neo.io.NSDFIO
  106. .. autoattribute:: extensions
  107. .. autoclass:: neo.io.OpenEphysIO
  108. .. autoattribute:: extensions
  109. .. autoclass:: neo.io.PickleIO
  110. .. autoattribute:: extensions
  111. .. autoclass:: neo.io.PlexonIO
  112. .. autoattribute:: extensions
  113. .. autoclass:: neo.io.RawBinarySignalIO
  114. .. autoattribute:: extensions
  115. .. autoclass:: neo.io.RawMCSIO
  116. .. autoattribute:: extensions
  117. .. autoclass:: Spike2IO
  118. .. autoattribute:: extensions
  119. .. autoclass:: neo.io.StimfitIO
  120. .. autoattribute:: extensions
  121. .. autoclass:: neo.io.TdtIO
  122. .. autoattribute:: extensions
  123. .. autoclass:: neo.io.TiffIO
  124. .. autoattribute:: extensions
  125. .. autoclass:: neo.io.WinEdrIO
  126. .. autoattribute:: extensions
  127. .. autoclass:: neo.io.WinWcpIO
  128. .. autoattribute:: extensions
  129. """
  130. import os.path
  131. # try to import the neuroshare library.
  132. # if it is present, use the neuroshareapiio to load neuroshare files
  133. # if it is not present, use the neurosharectypesio to load files
  134. try:
  135. import neuroshare as ns
  136. except ImportError as err:
  137. from neo.io.neurosharectypesio import NeurosharectypesIO as NeuroshareIO
  138. # print("\n neuroshare library not found, loading data with ctypes" )
  139. # print("\n to use the API be sure to install the library found at:")
  140. # print("\n www.http://pythonhosted.org/neuroshare/")
  141. else:
  142. from neo.io.neuroshareapiio import NeuroshareapiIO as NeuroshareIO
  143. # print("neuroshare library successfully imported")
  144. # print("\n loading with API...")
  145. from neo.io.alphaomegaio import AlphaOmegaIO
  146. from neo.io.asciiimageio import AsciiImageIO
  147. from neo.io.asciisignalio import AsciiSignalIO
  148. from neo.io.asciispiketrainio import AsciiSpikeTrainIO
  149. from neo.io.axographio import AxographIO
  150. from neo.io.axonio import AxonIO
  151. from neo.io.blackrockio import BlackrockIO
  152. from neo.io.blackrockio_v4 import BlackrockIO as OldBlackrockIO
  153. from neo.io.blkio import BlkIO
  154. from neo.io.bci2000io import BCI2000IO
  155. from neo.io.brainvisionio import BrainVisionIO
  156. from neo.io.brainwaredamio import BrainwareDamIO
  157. from neo.io.brainwaref32io import BrainwareF32IO
  158. from neo.io.brainwaresrcio import BrainwareSrcIO
  159. from neo.io.elanio import ElanIO
  160. # from neo.io.elphyio import ElphyIO
  161. from neo.io.exampleio import ExampleIO
  162. from neo.io.igorproio import IgorIO
  163. from neo.io.intanio import IntanIO
  164. from neo.io.klustakwikio import KlustaKwikIO
  165. from neo.io.kwikio import KwikIO
  166. from neo.io.micromedio import MicromedIO
  167. from neo.io.hdf5io import NeoHdf5IO
  168. from neo.io.neomatlabio import NeoMatlabIO
  169. from neo.io.nestio import NestIO
  170. from neo.io.neuralynxio import NeuralynxIO
  171. from neo.io.neuralynxio_v1 import NeuralynxIO as OldNeuralynxIO
  172. from neo.io.neuroexplorerio import NeuroExplorerIO
  173. from neo.io.neuroscopeio import NeuroScopeIO
  174. from neo.io.nixio import NixIO
  175. from neo.io.nixio_fr import NixIO as NixIOFr
  176. from neo.io.nsdfio import NSDFIO
  177. from neo.io.openephysio import OpenEphysIO
  178. from neo.io.pickleio import PickleIO
  179. from neo.io.plexonio import PlexonIO
  180. from neo.io.rawbinarysignalio import RawBinarySignalIO
  181. from neo.io.rawmcsio import RawMCSIO
  182. from neo.io.spike2io import Spike2IO
  183. from neo.io.stimfitio import StimfitIO
  184. from neo.io.tdtio import TdtIO
  185. from neo.io.tiffio import TiffIO
  186. from neo.io.winedrio import WinEdrIO
  187. from neo.io.winwcpio import WinWcpIO
  188. iolist = [
  189. AlphaOmegaIO,
  190. AsciiImageIO,
  191. AsciiSignalIO,
  192. AsciiSpikeTrainIO,
  193. AxographIO,
  194. AxonIO,
  195. BCI2000IO,
  196. BlackrockIO,
  197. BlkIO,
  198. BrainVisionIO,
  199. BrainwareDamIO,
  200. BrainwareF32IO,
  201. BrainwareSrcIO,
  202. ElanIO,
  203. # ElphyIO,
  204. ExampleIO,
  205. IgorIO,
  206. IntanIO,
  207. KlustaKwikIO,
  208. KwikIO,
  209. MicromedIO,
  210. NixIO, # place NixIO before NeoHdf5IO to make it the default for .h5 files
  211. NeoHdf5IO,
  212. NeoMatlabIO,
  213. NestIO,
  214. NeuralynxIO,
  215. NeuroExplorerIO,
  216. NeuroScopeIO,
  217. NeuroshareIO,
  218. NSDFIO,
  219. OpenEphysIO,
  220. PickleIO,
  221. PlexonIO,
  222. RawBinarySignalIO,
  223. RawMCSIO,
  224. Spike2IO,
  225. StimfitIO,
  226. TdtIO,
  227. TiffIO,
  228. WinEdrIO,
  229. WinWcpIO
  230. ]
  231. def get_io(filename, *args, **kwargs):
  232. """
  233. Return a Neo IO instance, guessing the type based on the filename suffix.
  234. """
  235. extension = os.path.splitext(filename)[1][1:]
  236. for io in iolist:
  237. if extension in io.extensions:
  238. return io(filename, *args, **kwargs)
  239. raise IOError("File extension %s not registered" % extension)