Commit 3d639aab authored by Hao Ting Wang's avatar Hao Ting Wang

Add details in readme

parent 912f613f
06/11/2018
Major update.
* add experience sampling probes.
See example_trial_generator.py for the limitation of the set-up.
29/09/2017
Intreme version of the task is ready.
......
......@@ -14,11 +14,34 @@ Project Organization
├── LICENSE
├── README.md <- The top-level README for developers using this project.
├── settings.py <- Enviromnetal setting of the task.
├── run.py <- The main experiment program.
├── examples <- Examples.
├── instructions <- Instructions .txt files. '#' used as page breaker
├── run.py <- The main experiment program.
├── example_trial_generator.py
| <- The example of the trial generator.
├── instructions <- Instructions .txt files.
├── data <- Data generated from the task. Read-only.
├── parameters <- Trial generation specification files.
├── src <- Source code for use in this project.
└── stimuli <- stimulus photos
└── stimuli <- stimulus photos and experience sampling questions
## Modifying experience sampling questions
Change the questions/scales/lable in `stimuli/ES_questions.csv`.
Please leave the headers untouch.
## Modifying instructions
'#' used as page breaker
The text in between curly breackates {} changes in the experiment. Please do not modify the text inside the breakets.
## Modifying MRI related setting
This script supports the buttom boxes set-up in York Neuroimaging Centre.
The two buttom boxes are mapped to number 1 to 4 and 6 to 9 on a regular keyboard.
Number 5 is linked to MRI trigger setting.
If your neuroimaging centre uses the same set up, there's no need to modify the code.
If you use parallel port, please contact your local support to find out the setting and modify the code yourself.
The dummy volumes are accounted for in the scanner used at York.
If you require manual set up, please modify the variable in `run.py` accordingly.
......@@ -13,38 +13,40 @@ from settings import *
from src.experiment import *
from src.fileIO import read_only, write_csv
INFO = {
'Experiment': 'nback_mpsych', # compulsory
'Subject': 'R0001_001', # compulsory
'Experiment': 'nback_expsampling', # compulsory
'Subject': '001', # compulsory
'Run': '1', # compulsory
'Version': ['A', 'B'], # counterbalance the fixation color
'N-back': ['0', '1'], # start the task with 1-back or 0-back
'Environment': ['mri', 'lab']
'Environment': ['mri', 'lab'] # mri version can be tested on a normal stimuli delivery pc
}
# collect participant info
experiment_info = subject_info(INFO)
# MRI related settings
dummy_vol = 0
tr = 2
trigger_code = '5'
# set up enviroment variables and generators
# set test to False when collecting participant
settings = get_settings(
env=experiment_info['Environment'],
ver=experiment_info['Version'], test=False)
trial_generator, headers = get_trial_generator(experiment_info['N-back'])
def run_experiment():
# collect participant info
experiment_info = subject_info(INFO)
# skip instruction expect run 1
if experiment_info['Run'] == '1':
skip_instruction = False
else:
skip_instruction = True
# set up enviroment variables and generators
# set test to False when collecting participant
settings = get_settings(
env=experiment_info['Environment'],
ver=experiment_info['Version'], test=False)
trial_generator, headers = get_trial_generator(experiment_info['N-back'])
# skip instruction expect run 1
if experiment_info['Run'] == '1':
skip_instruction = False
else:
skip_instruction = True
# now run this thing
if __name__ == "__main__":
# set working directory as the location of this file
_thisDir = os.path.dirname(os.path.abspath(__file__)
).decode(sys.getfilesystemencoding())
os.chdir(_thisDir)
# set log file
event_logger(settings['logging_level'], experiment_info['LogFile'])
......@@ -83,7 +85,7 @@ if __name__ == "__main__":
# generate trials
Experiment.trials = next(trial_generator)
# wait trigger
instructions.waitTrigger()
instructions.waitTrigger(trigger_code)
# get a global clock
timer = core.Clock()
......@@ -103,7 +105,7 @@ if __name__ == "__main__":
fixation.set_trial(trial)
fix_t = fixation.show(timer)
print(trial['TrialType'])
if trial['TrialType'] == 'ExpSample':
question.set(trial)
start_stim, Resp, rt = question.show(timer)
......@@ -147,3 +149,13 @@ if __name__ == "__main__":
# quit
Experiment.window.close()
core.quit()
# now run this thing
if __name__ == "__main__":
# set working directory as the location of this file
_thisDir = os.path.dirname(os.path.abspath(__file__)
).decode(sys.getfilesystemencoding())
os.chdir(_thisDir)
run_experiment()
......@@ -28,10 +28,6 @@ instr_txt = './instructions/exp_instr_es.txt'
ready_txt = './instructions/wait_trigger.txt'
# MRI related settings
dummy_vol = 0
tr = 2
from psychopy import logging
from src.fileIO import write_csv, create_headers, load_conditions_dict
from src.datastructure.stimulus import stimulus_onefeat, stimulus_ExpSample
......@@ -49,10 +45,12 @@ BASE = {
}
# Testing settings
TEST = {
# Development environment settings. Used for testing,
# outside of the MR room.
DEV = {
'env': 'dev',
'test': True,
'window_size': (1280, 720),
'window_size': (800, 600),,
'logging_level': logging.DEBUG
}
......
......@@ -29,6 +29,7 @@ class Paradigm(object):
else:
self.window = visual.Window(size=window_size, color=color, allowGUI=True, units='pix', *args, **kwargs)
class fixation_cross(object):
'''
fixation cross for this task
......@@ -58,6 +59,7 @@ class fixation_cross(object):
core.wait(self.duration)
return start_trial
class Text(object):
'''
show text in the middle of the screen
......@@ -96,6 +98,7 @@ class Text(object):
return start_trial, KeyResp, Resp, KeyPressTime, respRT, correct
class responsescreen(object):
'''
the screen for the memory task
......@@ -139,7 +142,7 @@ class responsescreen(object):
if 'NoGo'in trial['TrialType']:
self.line.fillColor = 'black'
self.dash.fillColor = 'black'
elif 'Recog' in trial['TrialType']:
self.line.fillColor = self.version['rec_color']
self.dash.fillColor = self.version['rec_color']
......@@ -156,10 +159,10 @@ class responsescreen(object):
else:
self.line.fillColor = self.version['loc_color']
self.dash.fillColor = self.version['loc_color']
self.keylist = self.version['loc_keys']
self.keyans = self.version['loc_keyans']
if '?' == trial['stimPicLeft']:
self.present_left = self.quest_left
self.present_right = self.quest_right
......@@ -223,6 +226,7 @@ class responsescreen(object):
return start_trial, KeyResp, Resp, KeyPressTime, respRT, correct
class Question(object):
'''
collect mind wandering report
......@@ -263,7 +267,7 @@ class Question(object):
def show(self, clock):
keyState=key.KeyStateHandler()
self.window.winHandle.push_handlers(keyState)
self.description.draw()
self.scale_l.draw()
self.scale_h.draw()
......@@ -322,11 +326,13 @@ def get_keyboard(timer, respkeylist, keyans):
Resp = keyans[respkeylist.index(KeyResp)]
return KeyResp, Resp, KeyPressTime
def quitEXP(endExpNow):
if endExpNow:
print 'user cancel'
core.quit()
class instructions(object):
'''
show instruction and wait for trigger
......@@ -362,10 +368,10 @@ class instructions(object):
# '{KEY_LOC_0}', self.settings['loc_keys'][0].upper())
# self.instruction_txt[2] = self.instruction_txt[2].replace(
# '{KEY_LOC_1}', self.settings['loc_keys'][1].upper())
self.instruction_txt[1] = self.instruction_txt[1].replace(
'{0_back_color}', self.settings['0_back_color'].upper())
self.instruction_txt[1] = self.instruction_txt[1].replace(
'{1_back_color}', self.settings['1_back_color'].upper())
return self.instruction_txt
......@@ -384,19 +390,22 @@ class instructions(object):
else:
event.waitKeys(keyList=['return'])
def waitTrigger(self):
# wait for trigger; or just wait
def waitTrigger(self, trigger_code):
# wait for trigger in mri environment
self.display.setText(self.ready_txt)
self.display.draw()
self.window.flip()
if self.env == 'lab':
core.wait(uniform(1.3,1.75))
core.wait(0)
elif self.env == 'mri':
event.waitKeys(keyList=['5'])
event.waitKeys(keyList=[trigger_code])
elif self.env == 'dev':
event.waitKeys(keyList=[trigger_code])
else: # not supported
raise Exception('Unknown environment setting')
def subject_info(experiment_info):
'''
get subject information
......@@ -422,6 +431,7 @@ def subject_info(experiment_info):
core.quit()
print 'User cancelled'
def event_logger(logging_level, LogFile):
'''
log events
......@@ -432,6 +442,7 @@ def event_logger(logging_level, LogFile):
logging.console.setLevel(logging.WARNING)
logging.LogFile(LogFile, level=logging_level)
def get_stim_screen(trial, switch_screen, stimulus_screen):
'''
trial: dict
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment