Skip to content

Commit

Permalink
Merge pull request psychopy#1444 from peircej/master
Browse files Browse the repository at this point in the history
RF: mostly fixes for Py3 compatibility and new dependency auto-install
  • Loading branch information
peircej committed Jun 22, 2017
2 parents 661e3f9 + 4a97a04 commit 648d4d8
Show file tree
Hide file tree
Showing 24 changed files with 557 additions and 646 deletions.
4 changes: 1 addition & 3 deletions buildCompleteInstaller.nsi
Expand Up @@ -65,9 +65,7 @@ Function .onInit
IfSilent +3
MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
"A version of PsychoPy2 is already installed. $\n$\nClick `OK` to remove the \
previous version or `Cancel` to cancel this upgrade. \
\
WAIT UNTIL UNINSTALL COMPLETES BEFORE CONTINUING" \
previous version or `Cancel` to cancel this upgrade." \
IDOK uninst
Abort

Expand Down
16 changes: 8 additions & 8 deletions psychopy/CHANGELOG.txt
Expand Up @@ -49,7 +49,7 @@ PsychoPy 1.85.1
* textbox v textstim demo wasn't working #b2913c12476
* error with colors when using TextStim with blendmode='add'
* errors in installer package:

* windows installer could overwrite system path setting rather than append (NSIS short-string problem came back!)
* freetype 32 bit dll is being provided again (was in matplotlib before but disappeared?)

Expand Down Expand Up @@ -146,15 +146,15 @@ Released Aug 2016

* OLD form --> NEW form
* Deprecated since 2012, must now update:
* `from psychopy import calib` --> `from psychopy import monitors as calib` (or just use `monitors`)
* `from psychopy import bits` --> `from psychopy.hardware.crs import bits`
* `from psychopy import log` --> `from psychopy import logging`
* `from psychopy import calib` --> `from psychopy import monitors as calib` (or just use `monitors`)
* `from psychopy import bits` --> `from psychopy.hardware.crs import bits`
* `from psychopy import log` --> `from psychopy import logging`
* Newly deprecated (the old way still works but logs a warning):
* `from psychopy import _shadersPyglet` --> `from psychopy.visual import shaders`
* `from psychopy import gamma` --> `from psychopy.visual import gamma`
* `from psychopy import filters` --> `from psychopy.visual import filters`
* `from psychopy import _shadersPyglet` --> `from psychopy.visual import shaders`
* `from psychopy import gamma` --> `from psychopy.visual import gamma`
* `from psychopy import filters` --> `from psychopy.visual import filters`
* API change (only affects people who write their own Builder components):
* `from psychopy.app.builder.components._visual import VisualComponent` --> `from psychopy.app.builder.components._base import BaseVisualComponent`
* `from psychopy.app.builder.components._visual import VisualComponent` --> `from psychopy.app.builder.components._base import BaseVisualComponent`

* PyQt is now default over wx for dialog boxes (if either PyQt4 or PyQt5 are installed). Also fixed bug to support PyQt5
* No Static Components are created by default (e.g. ISI). Have to add them manually
Expand Down
2 changes: 1 addition & 1 deletion psychopy/README.txt
Expand Up @@ -2,7 +2,7 @@ Thanks for downloading PsychoPy!

MORE INFO:
See the documentation at
http://www.psychopy.org
http://www.psychopy.org
and run the included demos.

FEEDBACK:
Expand Down
83 changes: 42 additions & 41 deletions psychopy/demos/coder/iohub/analoginput/run.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
Displays values from 8 channels ( 0 - 7 ) from the AnalogInput Device as
Displays values from 8 channels ( 0 - 7 ) from the AnalogInput Device as
configured in the iohub.config.yaml file in this directory.
@author: Sol
Expand All @@ -9,28 +9,29 @@
from __future__ import print_function #for compatibility with python3
from builtins import range
from psychopy import visual
from psychopy.iohub import OrderedDict,ioHubExperimentRuntime,EventConstants,module_directory
from collections import OrderedDict
from psychopy.iohub import ioHubExperimentRuntime, EventConstants, module_directory

class ExperimentRuntime(ioHubExperimentRuntime):
"""
Create an experiment using psychopy and the ioHub framework by extending
Create an experiment using psychopy and the ioHub framework by extending
the ioHubExperimentRuntime class. At minimum all that is needed is to override
the run() method with the main experiment script logic.
By the time run() is called, the experiment_config.yaml and iohub_config.yaml
files have been read and used to initialize the ioHub Server. The ioHubConnection
instance that has been created to interact the ioHub Process can be accessed using
`self.hub`.
To change the analog input device being used, or any configuration parameters
for that device hardware, edit the iohub_config.yaml. The demo is currently
set to use the LabJack U6 USB DAQ.
for that device hardware, edit the iohub_config.yaml. The demo is currently
set to use the LabJack U6 USB DAQ.
"""
def run(self,*args):
"""
The run method contains your experiment logic.
The run method contains your experiment logic.
It is equal to what would be in your main psychopy experiment
script .py file in a standard psychopy experiment setup.
script .py file in a standard psychopy experiment setup.
"""
display=self.devices.display
kb=self.devices.kb
Expand All @@ -40,20 +41,20 @@ def run(self,*args):
psychopy_monitor=display.getPsychopyMonitorName()
unit_type=display.getCoordinateType()
screen_index=display.getIndex()

