Package: pd-parser
pd-parserThe stable version of the documentation can be foundhere.A tool to parse photodiode events from a possibly corrupted channel, compatible with BIDS formatting.Corrupted data may look like so:Which may lead to some excluded events and differences between the events and the expected timing based on the behavior that look like so:pd-parsermatches deflection events on a potentially corrupted photodiode channel with time-stamped events generated by the computer that changes the luminance sensed by the photodiode. This tool is for research that needs high-performance timing synchronization, especially in clinical settings where having a channel record a photodiode is the best or only method of task-integration available and where the photodiode is especially likely to be corrupted by unavoidable environmental noise. First, photodiode time series data is extracted from an electrophysiology data file. The photodiode data can be on a single channel or two channels that are then bipolar re-referenced. Candidate photodiode events from this photodiode time series are identified based on matching a square-wave template. Time-stamped events from the computer triggering changes to the luminance of the photodiode are read from a tab-separated value (tsv) file, and the best alignment of these events relative to photodiode deflection events is then found while accounting for any drift between computer clocks of separate recording devices. Events are excluded where when the difference between the photodiode event and the time-stamped event are greater then a specified threshold. This discrepancy in timing can occur when a monitor doesn’t update the display for one or more frames most often because the computer paused execution of the program controlling luminance to do background tasks. Additional events can then be added using the time of each event relative to the corresponding photodiode-synchronized event. Adding relative events may be needed for any number of reasons. For instance, events may occur too rapidly in series relative to the monitor refresh rate to have a photodiode deflection for each event, or the photodiode deflection may effect neighboring channels on the amplifier with its large deflection and so be placed synchronous with an event, such the onset of fixation, where it will not effect other, more important events. Finally, the raw data and events data can be saved in brain imaging data structure (BIDS) format, which allows the behavioral events to be stored in a standardized format without modifying the underlying raw electrophysiology file.Installation InstructionsInstall the latest version python using of anacondaanaconda (https://www.anaconda.com/products/individual)orpython (https://www.python.org/downloads/)andmake sure that you add the installed packages to the path.OptionalCreate virtual environment to keep the particular versions of software relevant to this project from getting changed. In a terminal, runconda create--namemyenvand thenconda activate myenvorpython-mvenv /path/to/env/myenvand thensource /path/to/env/myenv/bin/activateRunconda install pipin a terminal, and then ensure that when you runwhich pipin a terminal it points to the where the anaconda or python you just installed is.Runpip installpd-parserin a terminal.Getting StartedPlot the examples in a Jupyter notebookIn theExamples page, click on ‘Download all examples in Jupyter notebooks’Unzip the downloaded fileRunpip install jupyterPoint the terminal to the folder where the files you downloaded are by runningcd /path/to/downloads/Runjupyter notebookin the terminal, this will pop up a webpage in your default browser.Change%matplotlib inlineto just%matplotlibto pop the plots out interactively instead of below the cell in the notebook.Run each cell, change the parameters and explore the example.Try pd-parser on your photodiode data. You will need:Time series datain.fif,.edf,.bdf,.vhdr, or.setformat like the data from the first cell ofthis example. If you do not know the name of the photodiode channel, the data will be plotted and you will be asked to find it so it is not necessary to pass the name.A behavior filein tab-separated value (tsv) format like the one created in the second cell ofthis example. The file needs to have:One column corresponding to the expected event in seconds, called by defaultfix_onset_timeOptionallyOther columns with relative event times in seconds.How to run:See theexample notebooksfor information on how to extract parameters forpd_parser, use the parameters to detect events, and saving the events and data in a BIDS-compatible format.Bug reportsUse theGitHub issue trackerto report bugs.ContributingPlease see ourcontributing guide.
`Alex Rockhill
Eugene, OR 2020