Skip to content

Commit

Permalink
small progress on LFO preprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
bouromain committed Oct 26, 2023
1 parent 9e4c71b commit 3580888
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: hippocampy

dependencies:
- python>=3.8,<3.11
- python>=3.8,<3.12
- pip
- mkl
- numpy
Expand Down
2 changes: 1 addition & 1 deletion hippocampy/matrix_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ def find_peak_row(M, zero_idx=None):
"""
if zero_idx is None:
zero_idx = M.shape[1] / 2
zero_idx = int(M.shape[1] / 2)

bef = np.hstack((np.atleast_2d(M[:, 0]).T, M[:, :-1]))
aft = np.hstack((M[:, 1:], np.atleast_2d(M[:, -1]).T))
Expand Down
42 changes: 28 additions & 14 deletions hippocampy/plot/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@


def joy_plot(F: np.ndarray, T=None, n_traces=20):

plt.figure


def line_error(M:np.ndarray, x:np.ndarray = None, color:str=None,alpha:float= 0.4, var_type:str = 'ste'):
def line_error(
M: np.ndarray,
x: np.ndarray = None,
color: str = None,
alpha: float = 0.4,
var_type: str = "ste",
):
"""
line_error return a axis handle of a line plot with shaded error overlaid
line_error return a axis handle of a line plot with shaded error overlaid
around this average/median curve
Parameters
Expand All @@ -31,7 +36,7 @@ def line_error(M:np.ndarray, x:np.ndarray = None, color:str=None,alpha:float= 0.
-------
ax
figure axis
Raises
------
Expand All @@ -41,18 +46,27 @@ def line_error(M:np.ndarray, x:np.ndarray = None, color:str=None,alpha:float= 0.
_description_
"""

if var_type not in ['ste', 'std']:
raise ValueError('var_type should either be ste: standard error or std: standard deviation')
m = bn.nanmean(M,axis=0)
ste = bn.nanstd(M,axis=0,ddof=1) / np.sqrt(M.shape[0])

if x is None:
if var_type not in ["ste", "std"]:
raise ValueError(
"var_type should either be ste: standard error or std: standard deviation"
)
m = bn.nanmean(M, axis=0)
ste = bn.nanstd(M, axis=0, ddof=1) / np.sqrt(M.shape[0])

if x is None:
x = np.arange(len(m))
else:
if len(m) != len(x):
raise ValueError('Size mismatch between x and input matrix M')
raise ValueError("Size mismatch between x and input matrix M")

plt.plot(x, m,color=color)
plt.fill_between(x,m-ste, m+ste,alpha=alpha, antialiased=True, edgecolor=color, facecolor=color)
plt.plot(x, m, color=color)
plt.fill_between(
x,
m - ste,
m + ste,
alpha=alpha,
antialiased=True,
edgecolor=color,
facecolor=color,
)
return plt.gca()

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
author="Bourboulou Romain",
author_email="[email protected]",
packages=["hippocampy"],
python_requires=">=3.7, <3.11",
python_requires=">=3.7, <3.12",
install_requires=[
"numpy",
"scipy",
Expand Down

0 comments on commit 3580888

Please sign in to comment.