I am running a script that presents red, green, and blue colors with intensities that range from 0-256 for each color, incrementing by 25 steps. The purpose of this is to calibrate the screen. However, before doing that, I ran this script to see whether intensity changes are visible to the naked eye (from my understanding, they should be; at least to detect a difference from 25 to 200). The problem is that intensity does not seem to change on the screen, despite the loop working (confirmed/reproducible via on-screen messages between each intensity change). I was wondering if anyone might have suggestions for fixing this.
Here is the reproducible script (press ‘q’ to quit whenever):
from psychopy import visual, core, event
import csv
# Create a window for calibration
win = visual.Window(size=(1920, 1080), fullscr=True, units="pix", color=[0,0,0])
# Define color channels and steps
channels = ['red', 'green', 'blue']
steps = list(range(0, 256, 25)) # Set the steps
# To store the records
records = []
# Function to check for 'q' key press
def check_quit_key():
keys = event.getKeys()
if 'q' in keys:
# Save the records before quitting
with open('color_calibration_records.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Color", "Intensity"]) # Header
writer.writerows(records) # Data rows
win.close()
core.quit()
# Create a rectangle to cover the entire screen
rect = visual.Rect(win, width=1920, height=1080)
# Calibrate each color channel
for channel in channels:
for step in steps:
if channel == 'red':
color = [step, 0, 0]
elif channel == 'green':
color = [0, step, 0]
elif channel == 'blue':
color = [0, 0, step]
# Show the color
rect.fillColor = color
rect.draw()
win.flip()
core.wait(3) # Show color for 3 seconds
check_quit_key() # Check if 'q' was pressed
# Record the value
records.append([channel, step])
# Display the "Just shown" message on a black screen
rect.fillColor = [0, 0, 0]
rect.draw()
message = f"Just shown: {channel.upper()} {step}"
text = visual.TextStim(win, text=message, height=50, color='white')
text.draw()
win.flip()
core.wait(1) # Display the message for 1 second
win.flip()
# Save the records to a CSV
with open('color_calibration_records.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerow(["Color", "Intensity"]) # Header
writer.writerows(records) # Data rows
# Close the window
win.close()
I am using Psyvhopy coder version 2023.1.2 on a Windows computer (running Windows 11) with a BenQ Zowie XL2540K 8-bit 240Hz display.