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
  • Loading branch information
peircej committed Aug 12, 2024
2 parents 401b5f8 + ef69672 commit a97f5d1
Show file tree
Hide file tree
Showing 24 changed files with 377 additions and 373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ eyetracker.hw.pupil_labs.pupil_core.EyeTracker:
port: 50020
timeout_ms: 1000
pupil_capture_recording:
enabled: True
location: Null # Use Pupil Capture default recording location
# Subscribe to pupil data only, does not require calibration or surface setup
pupillometry_only: False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ eyetracker.hw.pupil_labs.neon.EyeTracker:
runtime_settings:
companion_address: neon.local
companion_port: 8080
recording_enabled: True
camera_calibration: scene_camera.json
1 change: 0 additions & 1 deletion psychopy/app/Resources/routine_templates/Basic.psyexp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<Param val="CONTINUOUS" valType="str" updates="None" name="mgMove"/>
<Param val="0.5" valType="num" updates="None" name="mgSaccade"/>
<Param val="0.6" valType="num" updates="None" name="plConfidenceThreshold"/>
<Param val="True" valType="bool" updates="None" name="plPupilCaptureRecordingEnabled"/>
<Param val="" valType="str" updates="None" name="plPupilCaptureRecordingLocation"/>
<Param val="127.0.0.1" valType="str" updates="None" name="plPupilRemoteAddress"/>
<Param val="50020" valType="num" updates="None" name="plPupilRemotePort"/>
Expand Down
1 change: 0 additions & 1 deletion psychopy/app/Resources/routine_templates/Misc.psyexp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<Param val="CONTINUOUS" valType="str" updates="None" name="mgMove"/>
<Param val="0.5" valType="num" updates="None" name="mgSaccade"/>
<Param val="0.6" valType="num" updates="None" name="plConfidenceThreshold"/>
<Param val="True" valType="bool" updates="None" name="plPupilCaptureRecordingEnabled"/>
<Param val="" valType="str" updates="None" name="plPupilCaptureRecordingLocation"/>
<Param val="127.0.0.1" valType="str" updates="None" name="plPupilRemoteAddress"/>
<Param val="50020" valType="num" updates="None" name="plPupilRemotePort"/>
Expand Down
2 changes: 0 additions & 2 deletions psychopy/app/Resources/routine_templates/Online.psyexp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
<Param val="0.5" valType="num" updates="None" name="mgSaccade"/>
<Param val="neon.local" valType="str" updates="None" name="plCompanionAddress"/>
<Param val="8080" valType="num" updates="None" name="plCompanionPort"/>
<Param val="True" valType="bool" updates="None" name="plCompanionRecordingEnabled"/>
<Param val="0.6" valType="num" updates="None" name="plConfidenceThreshold"/>
<Param val="True" valType="bool" updates="None" name="plPupilCaptureRecordingEnabled"/>
<Param val="" valType="str" updates="None" name="plPupilCaptureRecordingLocation"/>
<Param val="127.0.0.1" valType="str" updates="None" name="plPupilRemoteAddress"/>
<Param val="50020" valType="num" updates="None" name="plPupilRemotePort"/>
Expand Down
1 change: 0 additions & 1 deletion psychopy/app/Resources/routine_templates/Trials.psyexp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<Param val="CONTINUOUS" valType="str" updates="None" name="mgMove"/>
<Param val="0.5" valType="num" updates="None" name="mgSaccade"/>
<Param val="0.6" valType="num" updates="None" name="plConfidenceThreshold"/>
<Param val="True" valType="bool" updates="None" name="plPupilCaptureRecordingEnabled"/>
<Param val="" valType="str" updates="None" name="plPupilCaptureRecordingLocation"/>
<Param val="127.0.0.1" valType="str" updates="None" name="plPupilRemoteAddress"/>
<Param val="50020" valType="num" updates="None" name="plPupilRemotePort"/>
Expand Down
5 changes: 0 additions & 5 deletions psychopy/experiment/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ class name. Usually, this function is called by the plugin system. The user

