Skip to content

Commit db0c121

Browse files
authored
Merge pull request #8 from alustig3/experiment-subsets
Experiment flexibility
2 parents c3f0211 + b326f4f commit db0c121

File tree

9 files changed

+400
-210
lines changed

9 files changed

+400
-210
lines changed

com/data_logger.py

100644100755
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,20 @@ def set_state_machine(self, sm_info):
2121
in self.sm_info['analog_inputs'].items()}
2222
self.analog_files = {ai['ID']: None for ai in self.sm_info['analog_inputs'].values()}
2323

24-
def open_data_file(self, data_dir, experiment_name, subject_ID, datetime_now=None):
24+
def open_data_file(self, data_dir, experiment_name, setup_ID, subject_ID, datetime_now=None):
2525
'''Open data file and write header information.'''
2626
self.data_dir = data_dir
2727
self.experiment_name = experiment_name
2828
self.subject_ID = subject_ID
29+
self.setup_ID = setup_ID
2930
if datetime_now is None: datetime_now = datetime.now()
3031
file_name = os.path.join(self.subject_ID + datetime_now.strftime('-%Y-%m-%d-%H%M%S') + '.txt')
3132
self.file_path = os.path.join(self.data_dir, file_name)
3233
self.data_file = open(self.file_path, 'w', newline = '\n')
3334
self.data_file.write('I Experiment name : {}\n'.format(self.experiment_name))
3435
self.data_file.write('I Task name : {}\n'.format(self.sm_info['name']))
3536
self.data_file.write('I Task file hash : {}\n'.format(self.sm_info['task_hash']))
37+
self.data_file.write('I Setup ID : {}\n'.format(self.setup_ID))
3638
self.data_file.write('I Subject ID : {}\n'.format(self.subject_ID))
3739
self.data_file.write('I Start date : ' + datetime_now.strftime('%Y/%m/%d %H:%M:%S') + '\n\n')
3840
self.data_file.write('S {}\n\n'.format(json.dumps(self.sm_info['states'])))

data/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Ignore all contents of data folder except .gitignore needed to ensure folder is version controlled.
1+
# Ignore all contents of folder except .gitignore needed to ensure folder is version controlled.
22
*
33
!.gitignore

experiments/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore all contents of folder except .gitignore needed to ensure folder is version controlled.
2+
*
3+
!.gitignore

experiments/.hgempty

Whitespace-only changes.

gui/configure_experiment_tab.py

100644100755
Lines changed: 114 additions & 49 deletions
Large diffs are not rendered by default.

gui/dialogs.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,24 @@ def __init__(self, parent, sv_dict):
208208

209209
# Invalid experiment dialog. ---------------------------------------------------------
210210

211-
def invalid_experiment_dialog(parent, message):
212-
QtGui.QMessageBox.question(parent, 'Invalid experiment',
211+
def invalid_run_experiment_dialog(parent, message):
212+
QtGui.QMessageBox.warning(parent, 'Invalid experiment',
213213
message + '\n\nUnable to run experiment.', QtGui.QMessageBox.Ok)
214214

215+
def invalid_save_experiment_dialog(parent, message):
216+
QtGui.QMessageBox.warning(parent, 'Invalid experiment',
217+
message + '\n\nUnable to save experiment.', QtGui.QMessageBox.Ok)
218+
219+
# Unrun subjects warning ---------------------------------------------------------
220+
221+
def unrun_subjects_dialog(parent,message):
222+
reply = QtGui.QMessageBox.warning(parent, 'Unrun Subjects',
223+
'The following Subjects will not be run:\n\n{}'.format(message), (QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
224+
if reply == QtGui.QMessageBox.Ok:
225+
return True
226+
else:
227+
return False
228+
215229
# Keyboard shortcuts dialog. ---------------------------------------------------------
216230

217231
class Keyboard_shortcuts_dialog(QtGui.QDialog):

gui/plotting.py

100644100755
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,32 +290,36 @@ def __init__(self, parent=None):
290290
self.subject_tabs = detachableTabWidget(self)
291291
self.setCentralWidget(self.subject_tabs)
292292
self.subject_plots = []
293+
self.active_plots = []
293294

294295
def setup_experiment(self, experiment):
295296
'''Create task plotters in seperate tabs for each subject.'''
296-
for setup in sorted(experiment['subjects'].keys()):
297+
subject_dict = experiment['subjects']
298+
subjects = subject_dict.keys()
299+
for subject in sorted(subjects):
297300
self.subject_plots.append(Task_plot(self))
298301
self.subject_tabs.addTab(self.subject_plots[-1],
299-
'{} : {}'.format(setup, experiment['subjects'][setup]))
302+
'{} : {}'.format(subject_dict[subject]['setup'], subject))
300303

301304
def set_state_machine(self, sm_info):
302305
'''Provide the task plotters with the state machine info.'''
303306
for subject_plot in self.subject_plots:
304307
subject_plot.set_state_machine(sm_info)
305308

306-
def start_experiment(self):
307-
for subject_plot in self.subject_plots:
308-
subject_plot.run_start(False)
309+
def start_experiment(self,rig):
310+
self.subject_plots[rig].run_start(False)
311+
self.active_plots.append(rig)
309312

310313
def close_experiment(self):
311314
'''Remove and delete all subject plot tabs.'''
312315
while len(self.subject_plots) > 0:
313316
subject_plot = self.subject_plots.pop()
314317
subject_plot.setParent(None)
315318
subject_plot.deleteLater()
316-
319+
self.close()
320+
317321
def update(self):
318322
'''Update the plots of the active tab.'''
319-
for subject_plot in self.subject_plots:
320-
if not subject_plot.visibleRegion().isEmpty():
323+
for i,subject_plot in enumerate(self.subject_plots):
324+
if not subject_plot.visibleRegion().isEmpty() and i in self.active_plots:
321325
subject_plot.update()

0 commit comments

Comments
 (0)