Package: open-ephys-python-tools
Open Ephys Python ToolsOverviewThis package centralizes and standardizes Python-specific tools for interacting with theOpen Ephys GUI.It consists of three modules:analysis- loads data in every format supported by the GUI, using a common interfacecontrol- allows a Python process to control the GUI, locally or over a network connectionstreaming- receives data from the GUI for real-time analysis and visualizationInstallationInside a Python virtual environment (condaor otherwise), run the following command:$pipinstallopen-ephys-python-toolsAlternatively, if you've cloned the repository locally, you can run the following command from inside theopen-ephys-python-toolsdirectory:$pipinstall-e.Note:The-eargument links the package in the original location (rather than by copying), so any edits to the source code can be used immediately. This is optional but can be extremely useful for debugging.Usageanalysisfromopen_ephys.analysisimportSessiondirectory='/path/to/data/2020-11-10_09-28-30'# for examplesession=Session(directory)If the directory contains data from one more Record Nodes, thesessionobject will contain a list of Record Nodes, accessible viasession.recordnodes[N], whereN = 0, 1, 2,, etc.If your directory just contains data (e.g. you specified a Record Node directory), individual recordings can be accessed viasession.recordings. The format of the recordings will be detected automatically as eitherBinary,Open Ephys, orNWB 2.Note:This package is intended for use with data saved by Open Ephys GUI version0.6.xand higher. However, theBinaryformat is backwards-compatible with data saved by version0.5.x. To read data saved in Open Ephys, NWB 1.0, or Kwik formats by GUI version0.5.xand lower, you can use code in thearchivebranch of this repository.Eachrecordingobject has the following fields:continuous: continuous data for each subprocessor in the recordingspikes: spikes for each electrode groupevents: PandasDataFrameof event times and metadataMore details aboutcontinuous,spikes, andeventsobjects can be found in theanalysis module README file.controlFirst, launch an instance of the Open Ephys GUI (version0.6.0or higher).Then, from your Python process:fromopen_ephys.controlimportOpenEphysHTTPServeraddress='10.128.50.10'# IP address of the computer running Open Ephysgui=OpenEphysHTTPServer(address)gui.acquire(10)# acquire data for 10 secondsMore details about available commands can be found in thecontrol module README file.streamingFirst, launch an instance of the Open Ephys GUI and make sure anEvent Broadcasterplugin is in the signal chain.Then, from your Python process:fromopen_ephys.streamingimportEventListeneraddress='10.128.50.10'# IP address of the computer running Open Ephysstream=EventListener(address)Next, define a callback function to handle each incoming event:defttl_callback(info):print("Event occurred on TTL line "+info['line']+" at "+info['sample_number']/info['sample_rate']+" seconds.")Finally, start listening for events by running...stream.start(ttl_callback=ttl_callback)...and pressctrl-Cto stop the process.More details about available commands can be found in thestreaming module README file.ContributingThis code base is under active development, and we welcome bug reports, feature requests, and external contributions. If you're working on an extension that you think would be useful to the community, don't hesitate tosubmit an issue.