-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_install.py
More file actions
174 lines (144 loc) · 5.54 KB
/
verify_install.py
File metadata and controls
174 lines (144 loc) · 5.54 KB
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/usr/bin/env python3
"""
Installation verification script for MEA-Flow.
This script checks that all core components are working correctly
and reports the status of optional dependencies.
"""
import sys
import warnings
def check_core_imports():
"""Check core MEA-Flow imports."""
print("🔍 Checking core imports...")
try:
import mea_flow
print("✅ mea_flow imported successfully")
except ImportError as e:
print(f"❌ Failed to import mea_flow: {e}")
return False
try:
from mea_flow import SpikeList, MEAMetrics, ManifoldAnalysis, MEAPlotter
print("✅ Core classes imported successfully")
except ImportError as e:
print(f"❌ Failed to import core classes: {e}")
return False
try:
from mea_flow.data import loaders
from mea_flow.analysis import metrics, activity, synchrony, regularity, burst_analysis
from mea_flow.manifold import analysis, embedding
from mea_flow.visualization import plotter
print("✅ All modules imported successfully")
except ImportError as e:
print(f"❌ Failed to import modules: {e}")
return False
return True
def check_dependencies():
"""Check status of core and optional dependencies."""
print("\n📦 Checking dependencies...")
# Core dependencies
core_deps = {
'numpy': 'numpy',
'scipy': 'scipy',
'pandas': 'pandas',
'matplotlib': 'matplotlib',
'seaborn': 'seaborn',
'sklearn': 'sklearn',
'h5py': 'h5py',
'tqdm': 'tqdm',
'joblib': 'joblib'
}
all_core_ok = True
for name, import_name in core_deps.items():
try:
__import__(import_name)
print(f"✅ {name}")
except ImportError:
print(f"❌ {name} - REQUIRED")
all_core_ok = False
# Optional dependencies
print("\n🔧 Optional dependencies:")
try:
import pyspike
print("✅ PySpike - Advanced spike train distance measures available")
except ImportError:
print("⚠️ PySpike - Not installed (spike distances will use fallback methods)")
try:
import umap
print("✅ UMAP - UMAP manifold learning available")
except ImportError:
print("⚠️ UMAP - Not installed (UMAP embedding will be disabled)")
return all_core_ok
def test_basic_functionality():
"""Test basic functionality with synthetic data."""
print("\n🧪 Testing basic functionality...")
try:
import numpy as np
from mea_flow import SpikeList, MEAMetrics
# Create simple synthetic data
np.random.seed(42)
n_channels = 16
n_spikes_per_channel = 50
recording_length = 10.0 # seconds
spike_data = []
channel_ids = []
for ch in range(n_channels):
# Generate random spike times
spike_times = np.sort(np.random.uniform(0, recording_length, n_spikes_per_channel))
spike_data.extend(spike_times)
channel_ids.extend([ch] * len(spike_times))
# Create SpikeList
spike_list = SpikeList(
spike_data={'times': spike_data, 'channels': channel_ids},
recording_length=recording_length
)
print("✅ SpikeList creation successful")
# Test metrics calculation
metrics = MEAMetrics()
results = metrics.compute_all_metrics(spike_list, grouping='global')
print("✅ Metrics calculation successful")
# Test manifold analysis
from mea_flow import ManifoldAnalysis
manifold = ManifoldAnalysis()
with warnings.catch_warnings():
warnings.simplefilter("ignore")
pop_results = manifold.analyze_population_dynamics(spike_list)
print("✅ Manifold analysis successful")
print("🎉 All basic functionality tests passed!")
return True
except Exception as e:
print(f"❌ Basic functionality test failed: {e}")
return False
def main():
"""Run all verification tests."""
print("🚀 MEA-Flow Installation Verification")
print("=" * 40)
# Check Python version
python_version = sys.version_info
if python_version < (3, 10):
print(f"❌ Python {python_version.major}.{python_version.minor} detected. Python 3.10+ required.")
return False
else:
print(f"✅ Python {python_version.major}.{python_version.minor}.{python_version.micro}")
# Run checks
core_ok = check_core_imports()
deps_ok = check_dependencies()
func_ok = test_basic_functionality() if core_ok else False
print("\n" + "=" * 40)
if core_ok and deps_ok and func_ok:
print("🎉 MEA-Flow installation verified successfully!")
print("\n💡 Next steps:")
print(" - Check out the tutorial: notebooks/01_mea_flow_tutorial.ipynb")
print(" - Read the documentation in docs/")
print(" - Try analyzing your MEA data!")
return True
else:
print("❌ Installation verification failed.")
print("\n🔧 Troubleshooting:")
if not core_ok:
print(" - Reinstall MEA-Flow: uv pip install -e .")
if not deps_ok:
print(" - Check missing dependencies and install if needed")
print(" - Check the README.md for installation instructions")
return False
if __name__ == "__main__":
success = main()
sys.exit(0 if success else 1)