forked from jamieboyd/AutoHeadFix
-
Notifications
You must be signed in to change notification settings - Fork 2
/
AHF_BrainLight.py
56 lines (48 loc) · 1.74 KB
/
AHF_BrainLight.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
#! /usr/bin/python3
#-*-coding: utf-8 -*-
from abc import ABCMeta, abstractmethod
from time import sleep
from AHF_Base import AHF_Base
class AHF_BrainLight(AHF_Base, metaclass = ABCMeta):
defaultDelay = 3.0
@staticmethod
@abstractmethod
def config_user_get(starterDict = {}):
ledDelay = starterDict.get('ledDelay', AHF_BrainLight.defaultDelay)
response = input('Delay in seconds before turning on\after turning off lights(currently %.2f): ' % ledDelay)
if response != '':
ledDelay = float(response)
starterDict.update({'ledDelay' : ledDelay})
return starterDict
@abstractmethod
def onForStim(self):
"""
Runs when headFixing starts, illuminating the brain or whatever needs illuminating
"""
if self.task.isFixTrial:
self.task.ContactCheck.turnOff()
pass
@abstractmethod
def offForStim(self):
"""
Runs when headFixing ends, turning off whatever was turned on
"""
self.task.ContactCheck.turnOn()
pass
def hardwareTest(self):
"""
generic hardware tester for brain illumination, turns on, waits 2 seconds, turns off
"""
saveDelay = self.ledDelay
self.ledDelay =0
self.onForStim()
print('Turning brain illumination ON for two seconds....')
sleep(2)
print('Turning brain illumination OFF.')
self.offForStim()
self.ledDelay = saveDelay
result = input('Do you wish to edit brain light settings? y/n ')
if result [0] == 'y' or result [0] == 'Y':
self.setdown()
self.settingsDict.update(self.config_user_get(self.settingsDict))
self.setup()