Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/psychopy/psychopy into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	pyproject.toml
  • Loading branch information
peircej committed May 4, 2023
2 parents 64c1c7e + d67bf66 commit 1ad3481
Show file tree
Hide file tree
Showing 16 changed files with 734 additions and 184 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:

- name: Test with pytest
run: |
pytest --ignore="psychopy/tests/test_app" --ignore="psychopy/tests/test_preferences" --ignore="psychopy/tests/test_experiment/needs_wx" -m "not needs_sound and not needs_wx and not emulator" --cov-config=.travis_coveragerc --cov=psychopy -v psychopy
pytest --ignore="psychopy/tests/test_app" --ignore="psychopy/tests/test_preferences" --ignore="psychopy/tests/test_experiment/needs_wx" -m "not needs_sound and not needs_wx and not emulator" --cov=psychopy -v psychopy
- name: upload failed app data
if: always()
Expand Down Expand Up @@ -250,7 +250,7 @@ jobs:
- name: Test with pytest
run: |
xvfb-run -a --server-args="-screen 0 1024x768x24" pytest -m "not needs_sound and not needs_wx and not needs_qt and not needs_pygame and not emulator" --cov-config=.travis_coveragerc --cov=psychopy -v psychopy
xvfb-run -a --server-args="-screen 0 1024x768x24" pytest -m "not needs_sound and not needs_wx and not needs_qt and not needs_pygame and not emulator" --cov=psychopy -v psychopy
- name: upload failed app data
if: always()
Expand Down
10 changes: 0 additions & 10 deletions .travis_coveragerc

This file was deleted.

20 changes: 20 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@

coverage:
status:
project:
default:
branches:
- dev
- release
if_ci_failed: error #success, failure, error, ignore
informational: false
only_pulls: false
patch:
default:
branches:
- release
if_ci_failed: failure #success, failure, error, ignore
informational: true
only_pulls: false


ignore:
- "psychopy/demos/coder" # ignore folders and all its contents
- "psychopy/tests"
Expand Down
15 changes: 14 additions & 1 deletion docs/source/api/sound/playback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ PTB Audio Latency Modes
~~~~~~~~~~~~~~~~~~~~~~~

When using the PTB backend you get the option to choose the Latency Mode,
referred to in PsychToolBox as the `reqlatencyclass`.
referred to in PsychToolBox as the `reqlatencyclass`, and can be set in
PsychoPy using :ref:`prefs.hardware['audioLatencyMode'] <hardwareSettings>`.

