Back to Home

psychWithJava - Psychophysics Programming with JAVA

psychWithJava, an open source project, provides tools for preparing psychophysics experiments using Java. It can be used for pure Java development, or with Matlab or Mathematica.

You can find instructions on how to install and use the package below. Sample programs are available under the Examples section. They include self running .jar files, which do not require installing the package.

API specifications - Documentation of all the tools in the psychWithJava package.

Source code - Source code of all the java classes in the package.

Installation and configuration - Instructions for installing the psychWithJava package and setting up your system and development environment.

Examples

Hello Psychophysicist - Your first program using psychWithJava package. Instructions for building and running projects using psychWithJava in pure Java, Matlab or Mathematica. Explains:

  • Preparing and building Java projects
  • Initiating the full screen exclusive mode (FSEM), i.e. capturing the control of the entire screen
  • Displaying text and image on the screen
  • Pausing (sleeping) for a while
  • Hiding/showing the cursor
  • Terminating the FSEM
  • Preparing, sharing and running jar files - these are executable files that you can easily share with colleagues.

A simple example for getting observer response - How to get observers' responses? This example shows how to use the built-in tools of psychWithJava to handle observer responses. Explains
  • Getting observer responses through keyboard
  • Getting the time of these responses
  • Waiting for the observer press a key (indefinitely or for a specific duration)

Exercise: Write a navigable slide show program using at least 4 images. Place horizontally centered subtitles below the images. Use arrow keys for navigation and implement an appropriate behavior at the two ends of the show.

A simple example demonstrating how to accurately time your events/trials - This example shows how to present events/trials accurately in time in blocks. Demonstrates

  • How to present sequence of letter characters in a block with close-to-desired flick rates
  • How to adjust the duration of blocks to match the expected overall elapsed time

An example demonstrating a simple block design fMRI protocol - This example shows how to present events/trials in a block design fMRI experiment. Demonstrates

  • How to present series of images separated by blank screens in a block with close-to-desired flick rates
  • How to adjust the duration of blocks to match the expected overall elapsed time
  • Implement a 1-back task

Exercise: Add "objects" and one more "blank" blocks to the experiment: Faces-Blank-Objects-Blank ....

Size perception - Asymmetric matching procedure to investigate perceived size of objects. Demonstrates the following:

  • Implementing a simple "method of adjustment" task with random trial order
  • Drawing filled geometric shapes (filled circles)
  • Writing observer data into a date-coded file

Orientation Discrimination - Alternative forced-choice (AFC) procedure to investigate orientation discrimination. Demonstrates the following:

  • Implementing a simple forced-choice task with method of constant stimuli
  • Prepare Gabor patches
  • Generate sound for feedback
  • Writing observer data into a date-coded file

Exercise: 1) Adjust the stimulus levels in the OrientationDiscrimination example such that you can get a good psychometric function from your data. Use 10 stimulus levels. 2) Using the same stimulus levels implement a 2 spatial alternative forced choice task (2AFC). Place the Gabor patches on either half of the screen and place a fixation mark at the center. Task is to indicate the side of the screen with the left-oblique Gabor, using arrow keys. 3) Using the same stimulus levels implement a 2AFC match to sample task. Present a Gabor in the first interval, and after an ISI present two Gabors side by side. Task is to indicate the Gabor in the second interval that matches the one in the first interval. Use arrow keys: left or right.

Orientation Discrimination 2 - Introduces an adaptive AFC procedure to investigate orientation discrimination. Shows:

  • How to implement an adaptive staircase procedure
  • Transformed and weighted staircases
  • How to implement interleaved staircases using HashMap

Exercise: 1) Using 4 interleaved, transformed and weighted staircases to converge at 0.75 probability correct, implement a 2 spatial alternative forced choice task (2AFC). Place the Gabor patches on either half of the screen and place a fixation mark at the center. Task is to indicate the side of the screen with the left-oblique Gabor, using arrow keys. 2) Using 4 interleaved, transformed and weighted staircases to converge at 0.75 probability correct, implement a 2AFC match to sample task. Present a Gabor in the first interval, and after an ISI present two Gabors side by side. Task is to indicate the Gabor in the second interval that matches the one in the first interval. Use arrow keys: left or right.

Orientation discrimination 3: Staircases with multiple factors. Coming soon...

Color look-up operations: Coming soon...

Simple block fMRI experiment design: Coming soon...

Wedges with flickering checkers: Coming soon...

Rotating wedges & expanding rings with flickering checkers: Coming soon...

Fixation task: Coming soon...

Normal Window - Convert your FSEM experiments into normal windowed applications.This example shows

  • How to convert your FSEM experiment into a normal windowed application with just a few lines of change using the NormalWindow class
  • Basic usage of the JFrame class in the standard Java API

Java Applets - Convert your FSEM experiments into Java applets and place them on your web page.This example shows

  • How to convert your FSEM experiment into a Java Applet using the NormalWindow class
  • Building and deploying Applets using a web browser or the appletviewer application.
  • A simple trick to run applets without preparing an html file.
  • How to design a re-play button and configure its functionality


Copyright (C) 2005 - 2013 Huseyin Boyaci. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU General Public License version 2 for more details (a copy is included in the LICENSE file that accompanies the source code) (also available at http://www.gnu.org). You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.