Skip to content

Instantly share code, notes, and snippets.

@alexholcombe
alexholcombe / gaborSecondScreenProblem.py
Created December 15, 2023 03:11
Psychopy: When fullscr, second screen is positioned incorrectly
from psychopy import core, visual, event
#If scrn=0, graphics window fills entire screen correctly
#If scrn=1, the graphics window is vertically offset so doesn't draw to entire screen, so you won't see the 'Hit Q to quit' message as it is off screen
scrn=1
myWin = visual.Window(fullscr=1,screen=scrn)
# INITIALISE SOME STIMULI
gabor = visual.GratingStim(myWin, tex="sin", mask="gauss", texRes=256,
size=[1.0, 1.0], sf=[4, 0], ori = 0, name='gabor1')
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Text is not vertically centered. Instead, 'center' coordinate it is drawn at is actually a point partway up from the text's vertical center.
"""
from __future__ import division
from psychopy import visual, core, event
@alexholcombe
alexholcombe / trialHandler2_alex.py
Created March 4, 2019 15:40
To illustrate that in PsychoPy3.0.5, trialHandler methods .next() and .nextEntry() do not work
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Demo of TrialHandler
"""
from __future__ import absolute_import, division, print_function
from builtins import range
#Uploaded in response to query on psychopy list: https://groups.google.com/group/psychopy-users/browse_thread/thread/c65e453edf530f8
#asking for code to input a string.
#Program flashes string on screen, and user tries to type it in. Supports backspace but no other editing special characters.
#Checks whether subject got it right
#Alex Holcombe alex.holcombe@sydney.edu.au 21 August 2012
#licensing: CC-BY whch means do whatever you want with it, with an attribution to the author. If you want permission to use it without
#attribution, just contact me.
from psychopy import monitors, visual, event, data, logging, core, sound, gui
import psychopy.info
@alexholcombe
alexholcombe / readWavAsArray2.py
Created August 13, 2012 23:03
some sound processing of wav files
#!/usr/bin/env python
"""
by Alex Holcombe
license: CC-ZERO
This code is a mess and a melange of sound processing, but was
uploaded because booradleyboo asked about sound processing on the google groups.
"""
import sys,os
import math
from os import path
@alexholcombe
alexholcombe / responseTimeTimestamped.py
Created July 4, 2012 01:12
demonstration of time-stamped keyboard polling with psychopy
from psychopy import visual, event, core
import numpy as np
"""Record response latency
"""
respClock = core.Clock()
Hz = 60
#create a window to draw in
bgColor=np.array([-1,-1,-1])
scrn = 0; fullscrn= 0
@alexholcombe
alexholcombe / tentativePsychopyRespTime.py
Created July 1, 2012 09:36
tentative test of psychopy response latency. Is this the recommended way to record response time?
from psychopy import visual, event, core
import numpy as np
"""Record response latency
"""
trialClock = core.Clock()
Hz = 60
#create a window to draw in
bgColor=np.array([-1,-1,-1])
scrn = 0; fullscrn= 0