-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoSave.py
49 lines (39 loc) · 1.39 KB
/
AutoSave.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
"""AutoSave plugin.
To activate the plugin, copy this file to `~/.phy/plugins/` and add this line
to your `~/.phy/phy_config.py`:
```python
c.TemplateGUI.plugins = ['AutoSave']
```
Luke Shaheen - Laboratory of Brain, Hearing and Behavior Sept 2021
"""
import numpy as np
from phy import IPlugin, connect
import os.path as op
import threading
import time
# spike_clusters, groups, labels,
class AutoSave(IPlugin):
def attach_to_controller(self, controller):
@connect
def on_gui_ready(sender,gui):
#class BackgroundTimer(threading.Thread):
# def run(self):
# while 1:
# time.sleep(60*5)
# print('\Saving')
# print(time.localtime())
# gui.file_actions.save()
#gui.timer = BackgroundTimer()
#gui.timer.start()
#print('Started timer')
@connect(sender=controller.supervisor)
def on_cluster(sender, up, gui=gui):
"""This is called every time a cluster assignment or cluster group/label
changes."""
print("Save on clustering")
if up.description == 'metadata_group':
gui.file_actions.save()
#@connect(sender=gui)
#def on_close(sender):
# print('Stopped timer')
# sender.timer.stop()