Code Monkey home page Code Monkey logo

psychscript's Introduction

#PsychScript

A HTML5/Javascript library for online behavioural experiments.


PsychScript is intended to make the process of creating and running psychology experiments online much less bewildering. It consists of the following:

  • JavaScript functions which abstract away as much of the difficult programming as possible
  • HTML templates to create the structure of many standard paradigms.
  • CSS to make it all look pretty.
  • The necessary server-side code (PHP) to save responses to a database.

The idea is to allow users' to write one line of PsychScript to make the experiment do what they want it to, rather than a dozen of JavaScript.

For example, collecting a keyboard response, which previously would have looked something this:

var accepted_keys = new Array('a', 'b', 'c');
var response
document.onkeydown = function(event) {
    var key = String.fromCharCode(event.keyCode)
	if (accepted_keys.indexOf(key) != -1) {
		response = key
	}
	else if (accepted_keys.indexOf(key.toLowerCase()) != -1) {
		// In case acccepted_keys were given in lowercase.
		response = key
	};
};

PsychScript allows us to achieve the same with:

var response = get_keyboard_response('abc');

A definite improvement!

Similarly,

var divs_to_hide = ['probe_text', 'probe_image', 'feedback_text']
for(var i=0; i<divs_to_hide.length; i++){
    document.getElementById(divs_to_hide[i]).style.display = "none";
};

becomes

hide(['probe_text', 'probe_image', 'feedback_text'])

You should get the idea by now.


###Demos To see some of PsychScript in action, check out these demos:


###Contribute This is a project for everyone, and all contributions are welcome.

The immediate problems to be solved include:

  • Abstracting as much code as possible away from the end user, while still allowing flexibility through the passing of arguments to functions.
  • Making it easier to create HTML as required by the experimenter (hopefully using existing open tools).
  • Testing and benchmarking, especially with regard to timing accuracy.
  • Creating templates for more common paradigms.

psychscript's People

Contributors

eointravers avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.