Skip to content

Commit

Permalink
Fixed Color/Added Comments
Browse files Browse the repository at this point in the history
Wordbox color reverts back to window color
  • Loading branch information
mdrasche committed Jan 21, 2015
1 parent 43819c4 commit ece79e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
4 changes: 4 additions & 0 deletions example/trials/spatial_span.csv
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
1,1,1,learn
2,2,2,learn
3,,,recall
4,0,5,learn
5,1,8,learn
6,2,7,learn
7,,,recall
8 changes: 5 additions & 3 deletions memtask/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ def setFillColor(self, stimList = None, color = "black"):
for stim in range(len(stimList)):
if type(color) == str: stimList[stim].Rect.setFillColor(color)
else: stimList[stim].Rect.setFillColor(color[stim], 'rgb')
else: stimList.Rect.setFillColor(color)
else:
if type(color) == str: stimList.Rect.setFillColor(color)
else: stimList.Rect.setFillColor(color, 'rgb')

class RecButtons(Buttons):
def method(self, stim, stimNum):
def method(self, stim, stimNum, win):
if stim.Text.text == "Clear":
for entry in self.stimList[:-3]:
entry.Rect.setFillColor("gray")
entry.Rect.setFillColor(win.color, 'rgb')
entry.Text.text = "0"
entry.Text.setAutoDraw(False)
self.respNum = 1
Expand Down
30 changes: 15 additions & 15 deletions memtask/proc_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,37 @@ def __call__(self, item, dur=2, color_change = "red", **kwargs):
self.draw(drawText = False)
win.flip()
core.wait(dur)
self.setFillColor(self.stimList[item], color="gray")
self.setFillColor(self.stimList[item], color=win.color)
def update(self, item, gridRecall):
"""With each call track the squares that have been called in the current trial"""
pass

class gridRecall(RecButtons):
def __call__(self, item, dur=2, **kwargs):
self.setAutoDraw(drawText=False)
for stim in self.stimList[-3:]:
self.setAutoDraw(drawText=False) #Display all squares w/o the text
for stim in self.stimList[-3:]: #Display text of the option squares (the final 3 in the stim list)
stim.Text.setAutoDraw(True)
Prompt.setAutoDraw(True) #Show instructions, defined outside of this object
win.flip()
myMouse.clickReset()
resps = []
respsRT = []
while not self.done:
click, time = myMouse.getPressed(getTime=True)
while not self.done: #Loop until self.done --> when'submit' is pressed
click, time = myMouse.getPressed(getTime=True) #record type of click and time since last click
if click[0] and time[0]:
x,y = myMouse.getPos()
sel = self.selButtons(x,y)
x,y = myMouse.getPos() #Get position of mouse (when its been clicked)
sel = self.selButtons(x,y)
if sel:
stim, stimLab = sel
stim, stimLab = sel #stim = a wordbox objcet; stimLab = the name of button or the position in the grid
resps.append(stimLab)
response = self.method(stim,self.respNum)
response = self.method(stim,self.respNum, win) #Respond to mouse click
respsRT.append(time[0])
self.draw(drawRect = True, drawText = None)
self.draw(drawRect = True, drawText = None) #Display updated grid
win.flip()
myMouse.clickReset()
#print response
"""for stim in self.stimList[-3:]:
stim.Text.setAutoDraw(False)"""
#Prompt.setAutoDraw(False)
Prompt.setAutoDraw(False)
self.reset()
return resps, respsRT
print resps, respsRT #TODO How to save this info



Expand All @@ -61,6 +59,8 @@ def run_task(design, proc_dict):
df = DataFrame.from_csv('example/trials/spatial_span.csv')
win = visual.Window([800,600],units="pix")
myMouse = event.Mouse(win = win)
recPrompt = "Select the blocks in order. Use the blank button to skip forgotten blocks."
Prompt = visual.TextStim(win, text = recPrompt, pos = (0, 250), color = "black")
Spos, Swdth, Shght, Stxt = genSpatialGrid(400*1.15,400,4,4) #Create grid without options buttons
P = gridPresent(win,
Spos, Swdth, Shght, Stxt,
Expand Down

0 comments on commit ece79e4

Please sign in to comment.