|PsychoPy| uses Mode 3 in as a default, assuming that you want low latency and you
don't care if other applications can't play sound at the same time (don't listen
Expand Down Expand Up @@ -166,6 +167,18 @@ The modes are as follows:
As Mode 3 except that, if we fail to be totally dominant, then raise an
error rather than just accepting our slightly less dominant status.

.. _PTB_devices:

PTB Devices
~~~~~~~~~~~

To set the output audio device to use, you can set the
:ref:`prefs.hardware['audioDevice'] <hardwareSettings>` setting. To determine
the set of available devices, you can do for example::

from pprint import pprint
import psychtoolbox.audio
pprint(psychtoolbox.audio.get_devices())

.. _soundClasses:

Expand Down
100 changes: 50 additions & 50 deletions docs/source/general/prefs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ In rare cases, you might want to adjust the preferences on a per-experiment basi

General settings (General)
--------------------------
window type (winType):
window type (winType) :
|PsychoPy| can use one of two 'backends' for creating windows and drawing; pygame, pyglet and glfw. Here you can set the default backend to be used.

units (units):
units (units) :
Default units for windows and visual stimuli ('deg', 'norm', 'cm', 'pix'). See :ref:`units`. Can be overridden by individual experiments.

full-screen (fullscr):
full-screen (fullscr) :
Should windows be created full screen by default? Can be overridden by individual experiments.

allow GUI (allowGUI):
allow GUI (allowGUI) :
When the window is created, should the frame of the window and the mouse pointer be visible. If set to False then both will be hidden.

paths (paths):
paths (paths) :
Paths for additional Python packages can be specified. See more :ref:`information on paths here <addModules>`.

flac audio compression (flac):
flac audio compression (flac) :
Set flac audio compression.

parallel ports (parallelPorts):
parallel ports (parallelPorts) :
This list determines the addresses available in the drop-down menu for the :doc:`/builder/components/parallelout`.

.. _applicationSettings:
Expand All @@ -36,92 +36,92 @@ Application settings (App)
---------------------------
These settings are common to all components of the application (Coder and Builder etc)

show start-up tips (showStartupTips):
show start-up tips (showStartupTips) :
Display tips when starting |PsychoPy|.

large icons (largeIcons):
large icons (largeIcons) :
Do you want large icons (on some versions of wx on macOS this has no effect)?

default view (defaultView):
default view (defaultView) :
Determines which view(s) open when the |PsychoPy| app starts up. Default is ‘last’, which fetches the same views as were open when |PsychoPy| last closed.

reset preferences (resetPrefs):
reset preferences (resetPrefs) :
Reset preferences to defaults on next restart of |PsychoPy|.

auto-save prefs (autoSavePrefs):
auto-save prefs (autoSavePrefs) :
Save any unsaved preferences before closing the window.

debug mode (debugMode):
debug mode (debugMode) :
Enable features for debugging |PsychoPy| itself, including unit-tests.

locale (locale):
locale (locale) :
Language to use in menus etc.; not all translations are available. Select a value, then restart the app. Think about :doc:`adding translations for your language</developers/localization>`.


.. _builderSettings:

Builder settings (Builder)
---------------------------
reload previous exp (reloadPrevExp):
reload previous exp (reloadPrevExp) :
Select whether to automatically reload a previously opened experiment at start-up.

uncluttered namespace (unclutteredNamespace):
uncluttered namespace (unclutteredNamespace) :
If this option is selected, the scripts will use more complex code, but the advantage is that there is less of a chance that name conflicts will arise.

components folders (componentsFolders):
components folders (componentsFolders) :
A list of folder path names that can hold additional custom components for the Builder view; expects a comma-separated list.

hidden components (hiddenComponents):
hidden components (hiddenComponents) :
A list of components to hide (e.g., because you never use them)

unpacked demos dir (unpackedDemosDir):
unpacked demos dir (unpackedDemosDir) :
Location of Builder demos on this computer (after unpacking).

saved data folder (savedDataFolder):
saved data folder (savedDataFolder) :
Name of the folder where subject data should be saved (relative to the script location).

Flow at top (topFlow):
Flow at top (topFlow) :
If selected, the “Flow” section will be shown topmost and the “Components” section will be on the left. Restart |PsychoPy| to activate this option.

always show readme (alwaysShowReadme):
always show readme (alwaysShowReadme) :
If selected, |PsychoPy| always shows the Readme file if you open an experiment. The Readme file needs to be located in the same folder as the experiment file.

max favorites (maxFavorites):
max favorites (maxFavorites) :
Upper limit on how many components can be in the Favorites menu of the Components panel.


.. _coderSettings:

Coder settings (Coder)
---------------------------
code font (codeFont):
code font (codeFont) :
A list of font names to be used for code display. The first found on the system will be used.

comment font (commentFont):
comment font (commentFont) :
A list of font names to be used for comments sections. The first found on the system will be used

output font (outputFont):
output font (outputFont) :
A list of font names to be used in the output panel. The first found on the system will be used.

code font size (codeFontSize):
code font size (codeFontSize) :
An integer between 6 and 24 that specifies the font size for code display in points.

output font size (outputFontSize):
output font size (outputFontSize) :
An integer between 6 and 24 that specifies the font size for output display in points.

show source asst (showSourceAsst):
show source asst (showSourceAsst) :
Do you want to show the source assistant panel (to the right of the Coder view)? On Windows this provides help about the current function if it can be found. On macOS the source assistant is of limited use and is disabled by default.

show output (showOutput):
show output (showOutput) :
Show the output panel in the Coder view. If shown all python output from the session will be output to this panel. Otherwise it will be directed to the original location (typically the terminal window that called |PsychoPy| application to open).

reload previous files (reloadPrevFiles):
reload previous files (reloadPrevFiles) :
Should |PsychoPy| fetch the files that you previously had open when it launches?

preferred shell (preferredShell):
preferred shell (preferredShell) :
Specify which shell should be used for the coder shell window.

newline convention (newlineConvention):
newline convention (newlineConvention) :
Specify which character sequence should be used to encode newlines in code files: unix = \n (line feed only), dos = \r\n (carriage return plus line feed).


Expand All @@ -130,19 +130,19 @@ newline convention (newlineConvention):
Connection settings (Connections)
---------------------------------

proxy (proxy):
proxy (proxy) :
The proxy server used to connect to the internet if needed. Must be of the form \http://111.222.333.444:5555

auto-proxy (autoProxy):
auto-proxy (autoProxy) :
|PsychoPy| should try to deduce the proxy automatically. If this is True and autoProxy is successful, then the above field should contain a valid proxy address.

allow usage stats (allowUsageStats):
allow usage stats (allowUsageStats) :
Allow |PsychoPy| to ping a website at when the application starts up. Please leave this set to True. The info sent is simply a string that gives the date, |PsychoPy| version and platform info. There is no cost to you: no data is sent that could identify you and |PsychoPy| will not be delayed in starting as a result. The aim is simple: if we can show that lots of people are using |PsychoPy| there is a greater chance of it being improved faster in the future.

check for updates (checkForUpdates):
check for updates (checkForUpdates) :
|PsychoPy| can (hopefully) automatically fetch and install updates. This will only work for minor updates and is still in a very experimental state (as of v1.51.00).

timeout (timeout):
timeout (timeout) :
Maximum time in seconds to wait for a connection response.


Expand All @@ -155,20 +155,20 @@ audioLib :
Select your choice of audio library with a list of names specifying the order they should be tried.
We recommend `['PTB', 'sounddevice', 'pyo', 'pygame']` for lowest latency.

audioLatencyMode : 0, 1, 2, 3, 4
Latency mode for PsychToolbox audio (3 is good for most applications. See :ref:`PTB_latency_modes`.
audioLatencyMode : 0, 1, 2, 3 (default), 4
Latency mode for PsychToolbox audio. See :ref:`PTB_latency_modes`.

audioDriver: 'portaudio'
Some of PsychoPy's audio engines provide the option not to sue portaudio but go directly to another lib (e.g. to coreaudio) but some don't allow that
audioDriver : 'portaudio'
Some of PsychoPy's audio engines provide the option not to use portaudio but go directly to another lib (e.g. to coreaudio) but some don't allow that.

# audio driver to use
audioDriver = list(default=list('portaudio'))
# audio device to use (if audioLib allows control)
audioDevice = list(default=list('default'))
# a list of parallel ports
parallelPorts = list(default=list('0x0378', '0x03BC'))
# The name of the Qmix pump configuration to use
qmixConfiguration = string(default='qmix_config')
audioDevice :
The name of the audio driver to use.

parallelPorts :
A list of parallel ports. The default is ``['0x0378', '0x03BC']``.

qmixConfiguration :
The name of the Qmix pump configuration to use. The default is ``'qmix_config'``.

.. _keyBindings:

Expand Down
24 changes: 12 additions & 12 deletions docs/source/recipes/builderFeedback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ This is actually demonstrated in the demo, `ExtendedStroop` (in the Builder>demo

If you have a Keyboard Component called `key_resp` then, after every trial you will have the following variables::

key_resp.keys #a python list of keys pressed
key_resp.rt #the time to the first key press
key_resp.corr #None, 0 or 1, if you are using 'store correct'
key_resp.keys # A python list of keys pressed
key_resp.rt # The time to the first key press
key_resp.corr # None, 0 or 1, if you are using 'store correct'

To create your `msg`, insert the following into the 'start experiment` section of the :ref:`code`::

msg='doh!'#if this comes up we forgot to update the msg!
msg='doh!'# If this comes up we forgot to update the msg!
and then insert the following into the `Begin Routine` section (this will get run every repeat of the routine)::
if not key_resp.keys :
msg="Failed to respond"
elif resp.corr:#stored on last run routine
msg="Correct! RT=%.3f" %(resp.rt)
msg = "Failed to respond"
elif key_resp.corr: # Stored on last run routine
msg = "Correct! RT=%.3f" %(key_resp.rt)
else:
msg="Oops! That was wrong"
Expand All @@ -42,20 +42,20 @@ In this case the feedback routine would need to come after the loop (the block o

In this case, to get all the keys pressed in a `numpy <http://www.numpy.org>`_ array::

trials.data['key_resp.keys'] #numpy array with size=[ntrials,ntypes]
trials.data['key_resp.keys'] # numpy array with size=[ntrials,ntypes]

If you used the 'Store Correct' feature of the Keyboard Component (and told psychopy what the correct answer was) you will also have a variable::

#numpy array storing whether each response was correct (1) or not (0)
trials.data['resp.corr']
# numpy array storing whether each response was correct (1) or not (0)
trials.data['key_resp.corr']
So, to create your `msg`, insert the following into the 'start experiment` section of the :ref:`code`::

msg='doh!'#if this comes up we forgot to update the msg!
msg='doh!'# If this comes up we forgot to update the msg!
and then insert the following into the `Begin Routine` section (this will get run every repeat of the routine)::

nCorr = trials.data['key_resp.corr'].sum() #.std(), .mean() also available
nCorr = trials.data['key_resp.corr'].sum() # .std(), .mean() also available
meanRt = trials.data['key_resp.rt'].mean()
msg = "You got %i trials correct (rt=%.2f)" %(nCorr,meanRt)

Expand Down
3 changes: 2 additions & 1 deletion psychopy/app/builder/dialogs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,8 @@ def showScreenNumbers(evt=None, dur=5):
# Progress bar
progBar = visual.Rect(
win, anchor="bottom left",
pos=(-1, -1), size=(0, 0.1)
pos=(-1, -1), size=(0, 0.1),
fillColor='white'
)

# Frame loop
Expand Down
4 changes: 4 additions & 0 deletions psychopy/iohub/client/connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ def launchHubServer(**kwargs):
Please see the psychopy/demos/coder/iohub/launchHub.py demo for examples
of different ways to use the launchHubServer function.
"""
# if already running, return extant connection object
if ioHubConnection.ACTIVE_CONNECTION is not None:
return ioHubConnection.ACTIVE_CONNECTION
# otherwise, make a new one
experiment_code = kwargs.get('experiment_code', None)
if experiment_code:
del kwargs['experiment_code']
Expand Down
2 changes: 1 addition & 1 deletion psychopy/preferences/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def loadAppData(self):
"""Fetch app data config (unless this is a lib-only installation)
"""
appDir = Path(self.paths['appDir'])
if not appDir:
if not appDir.is_dir(): # if no app dir this may be just lib install
return {}
# fetch appData too against a config spec
appDataSpec = ConfigObj(join(self.paths['appDir'], 'appData.spec'),
Expand Down
Loading

0 comments on commit 1ad3481

Please sign in to comment.