pynapple


Namepynapple JSON
Version 0.6.4 PyPI version JSON
download
home_pagehttps://github.com/pynapple-org/pynapple
SummaryPYthon Neural Analysis Package Pour Laboratoires d’Excellence
upload_time2024-04-18 17:15:32
maintainerNone
docs_urlNone
authorGuillaume Viejo
requires_python>=3.8
licenseMIT License Copyright (c) pynapple authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords neuroscience
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <!-- ![pic1](banner_logo.png) -->
<p align="center">
  <img width="60%" src="docs/images/banner_logo.png">
</p>


<!-- ========================== -->

[![image](https://img.shields.io/pypi/v/pynapple.svg)](https://pypi.python.org/pypi/pynapple)
[![pynapple CI](https://github.com/pynapple-org/pynapple/actions/workflows/main.yml/badge.svg)](https://github.com/pynapple-org/pynapple/actions/workflows/main.yml)
[![Coverage Status](https://coveralls.io/repos/github/pynapple-org/pynapple/badge.svg?branch=main)](https://coveralls.io/github/pynapple-org/pynapple?branch=main)
[![GitHub issues](https://img.shields.io/github/issues/pynapple-org/pynapple)](https://github.com/pynapple-org/pynapple/issues)
![GitHub contributors](https://img.shields.io/github/contributors/pynapple-org/pynapple)
![Twitter Follow](https://img.shields.io/twitter/follow/thepynapple?style=social)

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 License
-   __Documentation__: <https://pynapple-org.github.io/pynapple>
-   __Notebooks and tutorials__ : <https://pynapple-org.github.io/pynapple/generated/gallery/>
<!-- -   __Collaborative repository__: <https://github.com/pynapple-org/pynacollada> -->


> **Note**
> :page_with_curl: If you are using pynapple, please cite the following [paper](https://elifesciences.org/reviewed-preprints/85786)

------------------------------------------------------------------------

New release :fire:
------------------

### pynapple >= 0.6

Starting with 0.6, [`IntervalSet`](https://pynapple-org.github.io/pynapple/reference/core/interval_set/) objects are behaving as immutable numpy ndarray. Before 0.6, you could select an interval within an `IntervalSet` object with:

```python
new_intervalset = intervalset.loc[[0]] # Selecting first interval
```

With pynapple>=0.6, the slicing is similar to numpy and it returns an `IntervalSet`

```python
new_intervalset = intervalset[0]
```

See the [documentation](https://pynapple-org.github.io/pynapple/reference/core/interval_set/) for more details.


### pynapple >= 0.4

Starting with 0.4, pynapple rely on the [numpy array container](https://numpy.org/doc/stable/user/basics.dispatch.html) approach instead of Pandas for the time series. Pynapple builtin functions will remain the same except for functions inherited from Pandas. Typically this line of code in `pynapple<=0.3.6` :
```python
meantsd = tsdframe.mean(1)
```
is now :
```python
meantsd = np.mean(tsdframe, 1)
```
in `pynapple>=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 with `TsdTensor`. You can also look at this [notebook](https://pynapple-org.github.io/pynapple/generated/gallery/tutorial_pynapple_numpy/) for a demonstration of numpy compatibilities.

Community
---------

To 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 Started
---------------

### Installation

The best way to install pynapple is with pip within a new [conda](https://docs.conda.io/en/latest/) environment :

    
``` {.sourceCode .shell}
$ conda create --name pynapple pip python=3.8
$ conda activate pynapple
$ pip install pynapple
```

or directly from the source code:

``` {.sourceCode .shell}
$ 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 .
```
> **Note**
> The 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 including 

-   pandas
-   numpy
-   scipy
-   numba
-   pynwb 2.0
-   tabulate
-   h5py

<!-- For spyder users, it is recommended to install spyder after installing pynapple with :

``` {.sourceCode .shell}
$ conda create --name pynapple pip python=3.8
$ conda activate pynapple
$ pip install pynapple
$ pip install spyder
$ spyder
``` -->


Basic Usage
-----------

After installation, you can now import the package: 

``` {.sourceCode .shell}
$ python
>>> import pynapple as nap
```

You'll find an example of the package below. Click [here](https://www.dropbox.com/s/su4oaje57g3kit9/A2929-200711.zip?dl=1) to download the example dataset. The folder includes a NWB file containing the data.

``` py
import matplotlib.pyplot as plt
import numpy as np

import pynapple as nap

# LOADING DATA FROM NWB
data = nap.load_file("A2929-200711.nwb")

spikes = data["units"]
head_direction = data["ry"]
wake_ep = data["position_time_support"]

# COMPUTING TUNING CURVES
tuning_curves = nap.compute_1d_tuning_curves(
    spikes, head_direction, 120, ep=wake_ep, minmax=(0, 2 * np.pi)
)


# PLOT
plt.figure()
for i in spikes:
    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.

<!-- ![pic1](readme_figure.png) -->
<p align="center">
  <img width="80%" src="docs/images/readme_figure.png">
</p>


### Credits

Special thanks to Francesco P. Battaglia
(<https://github.com/fpbattaglia>) for the development of the original
*TSToolbox* (<https://github.com/PeyracheLab/TStoolbox>) and
*neuroseries* (<https://github.com/NeuroNetMem/neuroseries>) packages,
the latter constituting the core of *pynapple*.

This package was developped by Guillaume Viejo
(<https://github.com/gviejo>) and other members of the Peyrache Lab.

<!-- Logo: Sofia Skromne Carrasco, 2021. -->

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pynapple-org/pynapple",
    "name": "pynapple",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "neuroscience",
    "author": "Guillaume Viejo",
    "author_email": "Guillaume Viejo <guillaume.viejo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/7c/29/235e3eab73d1f7b25a830322eb25fe24b6b4d871132afd2c8ce1630960e9/pynapple-0.6.4.tar.gz",
    "platform": null,
    "description": "<!-- ![pic1](banner_logo.png) -->\n<p align=\"center\">\n  <img width=\"60%\" src=\"docs/images/banner_logo.png\">\n</p>\n\n\n<!-- ========================== -->\n\n[![image](https://img.shields.io/pypi/v/pynapple.svg)](https://pypi.python.org/pypi/pynapple)\n[![pynapple CI](https://github.com/pynapple-org/pynapple/actions/workflows/main.yml/badge.svg)](https://github.com/pynapple-org/pynapple/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/github/pynapple-org/pynapple/badge.svg?branch=main)](https://coveralls.io/github/pynapple-org/pynapple?branch=main)\n[![GitHub issues](https://img.shields.io/github/issues/pynapple-org/pynapple)](https://github.com/pynapple-org/pynapple/issues)\n![GitHub contributors](https://img.shields.io/github/contributors/pynapple-org/pynapple)\n![Twitter Follow](https://img.shields.io/twitter/follow/thepynapple?style=social)\n\nPYthon Neural Analysis Package.\n\npynapple 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.\n\n-   Free software: MIT License\n-   __Documentation__: <https://pynapple-org.github.io/pynapple>\n-   __Notebooks and tutorials__ : <https://pynapple-org.github.io/pynapple/generated/gallery/>\n<!-- -   __Collaborative repository__: <https://github.com/pynapple-org/pynacollada> -->\n\n\n> **Note**\n> :page_with_curl: If you are using pynapple, please cite the following [paper](https://elifesciences.org/reviewed-preprints/85786)\n\n------------------------------------------------------------------------\n\nNew release :fire:\n------------------\n\n### pynapple >= 0.6\n\nStarting with 0.6, [`IntervalSet`](https://pynapple-org.github.io/pynapple/reference/core/interval_set/) objects are behaving as immutable numpy ndarray. Before 0.6, you could select an interval within an `IntervalSet` object with:\n\n```python\nnew_intervalset = intervalset.loc[[0]] # Selecting first interval\n```\n\nWith pynapple>=0.6, the slicing is similar to numpy and it returns an `IntervalSet`\n\n```python\nnew_intervalset = intervalset[0]\n```\n\nSee the [documentation](https://pynapple-org.github.io/pynapple/reference/core/interval_set/) for more details.\n\n\n### pynapple >= 0.4\n\nStarting with 0.4, pynapple rely on the [numpy array container](https://numpy.org/doc/stable/user/basics.dispatch.html) approach instead of Pandas for the time series. Pynapple builtin functions will remain the same except for functions inherited from Pandas. Typically this line of code in `pynapple<=0.3.6` :\n```python\nmeantsd = tsdframe.mean(1)\n```\nis now :\n```python\nmeantsd = np.mean(tsdframe, 1)\n```\nin `pynapple>=0.4.0`. This allows for a better handling of returned objects.\n\nAdditionaly, it is now possible to define time series objects with more than 2 dimensions with `TsdTensor`. You can also look at this [notebook](https://pynapple-org.github.io/pynapple/generated/gallery/tutorial_pynapple_numpy/) for a demonstration of numpy compatibilities.\n\nCommunity\n---------\n\nTo 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.\n\nGetting Started\n---------------\n\n### Installation\n\nThe best way to install pynapple is with pip within a new [conda](https://docs.conda.io/en/latest/) environment :\n\n    \n``` {.sourceCode .shell}\n$ conda create --name pynapple pip python=3.8\n$ conda activate pynapple\n$ pip install pynapple\n```\n\nor directly from the source code:\n\n``` {.sourceCode .shell}\n$ conda create --name pynapple pip python=3.8\n$ conda activate pynapple\n$ # clone the repository\n$ git clone https://github.com/pynapple-org/pynapple.git\n$ cd pynapple\n$ # Install in editable mode with `-e` or, equivalently, `--editable`\n$ pip install -e .\n```\n> **Note**\n> The 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]\n\nThis procedure will install all the dependencies including \n\n-   pandas\n-   numpy\n-   scipy\n-   numba\n-   pynwb 2.0\n-   tabulate\n-   h5py\n\n<!-- For spyder users, it is recommended to install spyder after installing pynapple with :\n\n``` {.sourceCode .shell}\n$ conda create --name pynapple pip python=3.8\n$ conda activate pynapple\n$ pip install pynapple\n$ pip install spyder\n$ spyder\n``` -->\n\n\nBasic Usage\n-----------\n\nAfter installation, you can now import the package: \n\n``` {.sourceCode .shell}\n$ python\n>>> import pynapple as nap\n```\n\nYou'll find an example of the package below. Click [here](https://www.dropbox.com/s/su4oaje57g3kit9/A2929-200711.zip?dl=1) to download the example dataset. The folder includes a NWB file containing the data.\n\n``` py\nimport matplotlib.pyplot as plt\nimport numpy as np\n\nimport pynapple as nap\n\n# LOADING DATA FROM NWB\ndata = nap.load_file(\"A2929-200711.nwb\")\n\nspikes = data[\"units\"]\nhead_direction = data[\"ry\"]\nwake_ep = data[\"position_time_support\"]\n\n# COMPUTING TUNING CURVES\ntuning_curves = nap.compute_1d_tuning_curves(\n    spikes, head_direction, 120, ep=wake_ep, minmax=(0, 2 * np.pi)\n)\n\n\n# PLOT\nplt.figure()\nfor i in spikes:\n    plt.subplot(3, 5, i + 1, projection=\"polar\")\n    plt.plot(tuning_curves[i])\n    plt.xticks([0, np.pi / 2, np.pi, 3 * np.pi / 2])\n\nplt.show()\n```\nShown 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.\n\n<!-- ![pic1](readme_figure.png) -->\n<p align=\"center\">\n  <img width=\"80%\" src=\"docs/images/readme_figure.png\">\n</p>\n\n\n### Credits\n\nSpecial thanks to Francesco P. Battaglia\n(<https://github.com/fpbattaglia>) for the development of the original\n*TSToolbox* (<https://github.com/PeyracheLab/TStoolbox>) and\n*neuroseries* (<https://github.com/NeuroNetMem/neuroseries>) packages,\nthe latter constituting the core of *pynapple*.\n\nThis package was developped by Guillaume Viejo\n(<https://github.com/gviejo>) and other members of the Peyrache Lab.\n\n<!-- Logo: Sofia Skromne Carrasco, 2021. -->\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) pynapple authors  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "PYthon Neural Analysis Package Pour Laboratoires d\u2019Excellence",
    "version": "0.6.4",
    "project_urls": {
        "Download": "https://github.com/pynapple-org/pynapple/archive/refs/tags/v0.6.0.tar.gz",
        "Homepage": "https://github.com/pynapple-org/pynapple",
        "documentation": "https://pynapple-org.github.io/pynapple/",
        "repository": "https://github.com/pynapple-org/pynapple"
    },
    "split_keywords": [
        "neuroscience"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2367b18954f0fb06183b0ec573db26bf473c566c4e8d6e8964f79066912c8363",
                "md5": "4dbd566bb3f8d4ce205c163cbeef03e5",
                "sha256": "871d7777a89f9638ab86be272e99c1eea24686a65b020d6b426699315cd3b285"
            },
            "downloads": -1,
            "filename": "pynapple-0.6.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4dbd566bb3f8d4ce205c163cbeef03e5",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.8",
            "size": 83492,
            "upload_time": "2024-04-18T17:15:30",
            "upload_time_iso_8601": "2024-04-18T17:15:30.123591Z",
            "url": "https://files.pythonhosted.org/packages/23/67/b18954f0fb06183b0ec573db26bf473c566c4e8d6e8964f79066912c8363/pynapple-0.6.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c29235e3eab73d1f7b25a830322eb25fe24b6b4d871132afd2c8ce1630960e9",
                "md5": "ba3532fc9449677b8ec47798a3d24f1b",
                "sha256": "2c114f92312ac6f30e5f1ea37e9190b3a4404fb40f5bd4ac51f0d8c4fe3eb0d8"
            },
            "downloads": -1,
            "filename": "pynapple-0.6.4.tar.gz",
            "has_sig": false,
            "md5_digest": "ba3532fc9449677b8ec47798a3d24f1b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 94911682,
            "upload_time": "2024-04-18T17:15:32",
            "upload_time_iso_8601": "2024-04-18T17:15:32.365782Z",
            "url": "https://files.pythonhosted.org/packages/7c/29/235e3eab73d1f7b25a830322eb25fe24b6b4d871132afd2c8ce1630960e9/pynapple-0.6.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 17:15:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pynapple-org",
    "github_project": "pynapple",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pynapple"
}
        
Elapsed time: 0.24751s