Commit a8091097 authored by Hao Ting Wang's avatar Hao Ting Wang

add notes on places that needs work

parent 2e63ddce
......@@ -3,7 +3,7 @@ This is an example of how to generate a trial list
all the modules have documentation to some extend
find them by typing ?modulename to the console
set working directory to the task folder before runing this example
set working directory to the task folder before running this example
H.T. Wang
......@@ -19,21 +19,31 @@ from src.datastructure import trialtype
shape = ['square', 'triangle', 'circle']
# locate path of experiment specification related files
condition_path = './parameters/ConditionsSpecifications.csv'
# ConditionsSpecifications.csv:
# original design
# ConditionsSpecifications_ES.csv:
# 0 back condition,
# the experience sampling part has not been implemented yet
#condition_path = './parameters/ConditionsSpecifications.csv'
condition_path = './parameters/ConditionsSpecifications_ES.csv'
trialheader_path = './parameters/TrialHeaders.csv'
trialspec_path = './parameters/TrialSpecifications.csv'
stimulus_dir = './stimuli/'
# column name of trial type names in TrialSpecifications.csv
trialspec_col = 'trial_type'
block = '0'
block = None # accept values: '0', '1', None
# now define the generators
# create experiment parameters
# a 1.5 min block can have 6 catch trials max
parameters = experiment_parameters(block_length=4.5, block_go_n=18, runs=1)
# runs - minimum 1;
parameters = experiment_parameters(block_length=4.5, block_go_n=18, runs=2)
# create trial finder
find_trial = trial_finder(trialspec_path=trialspec_path, trialspec_col=trialspec_col)
......@@ -69,4 +79,9 @@ for trial in trials:
# the stimulus is saved as a tuple in the dictionar, use tup2str function in module stimulus
# uncomment the following lines to compare theout put
write_csv(fileName='../example.csv', list_headers=parameters.headers, thisTrial=trial)
write_csv(fileName='example_run1.csv', list_headers=parameters.headers, thisTrial=trial)
# to get run two:
trials = next(trial_generator)
for trial in trials:
write_csv(fileName='example_run2.csv', list_headers=parameters.headers, thisTrial=trial)
......@@ -164,7 +164,7 @@ class trial_builder(object):
block: None, '0', '1'
no sequence assigned, starting from 1 back, starting from 0 back
condition, shuffled: lst
conditions, shuffled: lst
if block == '1':
# use Ordereddict form python in-built library `collections`
......@@ -174,7 +174,8 @@ class trial_builder(object):
conditions = sorted(conditions,
reverse=True, key=lambda t: t['Condition'])
pass # low priority to-do: shuffle the conditions
return conditions
def block_trials(self, trial_finder, block, trial_headers):
......@@ -196,10 +197,10 @@ class trial_builder(object):
trial_NoGo = trial_finder.get(trial_type='NoGo')
trial_NoGo.lst_header = trial_headers
trial_Go1 = trial_finder.get(trial_type=block['GoTrial_1'])
trial_Go1 = trial_finder.get(trial_type=block['GoTrial1'])
trial_Go1.lst_header = trial_headers
trial_Go2 = trial_finder.get(trial_type=block['GoTrial_2'])
trial_Go2 = trial_finder.get(trial_type=block['GoTrial2'])
trial_Go2.lst_header = trial_headers
trial_Go = [trial_Go1, trial_Go2]
......@@ -241,6 +242,8 @@ class trial_builder(object):
def build(self, experiment_parameters, trial_finder, stimulus_generator, block):
This feature doesn't integrate experience sampling for now
now let's build the trial generator
experiment_parameters: obj
......@@ -287,12 +290,14 @@ class trial_builder(object):
self.task_t -= t
self.save_trial(cur_trial, block['Condition'])
# generate the go trial
# go trial: type 1 or type 2
# see which go trial type were all used
# need to integrate experience sampling here
  • integrate experience sampling here. I know this module is a mess. Let's try to figure it out.

Please register or sign in to reply
use_go = [i for i, e in enumerate(self.go_n) if e > 0]
if use_go:
# select a random one from the avalible ones
# select a random one from the available ones
idx = choice(use_go)
cur_trial, t = next(trial_Go[idx].generate_trial(
......@@ -7,10 +7,35 @@ stimulus feature generator
from random import shuffle, randint
from itertools import product
class stimulus_ExpSample(object):
experience sampling stimulus generator
save features and generate stimuli
feature: list, dictionaries of questions
def __init__(self, feature):
self.stimuli = feature
# here shuffle the questions but hold the first question in place
def generate(self):
Please register or sign in to reply
yield self.stimuli
yield self.stimuli
class stimulus_twofeat(object):
double feature stimulus generator
save features and genenrate stimuli pair
feature1, feature2 : list, features of stimulus
......@@ -36,7 +61,7 @@ class stimulus_twofeat_mix(object):
double feature stimulus generator with mixed congurency
The stimulis pair can share one feature or no feature.
save features and genenrate stimuli pair
feature1, feature2 : list, features of stimulus
......@@ -82,15 +107,15 @@ class stimulus_onefeat(object):
def tup2str(dir_path, tuple_stim, filesuffix):
trun tuple to a string (filename)
the filename must look like:
the filename must look like:
dir_path: str
example: './stimulus/'
tuple_stim: tuple
stimulus, ('feature1', 'feature2')
filesuffix: str
expample '.png'
......@@ -12,6 +12,60 @@ from random import choice, shuffle, uniform
from ..fileIO import create_headers
class ExpSample(object):
Please register or sign in to reply
generate a experience sampling trial detail
trial_spec: dict
trial specification
lst_header: list
headers for generating dictionary to store trial details
def __init__(self, trial_spec, lst_header):
self.trial_spec = trial_spec
self.lst_header = lst_header
def generate_trial(self, stimulus_generator, last_trial):
a generater that creates trials
stimulus_generator: generator
stimulus generator
last_trial: dict
the previous trial; some trials need this information
if it's a experience sampling question,
zero-back or no-go trial, None type is accepted
dict_row: dict
a trail in dictionary
self.trial_spec['trial_t_total']: float
total time of this trial, for counter
dict_row = {key: None for key in self.lst_header}
item_list = next(stimulus_generator.generate())
dict_row['TrialIndex'] = None
dict_row['Condition'] = None
dict_row['TrialType'] = self.trial_spec['trial_type']
dict_row['fix_duration'] = uniform(self.trial_spec['fix_t_min'],self.trial_spec['fix_t_max'])
dict_row['stim_duration'] =self.trial_spec['trial_t_total'] - dict_row['fix_duration']
dict_row['stimPicLeft'] = None
dict_row['stimPicRight'] = None
dict_row['Ans'] = None
dict_row['stimPicMid'] = item_list
yield dict_row,self.trial_spec['trial_t_total']
class NoGo(object):
generate a one back trial detail
My thought was on task:,Focus,Not at all,Completely
My thoughts involved future events:,Future,Not at all,Completely
My thoughts involved past events:,Past,Not at all,Completely
My thoughts involved myself:,Self,Not at all,Completely
My thoughts involved other people:,Other,Not at all,Completely
The emotion of my thoughts was:,Emotion,Negative,Positive
My thoughts were in the form of:,Modality,Images,Words
My thoughts were detailed and specific:,Detailed,Not at all,Completely
My thoughts were:,Deliberate,Spontaneous,Deliberate
I was thinking about solutions to problems (or goals):,Problem,Not at all,Completely
My thoughts were:,Diversity,One topic,Many topics
My thoughts were intrusive:,Intrusive,Not at all,Completely
My thoughts were linked to information from:,Source,Environment,Memory
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment