From 8acbead7226e2cdd3be756329a747e1b631c7db2 Mon Sep 17 00:00:00 2001 From: Guillaume Viejo Date: Mon, 30 Sep 2024 15:48:50 -0400 Subject: [PATCH 1/2] New front page --- docs/AUTHORS.md | 19 ++- docs/extra.css | 33 +++++ docs/images/Pynapple_logo_final.svg | 177 ++++++++++++++++++++++++ docs/index.md | 206 ++++++++++------------------ docs/installation.md | 41 ++++++ docs/quickstart.md | 87 ++++++++++++ mkdocs.yml | 33 ++++- 7 files changed, 454 insertions(+), 142 deletions(-) create mode 100644 docs/extra.css create mode 100644 docs/images/Pynapple_logo_final.svg create mode 100644 docs/installation.md create mode 100644 docs/quickstart.md diff --git a/docs/AUTHORS.md b/docs/AUTHORS.md index d6182d39..8633de39 100644 --- a/docs/AUTHORS.md +++ b/docs/AUTHORS.md @@ -1,5 +1,7 @@ -Credits -======= +--- +hide: + - navigation +--- Development Lead ---------------- @@ -12,8 +14,17 @@ Contributors ------------ - Adrien Peyrache -- Dan Levenstein +- Dan Levenstein - Sofia Skromne Carrasco - Davide Spalla - Luigi Petrucco - - ... [and many more!](https://github.com/pynapple-org/pynapple/graphs/contributors) \ No newline at end of file +- ... [and many more!](https://github.com/pynapple-org/pynapple/graphs/contributors) + +Special Credits +--------------- + +Special thanks to Francesco P. Battaglia +() for the development of the original +*TSToolbox* () and +*neuroseries* () packages, +the latter constituting the core of *pynapple*. diff --git a/docs/extra.css b/docs/extra.css new file mode 100644 index 00000000..7927fc70 --- /dev/null +++ b/docs/extra.css @@ -0,0 +1,33 @@ + /* Flexbox layout for the list items */ + .grid.cards ul > li { + display: flex !important; /* Ensure flexbox is applied */ + flex-direction: column; + justify-content: space-between; + height: 100%; + box-sizing: border-box; + } + + /* Ensure the link stays at the bottom */ + .grid.cards ul > li > p:last-of-type { + margin-top: auto; + padding-top: 10px; /* Optional spacing */ + } + + /* Adjust the spacing for the hr element */ + .grid.cards ul > li > hr { + margin: 10px 0; /* Adjust this value to match the original spacing */ + flex-shrink: 0; /* Prevent the hr from shrinking */ + } + + /* Center the icon and title within the first paragraph */ + .grid.cards ul > li > p:first-of-type { + display: flex; + align-items: center; + justify-content: center; + text-align: center; + } + + /* Add spacing between the icon and the title */ + .grid.cards ul > li > p:first-of-type img { + margin-right: 8px; + } \ No newline at end of file diff --git a/docs/images/Pynapple_logo_final.svg b/docs/images/Pynapple_logo_final.svg new file mode 100644 index 00000000..632d0080 --- /dev/null +++ b/docs/images/Pynapple_logo_final.svg @@ -0,0 +1,177 @@ + + + + diff --git a/docs/index.md b/docs/index.md index d505d2da..57d77d6e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,5 +1,14 @@ - +--- +hide: + - navigation + - toc +--- +#
Pynapple logo.
+ + +
+ [![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) @@ -7,163 +16,88 @@ ![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. +[:material-text-box-search-outline: __Documentation__](https://pynapple.org) | +[:material-book-open-variant-outline: __Cite the paper__](https://elifesciences.org/reviewed-preprints/85786) + +
+ -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__: +## __Overview__ -> **Note** -> :page_with_curl: If you are using pynapple, please cite the following [paper](https://elifesciences.org/reviewed-preprints/85786) +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. ------------------------------------------------------------------------- -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. +- :material-clock-fast:{ .lg .middle } __Getting Started__ -New releases :fire: ------------------- + --- -### pynapple >= 0.7 + New to Pynapple? Checkout the quickstart. -Pynapple now implements signal processing. For example, to filter a 1250 Hz sampled time series between 10 Hz and 20 Hz: + [:octicons-arrow-right-24: Quickstart](quickstart) -```python -nap.apply_bandpass_filter(signal, (10, 20), fs=1250) -``` -New functions includes power spectral density and Morlet wavelet decomposition. See the [documentation](https://pynapple-org.github.io/pynapple/reference/process/) for more details. +- :material-lightbulb-on-10:{ .lg .middle }   __How-To Guide__ -### 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: + Learn the pynapple API with notebooks. -```python -new_intervalset = intervalset.loc[[0]] # Selecting first interval -``` + [:octicons-arrow-right-24: API guide](https://pynapple.org/generated/api_guide/) -With pynapple>=0.6, the slicing is similar to numpy and it returns an `IntervalSet` +- :material-brain:{ .lg .middle}   __Neural Analysis__ -```python -new_intervalset = intervalset[0] -``` + --- -### pynapple >= 0.4 + Explore fully worked examples to learn how to analyze neural recordings using pynapple. + + [:octicons-arrow-right-24: Tutorials](https://pynapple.org/generated/examples/) -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. +- :material-cog:{ .lg .middle }   __API__ -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/api_guide/tutorial_pynapple_numpy/) for a demonstration of numpy compatibilities. + Access a detailed description of each module and function, including parameters and functionality. -Getting Started ---------------- + [:octicons-arrow-right-24: Modules](https://pynapple.org/reference/) -### Installation +- :material-hammer-wrench:{ .lg .middle }   __Installation Instructions__ -The best way to install pynapple is with pip within a new [conda](https://docs.conda.io/en/latest/) environment : + --- + + Run the following `pip` command in your virtual environment. + === "macOS/Linux" + ```bash + pip install pynapple + ``` + + === "Windows" + + ``` + python -m pip install pynapple + ``` -``` {.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 - - - -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, 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. - - -

- -

- -### Credits - -Special thanks to Francesco P. Battaglia -() for the development of the original -*TSToolbox* () and -*neuroseries* () packages, -the latter constituting the core of *pynapple*. - -This package was developped by Guillaume Viejo -() and other members of the Peyrache Lab. - - + *For more information see:*
+ [:octicons-arrow-right-24: Install](installation) + +- :material-frequently-asked-questions:{ .lg .middle }   __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. + + *To open an issue see :*
+ [:octicons-arrow-right-24: Issues](https://github.com/pynapple-org/pynapple/issues) + +
+ + + +## :material-scale-balance:{ .lg } License + +Open source, [licensed under MIT](https://github.com/pynapple-org/pynapple/blob/main/LICENSE). diff --git a/docs/installation.md b/docs/installation.md new file mode 100644 index 00000000..2a2e7611 --- /dev/null +++ b/docs/installation.md @@ -0,0 +1,41 @@ +--- +hide: + - navigation +--- + +# 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 + + diff --git a/docs/quickstart.md b/docs/quickstart.md new file mode 100644 index 00000000..f46b34d1 --- /dev/null +++ b/docs/quickstart.md @@ -0,0 +1,87 @@ +--- +hide: + - navigation +--- + +New releases :fire: +------------------ + +### pynapple >= 0.7 + +Pynapple now implements signal processing. For example, to filter a 1250 Hz sampled time series between 10 Hz and 20 Hz: + +```python +nap.apply_bandpass_filter(signal, (10, 20), fs=1250) +``` +New functions includes power spectral density and Morlet wavelet decomposition. See the [documentation](https://pynapple-org.github.io/pynapple/reference/process/) for more details. + +### 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] +``` + +### 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. + +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/api_guide/tutorial_pynapple_numpy/) for a demonstration of numpy compatibilities. + + +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, 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) + \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index f95ba2a4..d9a8d525 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -9,6 +9,30 @@ theme: primary: 'green' features: - navigation.tabs + markdown_extensions: + - attr_list + - admonition + - tables + - pymdownx.emoji: + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg + + features: + - content.tabs.link + - content.code.annotate + - content.code.copy + - announce.dismiss + - navigation.tabs + - navigation.instant + - navigation.instant.prefetch + - navigation.instant.preview + - navigation.instant.progress + - navigation.path + - navigation.sections + - navigation.top + - search.highlights + - search.share + - search.suggest plugins: - search @@ -38,7 +62,9 @@ plugins: separate_signature: true nav: - - Overview: index.md + - Overview: index.md + - Install: installation.md + - Quickstart: quickstart.md - Application guide: generated/api_guide - Analysis examples: generated/examples - External projects: external.md @@ -55,7 +81,7 @@ extra_javascript: extra_css: - https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.7/katex.min.css - + - extra.css markdown_extensions: - pymdownx.highlight: @@ -66,3 +92,6 @@ markdown_extensions: - pymdownx.snippets - pymdownx.superfences - admonition + - md_in_html + - pymdownx.tabbed: + alternate_style: true From 7212ca2d1693d18316053307dfc23361bcbaa7d5 Mon Sep 17 00:00:00 2001 From: Guillaume Viejo Date: Mon, 30 Sep 2024 15:55:46 -0400 Subject: [PATCH 2/2] Update index.md --- docs/index.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 57d77d6e..1953f50d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,6 @@ hide: ![GitHub contributors](https://img.shields.io/github/contributors/pynapple-org/pynapple) ![Twitter Follow](https://img.shields.io/twitter/follow/thepynapple?style=social) -[:material-text-box-search-outline: __Documentation__](https://pynapple.org) | [:material-book-open-variant-outline: __Cite the paper__](https://elifesciences.org/reviewed-preprints/85786)