Intro

From Waisman Brain Imaging Wiki

What Do We Use E-Prime For?

  1. To present stimuli (aka pictures, short video clips, and sounds) to subjects.
  2. To control other PCs and equipment; for example, to start and stop the EEG data recording, or to tell the shock equipment the level and duration of a shock, and when to shock the subject.
  3. To send timing/event signals to other PCs and equipment. For example, E-Prime can send an event to the EEG recording system right after E-Prime displays a picture on the screen. The EEG system will record the event in parallel with the EEG data, so that researchers can later determine how the subject reacts right after a picture is displayed.
  4. To record some data. This is usually very high-level stuff like the subject's name or ID, and other session-specific info, like their responses to questions. It can also record the time it takes for a subject to respond to a stimulus; for example, how many milliseconds it takes from when a picture is put on the screen to when the subject presses a key on the keyboard. Generally speaking, the data recorded directly by E-Prime will easily fit on a floppy.

How Does E-Prime Do It?

It puts pictures and videos up on the monitor screen, just like any other PC program. We split out the signal going to the monitor so that it appears on the monitor in the control room and the monitor in the subject room. (We also have a hardware switch that controls if the subject room monitor displays the signal or not. E-Prime doesn't control that at all.) So, for video, E-Prime isn't anything magic or special.

Similarly, for audio, it just plays the sound through the PC's sound card, just like any MP3 player app. Nothing special there. We plug a long extender cable into the sound card, and then plug a pair of "earbud" headphones into the far (subject room) end of the extender. Most studies only use this to play a "startle" sound, which is nothing more than a short recording of white noise played very loud.

E-Prime can read the keyboard and record whatever the subject types, just like many other apps. It also records the exact time that each key is pressed.

Everything else that E-Prime does (control other equipment and send timing or event signals) it does via the serial and printer (parallel) ports.

The serial port stuff is pretty simple. (This is the "E-Prime Biological" stuff that Max uses.) E-Prime sends a short text message out the serial port, and the other computer (like the Mac used for NetStation) gets it. The message can be pretty much anything that you want it to be, and E-Prime will include the time/date that the message is sent. This is mostly used for two things: sending commands (such as "START recording" and "STOP recording"), and events (usually something like "NEGPICON", negative picture is being displayed).

Serial port communication is very easy to do and very reliable. E-Prime would probably use it for everything, except for one problem: it is slow. It can take longer to send a message via the serial port than it will take for a user to blink or otherwise react. So, it isn't too good for anything that involves precise timing. And of course everything we do involves precise timing.

The alternative is to use some form of dedicated digital line. Something that turns on the exact instant that E-Prime tells it to turn on, and turns off exactly when E-Prime tells it to turn off. Then we just connect the line to one of the inputs on the EEG recording amp, and the digital line is recorded right along with the EEG data--it is literally just another channel of data. So then E-Prime can put up a picture, and a fraction of a millisecond later, turn on a line that is connected to the EEG recording amps. When it stops displaying the picture, it turns the line off.

There are two (relatively) easy ways to do this: use special hardware, or abuse the parallel port. We do both.

The analog->digital converter cards that we buy from National Instruments (and from MCC) don't just do A->D. They also have digital on/off lines, both input and output. So, we could use one of these digital output lines to connect to an input port on the EEG amp. The nice thing about using the NI or MCC card to do this is that there are a *lot* of digital lines available, at least 16 or 32--way more than we have spare input ports on the EEG amps. The downsides are: The cards (and drivers and software) are pretty expensive. The programming is much more complicated and fragile.

The other way to get some digital lines is to abuse the printer (parallel) port. The parallel port is called "parallel" because it is actually 8 individual data lines, all bunched together in parallel. Hmmm, 8 data lines. Why, that sounds like just what we need!

Well, almost. Back in the early days of PCs, the parallel port was a simple beast. It used the 8 data lines to send data to a printer, and had 4 more control lines to tell the printer how to do things, plus another 5 lines where the printer could send back its status. Simple. Reliable. Abusable. But then people had to get fancy, and made the 8 lines bi-directional, so that the printer could use them to send info back to the PC. This made the parallel port useful for such things as connecting another PC to it and sending data over it. But it also made the parallel port more complicated and "smarter". You couldn't trust it any more to just send data out--it might try to interpret the data as commands or something. And it got worse when they added the EPP and ECP modes, which made the parallel port even smarter and more interactive.

So, if we can convince the printer port to just behave and act in "standard" mode, then hey, we can use it to send up to 8 separate digital on/off signals to other equipment! Not all parallel ports nowadays can be forced to be dumb, but most can. And it is simple to program. Just set the contents of the port to be what you want (for example, line 1 on, and lines 2-8 off), and voila. Line 1 turns on at the port, and line 1 turns on at the amp.

So, that's how E-Prime does things.

E-Prime is, under the covers, a BASIC-like programming language with a lot of study-oriented functions built in, plus a graphical "connect the boxes" layer on top. Researchers will usually start with an existing E-Prime program, and tweak it to what they need it to be.

They'll usually begin by playing with the "connect the boxes" stuff. A lot can be accomplished this way. But almost always, they'll eventually need to get under the hood and do a little coding. And it is usually just a *little* coding, and they can often steal a snippet from some other study's code. So it isn't too bad.

It only gets ugly when people want to do something really complicated, like have a zillion digital lines plus send stuff over the serial port plus control a shock box plus have the pictures display for like 2 milliseconds. But only insane people like Alex and Max try to do that sort of thing.

Or sometimes the researcher isn't content with having the subject just see a picture and press a key. They want the subject to control a graphical slider bar with a mouse. And those insane people would be named something like Cat. But most people aren't crazy like that, and just want to show some pictures, play a startle noise, and have the users poke at the keyboard.