# check type and attributes of the class
if not issubclass(compClass, (BaseComponent, BaseVisualComponent)):
logging.warning(
"Component `{}` does not appear to be a subclass of "
"`psychopy.experiment.components._base.BaseComponent`. This will be skipped."
.format(compName)
)
return
elif not hasattr(compClass, 'categories'):
logging.warning(
Expand Down
18 changes: 2 additions & 16 deletions psychopy/experiment/components/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ def __init__(
plPupilRemoteAddress="127.0.0.1",
plPupilRemotePort=50020,
plPupilRemoteTimeoutMs=1000,
plPupilCaptureRecordingEnabled=True,
plPupilCaptureRecordingLocation="",
plCompanionAddress="neon.local",
plCompanionPort=8080,
plCompanionRecordingEnabled=True,
ecSampleRate='default',
keyboardBackend="ioHub",
filename=None, exportHTML='on Sync',
Expand Down Expand Up @@ -541,8 +539,8 @@ def getVersions():
"Tobii Technology": ["tbModel", "tbLicenseFile", "tbSerialNo", "tbSampleRate"],
"Pupil Labs": ["plPupillometryOnly", "plSurfaceName", "plConfidenceThreshold",
"plPupilRemoteAddress", "plPupilRemotePort", "plPupilRemoteTimeoutMs",
"plPupilCaptureRecordingEnabled", "plPupilCaptureRecordingLocation"],
"Pupil Labs (Neon)": ["plCompanionAddress", "plCompanionPort", "plCompanionRecordingEnabled"],
"plPupilCaptureRecordingLocation"],
"Pupil Labs (Neon)": ["plCompanionAddress", "plCompanionPort"],
"EyeLogic": ["ecSampleRate"],
}
for tracker in trackerParams:
Expand Down Expand Up @@ -734,11 +732,6 @@ def getVersions():
hint=_translate("Pupil remote timeout (ms)"),
label=_translate("Pupil remote timeout (ms)"), categ="Eyetracking"
)
self.params['plPupilCaptureRecordingEnabled'] = Param(
plPupilCaptureRecordingEnabled, valType='bool', inputType="bool",
hint=_translate("Pupil capture recording enabled"),
label=_translate("Pupil capture recording enabled"), categ="Eyetracking"
)
self.params['plPupilCaptureRecordingLocation'] = Param(
plPupilCaptureRecordingLocation, valType='str', inputType="single",
hint=_translate("Pupil capture recording location"),
Expand All @@ -754,11 +747,6 @@ def getVersions():
hint=_translate("Companion port"),
label=_translate("Companion port"), categ="Eyetracking"
)
self.params['plCompanionRecordingEnabled'] = Param(
plCompanionRecordingEnabled, valType='bool', inputType="bool",
hint=_translate("Recording enabled"),
label=_translate("Recording enabled"), categ="Eyetracking"
)

