Commit 912f613f authored by Hao Ting Wang's avatar Hao Ting Wang

visual display

Committer: Hao Ting Wang <hw1012@nirem008.ynic.york.ac.uk>

On branch nback_refactor
Your branch is up-to-date with 'origin/nback_refactor'.

Changes to be committed:
	deleted:    instructions/exp_instr.txt.save
	new file:   instructions/exp_instr_es.txt
	renamed:    instructions/exp_instr.txt -> instructions/exp_instr_nback.txt
	modified:   run.py
	modified:   settings.py
	modified:   src/experiment.py
parent efcc0296
Pipeline #594 canceled with stages
......@@ -4,20 +4,31 @@ Welcome to our experiment.
In it you will be asked to attend to pairs of different shapes divided by a vertical line in the middle of the screen.
You will only be required to keep your eyes in the centre of the screen and attend to the shapes most of the time.
When a reaction is required, the verticle line will change colour.We refer this as an event.
When a reaction is required, the vertical line will change colour.
The condition will switch between blocks. The two types of conditions are 0-back and 1-back. If the line is {0_back_color}, the trial is a 0-back block. If the line is {1_back_color}, the trial is a 1-back block.
The condition will switch between blocks. The two types of conditions are 0-back and 1-back.
When an event occurs in a 0-back block, the screen displays a pair of shapes and a smaller target item in the middle.
You answer according to the CURRENT screen.
When an event occurs in a 1-back block, the screen displays a pair of "?" and a smaller target item in the middle.
You answer according to the PREVIOUS screen.
There are two type of events, a location event and a recognition event.
If the line is {COLOR_REC}, the trial is a Recognition event - please indicate weather the target is/was presented;
If the line is {COLOR_LOC}, the trial is a Location event - please indicate the location of the target.
You are using key "1" and "2" to indicate LEFT or RIGHT.
You should try to be as quick and accurate as possible.
Press "1" to continue reading.
#
We are interested in the thoughts that you experienced during the rest period.
A list of descriptions and a rating scale will be presented on the screen.
Please use the four buttons to indicate how much each description reflects your experience.
Press "1" to move the tick mark towards 1, indicates "not at all".
Press "2" to move the tick mark towards 10, indicates "completely".
Press "4" to confirm the rating.
When the fixation cross is {COLOR_REC}, the {KEY_REC_0} button indicates {RESP_REC_0}, the {KEY_REC_1} button indicates {RESP_REC_1}.
When the fixation cross is {COLOR_LOC}, When the fixation cross is {COLOR_REC}, the {KEY_REC_0} button indicates {RESP_REC_0}, the {KEY_REC_1} button indicates {RESP_REC_1}.hould try to be as quick and accurate as possible.
Please note that there are no right or wrong answers.
Answer the questions as fast as possible.
Press RETURN to start the task.
Press "1" to start the task.
......@@ -74,7 +74,7 @@ if __name__ == "__main__":
# create display screens
fixation = fixation_cross(window=Experiment.window, color='black')
stimulus = responsescreen(window=Experiment.window, version=settings)
question = Question(window=Experiment.window, questions=questions, color='white')
question = Question(window=Experiment.window, questions=None, color='white')
switch = Text(window=Experiment.window, text='Switch', color='black')
endtxt = open('./instructions/end_instr.txt', 'r').read().split('#\n')[0]
end_msg = visual.TextStim(Experiment.window, text=endtxt, color='black',
......@@ -101,15 +101,15 @@ if __name__ == "__main__":
trial = parse_stimulus_name(trial)
# prepare fixation cross and stimulus display
fixation.set_trial(trial)
stim = get_stim_screen(trial, switch, stimulus)
# show fixation
fix_t = fixation.show(timer)
print(trial['TrialType'])
if trial['TrialType'] == 'ExpSample':
question.set(trial)
start_stim, Resp, rt = question.show(timer)
else:
# show stimulus screen and catch response
stim = get_stim_screen(trial, switch, stimulus)
stim_t, KeyResp, Resp, KeyPressTime, respRT, correct = stim.show(timer)
# post response fixation
......
......@@ -16,27 +16,27 @@ condition_path = './parameters/ConditionsSpecifications_ES.csv'
trialheader_path = './parameters/TrialHeaders.csv'
trialspec_path = './parameters/TrialSpecifications.csv'
stimulus_dir = './stimuli/'
exp_questions_path = './stimuli/ES_questions.csv'
# column name of trial type names in TrialSpecifications.csv
trialspec_col = 'trial_type'
# task instruction
instr_txt = './instructions/exp_instr.txt'
instr_txt = './instructions/exp_instr_es.txt'
# wait trigger screen
ready_txt = './instructions/wait_trigger.txt'
# MRI related settings
dummy_vol = 3
dummy_vol = 0
tr = 2
slice_per_vol = 60
from psychopy import logging
from src.fileIO import write_csv, create_headers
from src.datastructure.stimulus import stimulus_onefeat
from src.fileIO import write_csv, create_headers, load_conditions_dict
from src.datastructure.stimulus import stimulus_onefeat, stimulus_ExpSample
from src.datastructure.datastructure import *
from src.datastructure import trialtype
from src.datastructure import trial_library
# Base settings that apply to all environments.
# These settings can be overwritten by any of the
......@@ -128,15 +128,15 @@ VER_B_MRI = {
EXP_SAMPLING_A = {
'0_back_color': 'blue',
'1_back_color': 'red',
'keys': ['1', '2'],
'keyans': ['left', 'right']
'loc_keys': ['1', '2'],
'loc_keyans': ['left', 'right']
}
EXP_SAMPLING_B = {
'0_back_color': 'red',
'1_back_color': 'blue',
'keys': ['1', '2'],
'keyans': ['left', 'right']
'loc_keys': ['1', '2'],
'loc_keyans': ['left', 'right']
}
def get_trial_generator(block):
......@@ -149,17 +149,20 @@ def get_trial_generator(block):
block_length=BLOCK_TIME, block_go_n=BLOCK_GO_N, runs=1)
parameters.load_conditions(condition_path)
parameters.load_header(trialheader_path)
questions, _ = load_conditions_dict('./stimuli/ES_questions.csv')
# create trial finder
find_trial = trial_finder(trialspec_path=trialspec_path, trialspec_col=trialspec_col)
# create stimulus generators
# stimulus_generator = stimulus_twofeat(feature1=shape, feature2=texture)
stimulus_generator = stimulus_onefeat(feature=shape)
stimulus_generator = stimulus_onefeat(features=shape)
exp_sample_generator = stimulus_ExpSample(questions)
# now build the trials
builder = trial_builder()
# build the trial generator
trial_generator = builder.build(parameters, find_trial, stimulus_generator, block)
trial_generator = builder.build(parameters, find_trial, stimulus_generator, exp_sample_generator, block)
return trial_generator, parameters.headers
......
......@@ -4,6 +4,9 @@
experiemnt stimulus here
'''
from psychopy import core, data, gui, visual, event, logging
from pyglet.window import key
import os
from src.fileIO import *
from random import uniform, shuffle
......@@ -136,6 +139,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']
......@@ -143,11 +147,19 @@ class responsescreen(object):
self.keyans = self.version['rec_keyans']
elif 'Back' in trial['TrialType']:
self.line.fillColor = self.version['loc_color']
self.dash.fillColor = self.version['loc_color']
if 'Zero' in trial['TrialType']:
self.line.fillColor = self.version['0_back_color']
self.dash.fillColor = self.version['0_back_color']
elif 'One' in trial['TrialType']:
self.line.fillColor = self.version['1_back_color']
self.dash.fillColor = self.version['1_back_color']
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
......@@ -228,26 +240,33 @@ class Question(object):
self.window = window
self.description = visual.TextStim(self.window, text=None, height=34,
wrapWidth=1100, color=color, font=sans)
self.scale_h = visual.TextStim(self.window, text=None, height=34,
wrapWidth=1100, pos=[50,-50],color=color, font=sans)
self.scale_l = visual.TextStim(self.window, text=None, height=34,
wrapWidth=1100, pos=[-50,-50],color=color, font=sans)
wrapWidth=1100, pos=[-300,-150],color=color, font=sans)
self.scale_h = visual.TextStim(self.window, text=None, height=34,
wrapWidth=1100, pos=[300,-150],color=color, font=sans)
self.questions = questions
self.rating = visual.RatingScale(self.window, low=1, high=10, markerStart=5,
precision=10, tickMarks=[1, 10],
leftKeys='1', rightKeys='2', acceptKeys='4')
def set(self, trial):
self.description.setText(trial['Item'])
self.scale_h.setText(trial['Scale_low'])
self.scale_l.setText(trial['Scale_high'])
self.description.setText(trial['stimPicMid'])
self.scale_l.setText(trial['stimPicLeft'])
self.scale_h.setText(trial['stimPicRight'])
if trial['stim_duration']:
self.scale_max_time = trial['stim_duration']
else:
self.scale_max_time = 90
def show(self, clock):
keyState=key.KeyStateHandler()
self.window.winHandle.push_handlers(keyState)
self.description.draw()
self.scale_h.draw()
self.scale_l.draw()
self.scale_h.draw()
self.rating.draw()
self.window.flip()
start_trial = clock.getTime()
......@@ -255,7 +274,8 @@ class Question(object):
pos = self.rating.markerStart
inc = 0.1
while self.rating.noResponse:
while (self.rating.noResponse
and clock.getTime() - start_trial < self.scale_max_time):
if event.getKeys(keyList=['escape']):
print('user quit')
core.quit()
......@@ -272,6 +292,8 @@ class Question(object):
self.rating.setMarkerPos(pos)
self.description.draw()
self.scale_l.draw()
self.scale_h.draw()
self.rating.draw()
self.window.flip()
......@@ -328,19 +350,24 @@ class instructions(object):
I hard coded the part with text needs changing.
Will need to change this in the future
'''
self.instruction_txt[2] = self.instruction_txt[2].replace(
'{COLOR_REC}', self.settings['rec_color'].upper())
self.instruction_txt[2] = self.instruction_txt[2].replace(
'{COLOR_LOC}', self.settings['loc_color'].upper())
self.instruction_txt[2] = self.instruction_txt[2].replace(
'{KEY_REC_0}', self.settings['rec_keys'][0].upper())
self.instruction_txt[2] = self.instruction_txt[2].replace(
'{KEY_REC_1}', self.settings['rec_keys'][1].upper())
self.instruction_txt[2] = self.instruction_txt[2].replace(
'{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[2] = self.instruction_txt[2].replace(
# '{COLOR_REC}', self.settings['rec_color'].upper())
# self.instruction_txt[2] = self.instruction_txt[2].replace(
# '{COLOR_LOC}', self.settings['loc_color'].upper())
# self.instruction_txt[2] = self.instruction_txt[2].replace(
# '{KEY_REC_0}', self.settings['rec_keys'][0].upper())
# self.instruction_txt[2] = self.instruction_txt[2].replace(
# '{KEY_REC_1}', self.settings['rec_keys'][1].upper())
# self.instruction_txt[2] = self.instruction_txt[2].replace(
# '{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
def show(self):
......
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