Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Reaction Time #163

Closed
DominiqueMakowski opened this issue Aug 14, 2018 · 3 comments
Closed

Simple Reaction Time #163

DominiqueMakowski opened this issue Aug 14, 2018 · 3 comments

Comments

@DominiqueMakowski
Copy link

DominiqueMakowski commented Aug 14, 2018

This is the follow up of #162 with some more details about what I would like to do.

As psychologists are very interested in reaction times, a program for their experiment should separate the display part (loading stimulus and rendering it) from the response collection phase (I imagine it as a minimal while loop only checking for input to increase precision).

It seems that in Makie, those two aspects are somehow integrated, and I am not sure how to use it to build, for instance, a simple reaction time.

In a nutshell, such task would simply display a stimulus (let's say a green circle) and wait for the user's input (and compute the reaction time between stimulus rendering and response).

Using GLFW, I managed to do it, except for the stimulus display, and surely quite inefficiently (disclaimer: my experience with such program is based on pygame: I have no experience with openGL and it might be my way of thinking that is oldschool or just plain wrong):

import GLFW, Dates

monitor = GLFW.GetVideoMode(GLFW.GetPrimaryMonitor())

# Create a full-screen window and its OpenGL context
window = GLFW.CreateWindow(monitor.width, monitor.height, "ReactionTime.jl", GLFW.GetPrimaryMonitor())

# Make the window's context current
GLFW.MakeContextCurrent(window)


t0 = Dates.now() # Get starting time

# Loop until the user closes the window
while !GLFW.WindowShouldClose(window)

	# Render here
	# I don't know how to draw a stimulus

	# Get event
	# GLFW.SetKeyCallback(window, GLFW.Key)  # ok I didn't find how callback works either
	key_pressed = GLFW.GetKey(window, GLFW.KEY_SPACE)
	if key_pressed
		t1 = Dates.now()  # Get time
		rt = t1 - t0  # Compute reaction time
		println("The Reaction time is $rt")
		break
	end

	# Swap front and back buffers
	GLFW.SwapBuffers(window)

	# Poll for and process events
	GLFW.PollEvents()
end
 
GLFW.DestroyWindow(window)

Is such reaction time task, with a good precision and control, feasible in Makie? If not, what other backend / tools should I look for?

Thanks a lot!!

@SimonDanisch
Copy link
Member

Is such reaction time task, with a good precision and control, feasible in Makie?

I want it to be feasable! :D
I will try to add functionality to make this work! So you want to have an explicit renderloop, right?
Something like:

scene = Scene()
insert_stimulus_plot(scene)
t0 = time()
while isopen(scene)
     if ispressed(scene, Keyboard.space)
	rt = time() - t0  # Compute reaction time
	println("The Reaction time is $rt")
    end
    draw_frame(scene)
end

?

If there are any performance problems, we should fix them as fast as possible anyways ;)

@DominiqueMakowski
Copy link
Author

exactly!

@jayschwa
Copy link
Member

It sounds like the feature request applies to a downstream package, so I'm closing this issue. Re-open if I am mistaken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants