Package: pynapple
PYthon Neural Analysis Package.pynapple is a light-weight python library for neurophysiological data analysis. The goal is to offer a versatile set of tools to study typical data in the field, i.e. time series (spike times, behavioral events, etc.) and time intervals (trials, brain states, etc.). It also provides users with generic functions for neuroscience such as tuning curves and cross-correlograms.Free software: MIT LicenseDocumentation:https://pynapple-org.github.io/pynappleNotebooks and tutorials:https://pynapple-org.github.io/pynapple/generated/gallery/Note:page_with_curl: If you are using pynapple, please cite the followingpaperNew release :fire:Starting with 0.4, pynapple rely on thenumpy array containerapproach instead of Pandas. Pynapple builtin functions will remain the same except for functions inherited from Pandas. Typically this line of code inpynapple<=0.3.6:meantsd=tsdframe.mean(1)is now:meantsd=np.mean(tsdframe,1)inpynapple>=0.4.0. This allows for a better handling of returned objects.Additionaly, it is now possible to define time series objects with more than 2 dimensions withTsdTensor. You can also look at thisnotebookfor a demonstration of numpy compatibilities.CommunityTo ask any questions or get support for using pynapple, please consider joining our slack. Please send an email to thepynapple[at]gmail[dot]com to receive an invitation link.Getting StartedInstallationThe best way to install pynapple is with pip within a newcondaenvironment :$ conda create --name pynapple pip python=3.8
$ conda activate pynapple
$ pip install pynappleor directly from the source code:$ conda create --name pynapple pip python=3.8
$ conda activate pynapple
$ # clone the repository
$ git clone https://github.com/pynapple-org/pynapple.git
$ cd pynapple
$ # Install in editable mode with `-e` or, equivalently, `--editable`
$ pip install -e .NoteThe package is now using a pyproject.toml file for installation and dependencies management. If you want to run the tests, use pip install -e .[dev]This procedure will install all the dependencies includingpandasnumpyscipynumbapynwb 2.0tabulateh5pyBasic UsageAfter installation, you can now import the package:$ python
>>> import pynapple as napYou'll find an example of the package below. Clickhereto download the example dataset. The folder includes a NWB file containing the data.importmatplotlib.pyplotaspltimportnumpyasnpimportpynappleasnap# LOADING DATA FROM NWBdata=nap.load_file("A2929-200711.nwb")spikes=data["units"]head_direction=data["ry"]wake_ep=data["position_time_support"]# COMPUTING TUNING CURVEStuning_curves=nap.compute_1d_tuning_curves(spikes,head_direction,120,ep=wake_ep,minmax=(0,2*np.pi))# PLOTplt.figure()foriinspikes:plt.subplot(3,5,i+1,projection="polar")plt.plot(tuning_curves[i])plt.xticks([0,np.pi/2,np.pi,3*np.pi/2])plt.show()Shown below, the final figure from the example code displays the firing rate of 15 neurons as a function of the direction of the head of the animal in the horizontal plane.CreditsSpecial thanks to Francesco P. Battaglia
(https://github.com/fpbattaglia) for the development of the originalTSToolbox(https://github.com/PeyracheLab/TStoolbox) andneuroseries(https://github.com/NeuroNetMem/neuroseries) packages,
the latter constituting the core ofpynapple.This package was developped by Guillaume Viejo
(https://github.com/gviejo) and other members of the Peyrache Lab.Logo: Sofia Skromne Carrasco, 2021.