-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFISH2_user_program.py
126 lines (105 loc) · 5.41 KB
/
FISH2_user_program.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
#Python 3 program to manage User function for FISH system 2.
#Date: 02 February 2017
#Author: Lars E. Borm
#E-mail: [email protected] or [email protected]
#Python version: 3.5.1
#Creates the FISH_System2_db
#Asks the user to input all data realated to one or two experiments
#Constant loop where the user can update the .yaml datafile which gets exported
#to the database.
import FISH2_peripherals as perif
import time
from sys import platform
color = True
try:
from colorama import Fore, Back, Style, init
except ImportError:
color = False
if color == True:
if platform == 'win32':
init()
#Make FISH system 2 database
db_path = perif.newFISHdb('FISH_System2_db')
time.sleep(5)
print('db_path: ', db_path)
#Fill .yaml datafile and export to datbase
perif.datafileUserUpdateAll(db_path)
#When required the user can update the datafile which gets exported to the database.
#Or the program can be paused.
while True:
while True:
print('\n'*5)
if color == True:
print('Do you want to:\n' + Fore.BLACK + Back.WHITE + '* update (all / part) ' + Style.RESET_ALL + ' of the experiment data \n' + Fore.BLACK + Back.WHITE + '* pause ' + Style.RESET_ALL + ' the experiment\n' + Fore.BLACK + Back.WHITE + '* prime ' + Style.RESET_ALL + ' the buffer line(s) \n' + Fore.BLACK + Back.WHITE + '* new exp ' + Style.RESET_ALL + ' Add a new experiment \n' + Fore.BLACK + Back.WHITE + '* remove New_EXP_Flag ' + Style.RESET_ALL + ' If imaging settings have been prepared \n' + Style.RESET_ALL + '\n')
print('Enter: ' + Fore.BLACK+Back.WHITE +' all ' + Style.RESET_ALL + ', ' + Fore.BLACK+Back.WHITE +' part ' + Style.RESET_ALL + ', ' + Fore.BLACK+Back.WHITE +' pause ' + Style.RESET_ALL + ', ' + Fore.BLACK+Back.WHITE +' prime '+ Style.RESET_ALL + ', ' + Fore.BLACK+Back.WHITE +' new ' + Style.RESET_ALL + ' or ' + Fore.BLACK+Back.WHITE +' remove ' + Style.RESET_ALL + '...')
awnser = input('...').lower()
else:
awnser = input('''Do you want to update (all / part), pause, add new, remove New_EXP_Flag?\nEnter "all", "part" or "pause"...''').lower()
if awnser == 'all' or awnser == 'part' or awnser == 'pause' or awnser == 'prime' or awnser =='new' or awnser == 'remove':
break
else:
print('Invalid input, choose between "all", "part", "pause", "new" or "remove"')
time.sleep(1)
if awnser == 'all':
perif.DBToYaml(db_path)
print('Buffer volumes & machines coppied to .yaml info file.')
perif.datafileUserUpdateAll(db_path)
print('All data updated.')
elif awnser == 'part':
perif.DBToYaml(db_path)
print('Buffer volumes & machines coppied to .yaml info file.')
perif.datafileUserUpdateParts(db_path)
print('Requested data updated.')
elif awnser == 'pause':
perif.setFlagDB(db_path, 'Pause_flag')
print('Experiment paused.\n')
input('Press enter to continue with experiment...')
perif.removeFlagDB(db_path, 'Pause_flag')
print('Experiment will resume. \n')
elif awnser == 'prime':
perif.userPrime(db_path)
elif awnser == 'new':
perif.setFlagDB(db_path, 'Pause_flag')
print('Experiment paused.\n')
perif.DBToYaml(db_path)
print('Buffer volumes & machines coppied to .yaml info file.')
perif.datafileUserUpdateAll(db_path)
input('Press enter if new experiment is connected and ready to be stained...')
print('\nIf possible, prepare the imaging now (set ROI, focus etc.)')
print('If not possible, you will be reminded when the current imaging is done.')
while True:
img_prep = input('Is the imaging already prepared? Y/N: ').lower()
if img_prep == 'y' or img_prep == 'n':
break
else:
print('Invalid input: {}. Choose: "Y" '.format(img_prep))
while True:
chamber = input('For which chamber is the imaging prepared, "1" or "2": ')
try:
chamber = int(chamber)
if chamber == 1 or chamber == 2:
break
else:
print('Invalid input: {}. Choose between "1" or "2"'.format(chamber))
except Exception as e:
print('Invalid input: {}. Choose between "1" or "2"'.format(chamber))
if img_prep == 'y':
perif.removeFlagDB(db_path, 'New_EXP_flag_{}'.format(chamber))
print('Imaging prepared, New_EXP_flag_{} removed\n'.format(chamber))
elif img_prep == 'n':
perif.setFlagDB(db_path, 'New_EXP_flag_{}'.format(chamber))
print('Imaging not yet prepared, New_EXP_flag_{} set'.format(chamber))
print('You will be notified when you can prepare the imaging\n')
perif.removeFlagDB(db_path, 'Pause_flag')
print('Experiment will resume. \n')
elif awnser == 'remove':
while True:
chamber = input('For which chamber is the imaging prepared, "1" or "2": ')
try:
chamber = int(chamber)
if chamber == 1 or chamber == 2:
break
except Exception as e:
print('Invalid input: {}. Choose between "1" or "2"'.format(chamber))
perif.removeFlagDB(db_path, 'New_EXP_flag_{}'.format(chamber))
print('#'*80)