Skip to content

Commit

Permalink
fixed dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
BalzaniEdoardo committed Nov 15, 2024
1 parent 7a62e99 commit 3ba0d4e
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 37 deletions.
1 change: 1 addition & 0 deletions docs/assets/NeMoS_Logo_CMYK_White.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions docs/background/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,38 @@ pip install nemos[examples]

:::

::::{grid} 1 2 3 3

:::{grid-item-card}
```{toctree}
:maxdepth: 2
:caption: Contents
plot_00_conceptual_intro.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_01_1D_basis_function.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_02_ND_basis_function.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_03_1D_convolution.md
```
```
:::

::::
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@

html_theme = 'pydata_sphinx_theme'

html_logo = "assets/NeMoS_Logo_CMYK_Full.svg"
html_favicon = "assets/NeMoS_favicon.ico"

# Additional theme options
Expand All @@ -133,6 +132,10 @@
"show_prev_next": True,
"header_links_before_dropdown": 6,
"navigation_depth": 3,
"logo": {
"image_light": "_static/NeMoS_Logo_CMYK_Full.svg",
"image_dark": "_static/NeMoS_Logo_CMYK_White.svg",
}
}

html_context = {
Expand Down
37 changes: 35 additions & 2 deletions docs/how_to_guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,46 @@ pip install nemos[examples]
:::


::::{grid} 1 2 3 3

:::{grid-item-card}
```{toctree}
:maxdepth: 2
:caption: Contents
plot_02_glm_demo.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_03_population_glm.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_04_batch_glm.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_05_sklearn_pipeline_cv_demo.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_06_glm_pytree.md
```
```
:::

::::
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

# Install

## Prerequisites

Expand Down
45 changes: 43 additions & 2 deletions docs/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,55 @@ pip install nemos[examples]
```
:::

::::{grid} 1 2 3 3

:::{grid-item-card}
```{toctree}
:maxdepth: 2
:caption: Contents
plot_01_current_injection.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_02_head_direction.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_03_grid_cells.md
```
:::


:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_04_v1_cells.md
```
:::


:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_05_place_cells.md
```
:::

:::{grid-item-card}
```{toctree}
:maxdepth: 2
plot_06_calcium_imaging.md
```
```
:::

::::
4 changes: 2 additions & 2 deletions docs/tutorials/plot_04_v1_cells.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sta = nap.compute_event_trigger_average(spikes, stimulus, binsize=0.025,
windowsize=(-0.15, 0.0))
```

sta is a `TsdTensor`, which gives us the 2d receptive field at each of the
sta is a [`TsdTensor`](https://pynapple.org/generated/pynapple.core.time_series.TsdTensor.html), which gives us the 2d receptive field at each of the
time points.


Expand Down Expand Up @@ -291,7 +291,7 @@ filtered_stimulus
We can see that the time points are now aligned, and we've filled forward the
values the way we'd like.

Now, similar to the [head direction tutorial](../plot_02_head_direction), we'll
Now, similar to the [head direction tutorial](plot_02_head_direction), we'll
use the log-stretched raised cosine basis to create the predictor for our
GLM:

Expand Down
31 changes: 18 additions & 13 deletions docs/tutorials/plot_05_place_cells.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ from nemos import _documentation_utils as doc_plots
# configure plots some
plt.style.use(nmo.styles.plot_style)
# shut down jax to numpy conversion warning
nap.nap_config.suppress_conversion_warnings = True
```

## Data Streaming
Expand Down Expand Up @@ -118,7 +121,7 @@ for i, n in enumerate(order):

## Phase precession

