https://github.com/deepcharles/mousemonitor
https://github.com/deepcharles/mousemonitor
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deepcharles/mousemonitor
- Owner: deepcharles
- License: mit
- Created: 2024-11-16T07:59:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-16T13:53:03.000Z (over 1 year ago)
- Last Synced: 2025-03-13T04:17:35.836Z (over 1 year ago)
- Language: Python
- Size: 1.42 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# An α7 nicotinic and GABAB receptor-mediated pathway controls acetylcholine release in the tripartite neuromuscular junction
Python implementation of the algorithm described in **(Krejci, et al., 2024)**.
- Krejci, E., Konstantin, P., Lenina, O., Bernard, V., Germain, T., Truong, C., Nurullin, L., Sibgatullina, G., Samigullin, D., & Ohno, K. (2024). An α7 nicotinic and GABAB receptor-mediated pathway controls acetylcholine release in the tripartite neuromuscular junction. The Journal of Physiology.
## Install
Clone this repository and within the downloaded directory, execute the following command.
```bash
python -m pip install .
```
## Example usage
The following code perform the active/inactive segmentation on a signal example collected using the protocol in the article.
The signal has been preprocessed beforehand.
### Import librairies
```python
import numpy as np
import matplotlib.pyplot as plt
from mousemonitor import opt_state_sequence_binary
```
### Load data and define parameters
```python
data = np.load("example.npz")
signal = data["signal"]
mvt = data["mvt"]
time_array = data["time_array"]
fs = data["fs"]
is_active = np.where(np.diff(signal) > 0, 1, -1)
PENALTY = 3000
```
### Perform signal segmentation and plot
```python
bkps, opt_state_sequence = opt_state_sequence_binary(is_active, penalty=PENALTY)
```
```python
fig, (main_plot, main_timeline) = plt.subplots(
nrows=2,
ncols=1,
figsize=(15, 7),
sharex=True,
gridspec_kw={"height_ratios": [6, 1]},
)
main_plot.set_xmargin(0)
main_plot.set_xlabel("Time (h)")
main_plot.set_xticks([1, 3, 5, 7, 9, 11])
main_plot.set_ylabel("Active - Inactive (min)")
main_plot.set_ylim(-500, 500)
main_plot.axhline(0, color="k", alpha=0.1)
main_timeline.set_xmargin(0)
main_timeline.set_xlabel("Time (h)")
main_timeline.set_xticks([1, 3, 5, 7, 9, 11])
main_timeline.set_yticks([])
main_plot.plot(time_array[:-1] / 3600, np.cumsum(is_active) / fs / 60, color="b")
for b in bkps:
main_plot.axvline(time_array[b] / 3600, ls="--", color="k", alpha=0.2)
main_timeline.imshow(
1 - opt_state_sequence[None, :],
aspect="auto",
cmap="Greens",
interpolation="nearest",
extent=[0, 12, 0, 1],
alpha=0.8,
vmax=2,
vmin=-0.5,
)
fig.tight_layout()
```
