Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Experiment Design

by aufrank (Pilgrim)
on Jul 13, 2002 at 17:01 UTC ( #181498=perlquestion: print w/replies, xml ) Need Help??

aufrank has asked for the wisdom of the Perl Monks concerning the following question:

Hey all--

When I go back to school in the fall, I will be starting my own research in a psycholinguistics lab. I designed the experiment at the end of last semester, and am looking forward to actually carrying it out.

The main thing that subjects will have to do is a lexical decision task, where they are presented with a string of letters, and have to indicate by pressing certain keys whether or not the characters on the screen form a real word. By displaying different types of distractor words for varying amounts of time before the target word we can find out what characteristics of words have facilitative effects on lexical decision (speed up the decision), and which have inhibitory effects (slow down the decision).

I am hoping that I can write the code to conduct the experiment in pure perl. I will need the following functionality:

  • display an entirely blank screen
  • show words at random points on the screen
  • control how long the words stay on the screen
  • take user input as to whether the letters form a word or not
  • measure the time between displaying the target word and the user input
  • keep track of the users input in a database as the experiment progresses

    I'm wondering what sorts of modules you all know about that could potentially be put together to construct the type of experiment I'm talking about. Measuring time is especially important, and needs to be accurate at least down to miliseconds. Is a pure perl solution feasible and practical?

    Thanks in advance for any input,

  • Replies are listed 'Best First'.
    Re: Experiment Design
    by cjf (Parson) on Jul 13, 2002 at 17:28 UTC

      Sounds like an interesting experiment, a few modules that come to mind are:

      • Time::HiRes for measuring time more accurately.
      • DBI modules for the database input.
      • Math::TrulyRandom may be of use for random number generation, I have had a couple problems with it though and it's in all probability overkill.

      You might want to check out the Lingua modules as well, some of them are very interesting.

      Update: Forgot to ask, what exactly do you mean by "screen?" The console? a GUI? web-based maybe? or have you decided yet?

        Thanks for your reply and all the others-- the suggestions so far have been really helpful.

        I wish I could provide more specifics about the setup in the lab, but since I've yet to do any work there, I actually don't know what platform I'll be running this on.

        cjf, to clarify what I mean by screen, I need to fill the entire monitor with one background color, and write words to random spots on it in another color. Preferably this could be done without displaying any of the usual window-dressing (title bar and close buttons), so a browser-based solution does not really appeal. The idea is that the only thing the subject can focus on is the words that I present them, so really I'm basically just looking to turn the entire monitor white and print black text to different points within that big white backdrop.

        Hope this makes sense and helps to clarify my needs, thanks again for all the feedback so far,

    Re: Experiment Design
    by amphiplex (Monk) on Jul 13, 2002 at 17:23 UTC
      You could use Time::HiRes for accurate time measuring:
      use Time::HiRes qw(gettimeofday); print "Press return: "; my $before = gettimeofday; <>; my $elapsed = gettimeofday - $before; print "you took $elapsed seconds\n";
      (code taken from the Perl-Cookbook)

      ---- kurt
    Re: Experiment Design
    by zentara (Archbishop) on Jul 13, 2002 at 18:56 UTC
      The Term::Screen module will make it easy to
      position words on the screen, colors and highlighting too
    Re: Experiment Design
    by beretboy (Chaplain) on Jul 13, 2002 at 18:59 UTC
      You may want to look into the Tk family of modules for display and blanking out the screen. Also check out Term::Readkey to get user input.

      "Sanity is the playground of the unimaginative" -Unknown
    Re: Experiment Design
    by ronald (Beadle) on Jul 15, 2002 at 01:17 UTC
      Getting millisecond accuracy is pretty tricky business, and you might be better off with a professional package designed for this kind of thing. I work in a linguistics lab (phonetics), and we use E-Prime from It's designed for use with Windows.

      Even if you don't want to use E-Prime, their documentation has some nice discussion of the kinds of technical problems you need to address in a Windows environment for getting millisecond accuracy. Maybe Time::HiRes addresses all these problems already.
        I'll second these concerns. Time::HiRes may be up to snuff on Win32 (I don't see why it wouldn't be since it uses XS) but I'd read the source and put it through some torture tests to be sure. And you could always write your own XS code to handle timing if you needed to. But in addition, I'd be concerned about the accuracy of measuring keypress times on a standard keyboard.

        Incidentally, this looks like a good run-down of the commercial experimental psych packages, including E-Prime and others.

        -- Frag.

    Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: perlquestion [id://181498]
    Approved by TStanley
    Front-paged by cjf
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (7)
    As of 2022-12-01 16:12 GMT
    Find Nodes?
      Voting Booth?