# EyeLogic
self.params['ecSampleRate'] = Param(
Expand Down Expand Up @@ -1615,7 +1603,6 @@ def writeDevicesCode(self, buff):

# Define runtime_settings > pupil_capture_recording dict
code = (
"'enabled': %(plPupilCaptureRecordingEnabled)s,\n"
"'location': %(plPupilCaptureRecordingLocation)s,\n"
)
buff.writeIndentedLines(code % inits)
Expand Down Expand Up @@ -1646,7 +1633,6 @@ def writeDevicesCode(self, buff):
code = (
"'companion_address': %(plCompanionAddress)s,\n"
"'companion_port': %(plCompanionPort)s,\n"
"'recording_enabled': %(plCompanionRecordingEnabled)s,\n"
)
buff.writeIndentedLines(code % inits)

Expand Down
2 changes: 1 addition & 1 deletion psychopy/experiment/components/sound/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def getSpeakerValues():
return vals

self.params['speakerIndex'] = Param(
speakerIndex, valType="code", inputType="choice", categ="Device",
speakerIndex, valType="str", inputType="choice", categ="Device",
allowedVals=getSpeakerValues,
allowedLabels=getSpeakerLabels,
hint=_translate(
Expand Down
65 changes: 32 additions & 33 deletions psychopy/hardware/crs/bits.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# Part of the PsychoPy library
# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019-2024 Open Science Tools Ltd.
# Distributed under the terms of the GNU General Public License (GPL).

# Acknowledgements:
# This code was initially written by Jon Peirce.
# with substantial additions by Andrew Schofield
# CRS Ltd provided support as needed.
# Shader code for mono++ and color++ modes was based on code in Psychtoolbox
# (Kleiner) but does not actually use that code directly

import psychopy.logging as logging

try:
from psychopy_crs.bits import (
BitsSharp,
BitsPlusPlus,
DisplayPlusPlus,
DisplayPlusPlusTouch)
except (ModuleNotFoundError, ImportError):
logging.error(
"Support for Cambridge Research Systems Bits#, Bits++, Display++ and "
"Display++ Touch hardware is not available this session. Please "
"install `psychopy-crs` and restart the session to enable support.")
except Exception as e:
logging.error(
"Error encountered while loading `psychopy-crs`. Check logs for more "
"information.")

if __name__ == "__main__":
from psychopy.tools.pkgtools import PluginStub


class BitsSharp(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/bits/#psychopy_crs.bits.BitsSharp"
):
pass


class BitsPlusPlus(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/bits/#psychopy_crs.bits.BitsPlusPlus"
):
pass


class DisplayPlusPlus(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/bits/#psychopy_crs.bits.DisplayPlusPlus"
):
pass


class DisplayPlusPlusTouch(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/bits/#psychopy_crs.bits.DisplayPlusPlusTouch"
):
pass
14 changes: 5 additions & 9 deletions psychopy/hardware/crs/colorcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@
from psychopy.tools.pkgtools import PluginStub


class ColorCAL(PluginStub, plugin="psychopy-crs", doclink="https://psychopy.github.io/psychopy-crs/coder/ColorCAL"):
class ColorCAL(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/ColorCAL"
):
pass


# Monkey-patch our metadata into CRS class if missing required attributes
if not hasattr(ColorCAL, "longName"):
setattr(ColorCAL, "longName", "CRS ColorCAL")

if not hasattr(ColorCAL, "driverFor"):
setattr(ColorCAL, "driverFor", ["colorcal"])
14 changes: 5 additions & 9 deletions psychopy/hardware/crs/optical.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,9 @@
from psychopy.tools.pkgtools import PluginStub


class OptiCAL(PluginStub, plugin="psychopy-crs", doclink="https://psychopy.github.io/psychopy-crs/coder/OptiCAL"):
class OptiCAL(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/OptiCAL"
):
pass


# Monkey-patch our metadata into CRS class if missing required attributes
if not hasattr(OptiCAL, "longName"):
setattr(OptiCAL, "longName", "CRS OptiCal")

if not hasattr(OptiCAL, "driverFor"):
setattr(OptiCAL, "driverFor", ["optical"])
19 changes: 15 additions & 4 deletions psychopy/hardware/crs/shaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@
# (Mario Kleiner) but does not use that code directly
# It is, for example, Mario's idea to add the 0.01 to avoid rounding issues

try:
from psychopy_crs.shaders import bitsMonoModeFrag, bitsColorModeFrag
except Exception:

from psychopy.tools.pkgtools import PluginStub


class bitsMonoModeFrag(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/shaders"
):
pass

if __name__ == "__main__":

class bitsColorModeFrag(
PluginStub,
plugin="psychopy-crs",
doclink="https://psychopy.github.io/psychopy-crs/coder/shaders"
):
pass
7 changes: 7 additions & 0 deletions psychopy/hardware/emulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,12 @@ class ResponseEmulator(
pass


class launchScan(
PluginStub,
plugin="psychopy-mri-emulator"
):
pass


if __name__ == "__main__":
pass
20 changes: 14 additions & 6 deletions psychopy/hardware/microphone.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ def __init__(self,
if isinstance(device, MicrophoneDevice):
self._device = device._device
else:
raise KeyError(
f"Could not find MicrophoneDevice named {index}"
# if not found, find best match
self._device = self.findBestDevice(
index=index,
sampleRateHz=sampleRateHz,
channels=channels
)
else:
# get best match
Expand Down Expand Up @@ -337,11 +340,11 @@ def findBestDevice(self, index, sampleRateHz, channels):
# iterate through device profiles
for profile in self.getDevices():
# if same index, keep as fallback
if profile.deviceIndex == index:
if index in (profile.deviceIndex, profile.deviceName):
fallbackDevice = profile
# if same everything, we got it!
if all((
profile.deviceIndex == index,
index in (profile.deviceIndex, profile.deviceName),
profile.defaultSampleRate == sampleRateHz,
profile.inputChannels == channels,
)):
Expand All @@ -353,6 +356,7 @@ def findBestDevice(self, index, sampleRateHz, channels):
f"Could not find exact match for specified parameters (index={index}, sampleRateHz="
f"{sampleRateHz}, channels={channels}), falling back to best approximation ("
f"index={fallbackDevice.deviceIndex}, "
f"name={fallbackDevice.deviceName},"
f"sampleRateHz={fallbackDevice.defaultSampleRate}, "
f"channels={fallbackDevice.inputChannels})"
)
Expand Down Expand Up @@ -391,7 +395,7 @@ def isSameDevice(self, other):
# if the other object is the wrong type or doesn't have an index, it's not this
return False

return self.index == index
return index in (self.index, self._device.deviceName)

@staticmethod
def getDevices():
Expand Down Expand Up @@ -429,9 +433,13 @@ def getDevices():
def getAvailableDevices():
devices = []
for profile in st.getAudioCaptureDevices():
# get index as a name if possible
index = profile.get('device_name', None)
if index is None:
index = profile.get('index', None)
device = {
'deviceName': profile.get('device_name', "Unknown Microphone"),
'index': profile.get('index', None),
'index': index,
'sampleRateHz': profile.get('defaultSampleRate', None),
'channels': profile.get('inputChannels', None),
}
Expand Down
Loading

0 comments on commit a97f5d1

Please sign in to comment.