# Create a psychopy window, full screen resolution, full screen mode.
window=visual.Window(display_resolution, monitor=psychopy_monitor,
window=visual.Window(display_resolution, monitor=psychopy_monitor,
units=unit_type, color=[128,128,128], colorSpace='rgb255',
fullscr=True, allowGUI=False, screen=screen_index)
fullscr=True, allowGUI=False, screen=screen_index)

# Get the number of trials selected in the session dialog.
#
user_params=self.getUserDefinedParameters()
print('user_params: ', user_params)
trial_count=int(user_params.get('trial_count',5))

# Create an ordered dictionary of psychopy stimuli.

# Create an ordered dictionary of psychopy stimuli.
# An ordered dictionary is one that returns keys in the order
# they are added, so you can use it to reference stim by a name
# or by 'zorder'.
Expand All @@ -62,25 +63,25 @@ def run(self,*args):
psychoStim['grating'] = visual.PatchStim(window, mask="circle",
size=150,pos=[0,0], sf=.075)

psychoStim['title'] = visual.TextStim(window,
psychoStim['title'] = visual.TextStim(window,
text="Analog Input Test. Trial 1 of %d"%(trial_count),
pos = [0,200], height=36, color=[1,.5,0],
pos = [0,200], height=36, color=[1,.5,0],
colorSpace='rgb',
alignHoriz='center',alignVert='center',
wrapWidth=800.0)

ai_values_string_proto="AI_0: %.3f\tAI_1: %.3f\tAI_2: %.3f\tAI_3: %.3f\t\nAI_4: %.3f\tAI_5: %.3f\tAI_6: %.3f\tAI_7: %.3f"
ai_values=(0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0)
psychoStim['analog_input_values'] = visual.TextStim(window,
psychoStim['analog_input_values'] = visual.TextStim(window,
text=ai_values_string_proto%ai_values,
pos = [0,-200], height=24, color=[1,1,0],
pos = [0,-200], height=24, color=[1,1,0],
colorSpace='rgb',
alignHoriz='center',alignVert='center',
wrapWidth=800.0)

psychoStim['instruction'] = visual.TextStim(window,
psychoStim['instruction'] = visual.TextStim(window,
text="Press SPACE Key for Next Trial",
pos = [0,-300], height=36, color=[1,1,0.5],
pos = [0,-300], height=36, color=[1,1,0.5],
colorSpace='rgb',
alignHoriz='center',alignVert='center',
wrapWidth=800.0)
Expand All @@ -89,25 +90,25 @@ def run(self,*args):
self.hub.clearEvents('all')

# Run a number of analog input recording /trials/
#
for i in range(trial_count):
#
for i in range(trial_count):
# Clear all events from the global and device level event buffers.
psychoStim['title'].setText("Analog Input Test. Trial %d of %d"%(i+1,trial_count))
self.hub.clearEvents('all')

# Start streaming AnalogInput data.
#
ain.enableEventReporting(True)
# Loop until we get a keyboard event where the

# Loop until we get a keyboard event where the
# SPACE key was pressed.
#
#
while 1:

# For each retrace, update the grating phase
#
psychoStim['grating'].setPhase(0.05, '+')

# Update analog input values to display
#
analog_input_events=ain.getEvents()
Expand All @@ -117,43 +118,43 @@ def run(self,*args):
ai_values=(event.AI_0,event.AI_1,event.AI_2,event.AI_3,
event.AI_4,event.AI_5,event.AI_6,event.AI_7)
psychoStim['analog_input_values'].setText(ai_values_string_proto%ai_values)

# redraw the stim
[psychoStim[stimName].draw() for stimName in psychoStim]

# Flip, storing the time of the start of display update retrace.
#
flip_time=window.flip()


# Send a message to the ioHub Process with indicating
# that a flip occurred and at what time.
#
self.hub.sendMessageEvent("Flip", sec_time=flip_time)

# Get any new key values from keyboard *Char* Events.
#
key_values=[k.key for k in kb.getEvents(EventConstants.KEYBOARD_RELEASE)]

if u' ' in key_values:
break

# Clear the screen
#
window.flip()

# Stop analog input recording
#
ain.enableEventReporting(False)

# Delay 1/4 second before next trial
#
actualDelay=self.hub.wait(0.250)

# All trials have been run. End demo....
# Wait 250 msec before ending the experiment
actualDelay=self.hub.wait(0.250)

print("Delay requested %.6f, actual delay %.6f, Diff: %.6f"%(0.250,actualDelay,actualDelay-0.250))

### End of experiment logic
Expand All @@ -165,10 +166,10 @@ def run(self,*args):

def main(configurationDirectory):
"""
Creates an instance of the ExperimentRuntime class,
Creates an instance of the ExperimentRuntime class,
and launches the experiment logic in run().
"""
runtime=ExperimentRuntime(configurationDirectory, "experiment_config.yaml")
runtime=ExperimentRuntime(configurationDirectory, "experiment_config.yaml")
runtime.start(sys.argv)

# run the main function, which starts the experiment runtime
Expand Down
50 changes: 25 additions & 25 deletions psychopy/demos/coder/iohub/ioHubDelayTest/run.py
Expand Up @@ -16,8 +16,8 @@
from numpy import zeros

from psychopy import core, visual
from psychopy.iohub import Computer, ioHubExperimentRuntime,EventConstants,OrderedDict

from psychopy.iohub import Computer, ioHubExperimentRuntime, EventConstants
from collections import OrderedDict


class ExperimentRuntime(ioHubExperimentRuntime):
Expand All @@ -26,18 +26,18 @@ def run(self,*args,**kwargs):
Tests the round trip delay from when the experiment runtime requests
new events from the ioHub server to when a response with >=1 new
event is received and ready for use within the experiment script.
Only getEvent requests that return with atleast one new event are used in
the calculated statistics to try and ensure the reported delay is measuring
the higher processing load case of new events being returned, vs. the
case of no new events being available.
the higher processing load case of new events being returned, vs. the
case of no new events being available.
At the end of the test, a MatPlotLib figure is displayed showing a
histogram of the round trip event request delays as well as two figures
representing the retrace onset detection stability of PsychoPy when the
representing the retrace onset detection stability of PsychoPy when the
ioHub is being used.
PsychoPy code is taken from an example psychopy script in the coder
PsychoPy code is taken from an example psychopy script in the coder
documentation.
"""
self.psychoStim = OrderedDict()
Expand Down Expand Up @@ -92,51 +92,51 @@ def run(self,*args,**kwargs):

def createPsychoGraphicsWindow(self):
#create a window
self.psychoWindow = visual.Window(self.display.getPixelResolution(),
monitor=self.display.getPsychopyMonitorName(),
self.psychoWindow = visual.Window(self.display.getPixelResolution(),
monitor=self.display.getPsychopyMonitorName(),
units=self.display.getCoordinateType(),
color=[128,128,128], colorSpace='rgb255',
fullscr=True, allowGUI=False,
screen=self.display.getIndex()
)
)

currentPosition=self.mouse.setPosition((0,0))
self.mouse.setSystemCursorVisibility(False)

fixation = visual.PatchStim(self.psychoWindow, size=25, pos=[0,0], sf=0,
color=[-1,-1,-1], colorSpace='rgb')
title = visual.TextStim(win=self.psychoWindow,
title = visual.TextStim(win=self.psychoWindow,
text="ioHub getEvents Delay Test", pos = [0,125],
height=36, color=[1,.5,0], colorSpace='rgb',
alignHoriz='center', wrapWidth=800.0)
instr = visual.TextStim(win=self.psychoWindow,

instr = visual.TextStim(win=self.psychoWindow,
text='Move the mouse around, press keyboard keys and mouse buttons',
pos = [0,-125], height=32, color=[-1,-1,-1],
pos = [0,-125], height=32, color=[-1,-1,-1],
colorSpace='rgb',alignHoriz='center',wrapWidth=800.0)

self.psychoStim['static'] = visual.BufferImageStim(win=self.psychoWindow,
stim=(fixation, title, instr))
self.psychoStim['grating'] = visual.PatchStim(self.psychoWindow,
mask="circle", size=75,pos=[-100,0],
self.psychoStim['grating'] = visual.PatchStim(self.psychoWindow,
mask="circle", size=75,pos=[-100,0],
sf=.075)
self.psychoStim['keytext'] = visual.TextStim(win=self.psychoWindow,
text='key', pos = [0,300], height=48,
self.psychoStim['keytext'] = visual.TextStim(win=self.psychoWindow,
text='key', pos = [0,300], height=48,
color=[-1,-1,-1], colorSpace='rgb',
alignHoriz='left',wrapWidth=800.0)
self.psychoStim['mouseDot'] = visual.GratingStim(win=self.psychoWindow,
tex=None, mask="gauss",
tex=None, mask="gauss",
pos=currentPosition,size=(50,50),
color='purple')
self.psychoStim['progress'] = visual.ShapeStim(win=self.psychoWindow,
vertices=[(0,0),(0,0),(0,0),(0,0)],
self.psychoStim['progress'] = visual.ShapeStim(win=self.psychoWindow,
vertices=[(0,0),(0,0),(0,0),(0,0)],
pos=(400, -300))

def drawAndFlipPsychoWindow(self):
self.psychoStim['grating'].setPhase(0.05, '+')#advance phase by 0.05 of a cycle
currentPosition,currentDisplayIndex=self.mouse.getPosition(return_display_index=True)
if currentDisplayIndex == self.display.getIndex():

if currentDisplayIndex == self.display.getIndex():
currentPosition=(float(currentPosition[0]),float(currentPosition[1]))
self.psychoStim['mouseDot'].setPos(currentPosition)

Expand Down

0 comments on commit 648d4d8

Please sign in to comment.