-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.py
150 lines (98 loc) · 3.67 KB
/
module.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# env_2 has all of these packages installed.
import numpy as np
import pandas as pd
import polars as pl
from scipy import signal as ss
from scipy.optimize import curve_fit
from scipy.stats import wilcoxon # Wilcoxon signed-rank test.
from scipy.stats import mannwhitneyu
from scipy.stats import kruskal as kw # Kruskal-Wallis H-test for independent samples.
from scipy.stats import normaltest as norm
import scipy.cluster.hierarchy as sch
from scipy.cluster.hierarchy import dendrogram
# geometric mean & standard deviation.
from scipy.stats import gmean
from scipy.stats import gstd
from scipy.io import savemat
from scipy.io import loadmat
import scipy.interpolate as IPL
from scipy.interpolate import griddata
# %%
import dask.dataframe as dd
from dask.diagnostics import ProgressBar
from dask.distributed import Client
from dask.distributed import get_task_stream
# %%
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.lines import Line2D
from matplotlib.colors import LogNorm
import seaborn as sns
import plotly.express as px
# %%
############
# these 2 modules are not present in env_11 environment.
from open_ephys.analysis import Session
from PyPDF2 import PdfFileMerger, PdfFileReader
import adaptivekde as opt
# opt
# Out[39]: <module 'adaptivekde' from '/home/azare/anaconda3/envs/env_2/lib/python3.10/site-packages/adaptivekde/__init__.py'>
################
#
#
# %%
pd.set_option('display.float_format', lambda x: '%.6f' % x)
# sns.set(font_scale=1.75) # this makes the default seaborn : gray background with grids.
# sns.set_style("white")
# sns.set(style="whitegrid", font_scale=1.75)
# font_scale : I made it 3 for statistical plots.
sns.set(style="ticks", font_scale=2) # matplotlib style : only the fontsize is changed.
np.set_printoptions(suppress=True)
# %%
###################
import spikeinterface as si
import spikeinterface.extractors as se
import spikeinterface.sorters as sst
import spikeinterface.widgets as sw
import spikeinterface.exporters as exp
from spikeinterface.preprocessing import (bandpass_filter, common_reference)
import spikeinterface.preprocessing as prep
import spikeinterface.postprocessing as post
import spikeinterface.qualitymetrics as qm
from spikeinterface.qualitymetrics import compute_quality_metrics
# note : this is part of the spikeinterface[full] installation.
# no need to install it separately !!
from probeinterface import read_probeinterface
##############
import spikeinterface.curation as cur
from spikeinterface.sortingcomponents.peak_detection import detect_peaks
from spikeinterface.sortingcomponents.peak_localization import localize_peaks
from spikeinterface.sortingcomponents.motion_estimation import estimate_motion
from spikeinterface.sortingcomponents.motion_correction import CorrectMotionRecording
#################
import pickle
import copy
# %%
# import hyperspy.api as hs
#
#from math import pi
#
#import sounddevice as sd
#
# %%
from sklearn.pipeline import make_pipeline as mpl
from sklearn.metrics import r2_score , silhouette_score
from sklearn.preprocessing import StandardScaler as stsc
from sklearn.model_selection import GridSearchCV
from sklearn.preprocessing import PolynomialFeatures as pf
from sklearn.linear_model import LinearRegression as LR
from sklearn.cluster import AgglomerativeClustering
from sklearn.cluster import DBSCAN
from sklearn.cluster import KMeans
# %%
import math
import os
import collections
# progress bar
from tqdm import tqdm
tqdm.pandas() # Enable tqdm for pandas operations