In addition to place modulation, place cells are also modulated by the theta oscillation. The phase at which neurons fire is dependant of the position. This phenomen is called "phase precession" (see [J. O’Keefe, M. L. Recce, "Phase relationship between hippocampal place units and the EEG theta rhythm." Hippocampus 3, 317–330 (1993).](https://doi.org/10.1002/hipo.450030307)
In addition to place modulation, place cells are also modulated by the theta oscillation. The phase at which neurons fire is dependant of the position. This phenomen is called "phase precession" (see [J. O’Keefe, M. L. Recce, "Phase relationship between hippocampal place units and the EEG theta rhythm." Hippocampus 3, 317–330 (1993).](https://doi.org/10.1002/hipo.450030307)).

Let's compute the response of the neuron as a function of both theta and position. The phase of theta has already been computed but we have to bring it to the same dimension as the position feature. While the position has been sampled at 40Hz, the theta phase has been computed at 1250Hz.
Later on during the analysis, we will use a bin size of 5 ms for counting the spikes. Since this corresponds to an intermediate frequency between 40 and 1250 Hz, we will bring all the features to 200Hz already.
Expand All @@ -142,7 +145,7 @@ data = nap.TsdFrame(
print(data)
```

`data` is a `TsdFrame` that contains the position and phase. Before calling `compute_2d_tuning_curves` from pynapple to observe the theta phase precession, we will restrict the analysis to the place field of one neuron.
`data` is a [`TsdFrame`](https://pynapple.org/generated/pynapple.core.time_series.TsdTensor.html) that contains the position and phase. Before calling [`compute_2d_tuning_curves`](https://pynapple.org/generated/pynapple.process.tuning_curves.html#pynapple.process.tuning_curves.compute_2d_tuning_curves) from pynapple to observe the theta phase precession, we will restrict the analysis to the place field of one neuron.

There are a lot of neurons but for this analysis, we will focus on one neuron only.

Expand All @@ -163,7 +166,7 @@ This neurons place field is between 0 and 60 cm within the linear track. Here we
within_ep = position.threshold(60.0, method="below").time_support
```

`within_ep` is an `IntervalSet`. We can now give it to `compute_2d_tuning_curves` along with the spiking activity and the position-phase features.
`within_ep` is an [`IntervalSet`](https://pynapple.org/generated/pynapple.core.interval_set.IntervalSet.html). We can now give it to [`compute_2d_tuning_curves`](https://pynapple.org/generated/pynapple.process.tuning_curves.html#pynapple.process.tuning_curves.compute_2d_tuning_curves) along with the spiking activity and the position-phase features.


```{code-cell} ipython3
Expand Down Expand Up @@ -219,14 +222,14 @@ for s, e in data.time_support.values: # Time support contains the epochs
speed = nap.Tsd(t=data.t, d=np.hstack(speed), time_support=data.time_support)
```

Now that we have the speed of the animal, we can compute the tuning curves for speed modulation. Here we call pynapple `compute_1d_tuning_curves`:
Now that we have the speed of the animal, we can compute the tuning curves for speed modulation. Here we call pynapple [`compute_1d_tuning_curves`](https://pynapple.org/generated/pynapple.process.tuning_curves.html#pynapple.process.tuning_curves.compute_1d_tuning_curves):


```{code-cell} ipython3
tc_speed = nap.compute_1d_tuning_curves(spikes, speed, 20)
```

To assess the variabilty in speed when the animal is travering the linear track, we can compute the average speed and estimate the standard deviation. Here we use numpy only and put the results in a pandas `DataFrame`:
To assess the variabilty in speed when the animal is travering the linear track, we can compute the average speed and estimate the standard deviation. Here we use numpy only and put the results in a pandas [`DataFrame`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html):


```{code-cell} ipython3
Expand Down Expand Up @@ -285,9 +288,9 @@ print(count.shape)

For each feature, we will use a different set of basis :

- position : `nmo.basis.MSplineBasis`
- theta phase : `nmo.basis.CyclicBSplineBasis`
- speed : `nmo.basis.MSplineBasis`
- position : [`MSplineBasis`](nemos.basis.MSplineBasis)
- theta phase : [`CyclicBSplineBasis`](nemos.basis.CyclicBSplineBasis)
- speed : [`MSplineBasis`](nemos.basis.MSplineBasis)


```{code-cell} ipython3
Expand Down Expand Up @@ -335,7 +338,7 @@ glm.fit(X, count)

## Prediction

Let's check first if our model can accurately predict the different tuning curves we displayed above. We can use the `predict` function of NeMoS and then compute new tuning curves
Let's check first if our model can accurately predict the different tuning curves we displayed above. We can use the [`predict`](nemos.glm.GLM.predict) function of NeMoS and then compute new tuning curves


```{code-cell} ipython3
Expand Down Expand Up @@ -367,9 +370,10 @@ fig = doc_plots.plot_position_phase_speed_tuning(

While this model captures nicely the features-rate relationship, it is not necessarily the simplest model. Let's construct several models and evaluate their score to determine the best model.

!!! note
To shorten this notebook, only a few combinations are tested. Feel free to expand this list.
:::{note}

To shorten this notebook, only a few combinations are tested. Feel free to expand this list.
:::


```{code-cell} ipython3
Expand Down Expand Up @@ -440,8 +444,9 @@ plt.tight_layout()

Some models are doing better than others.

!!! warning
A proper model comparison should be done by scoring models repetitively on various train and test set. Here we are only doing partial models comparison for the sake of conciseness.
:::{warning}
A proper model comparison should be done by scoring models repetitively on various train and test set. Here we are only doing partial models comparison for the sake of conciseness.
:::

Alternatively, we can plot some tuning curves to compare each models visually.

Expand Down
Loading

0 comments on commit 3ba0d4e

Please sign in to comment.