Matlab Program for Reading Eprime Text Files

Personal E-Prime knowledge base of one experimental psychology PhD student, or, what I've found useful to know during my learning feel with E-Prime number… If you lot find something that is wrong or want to add more tips, please absolutely do that (in the comments below)!

Contents:

  • Basic work with context attributes and variables in E-Bones inline scripts
  • How to run experiments on multiple computers (without the full E-Prime suite)?
  • How to adjust a script on a field of study station without East-Studio?
  • How to read & consign collected data (.edat2) without E-DataAid?
  • How to easily output simply some values during the experiment?
  • How to create a staircase process in E-Prime?
  • How to send markers/triggers from E-Prime number to EEG or other device (without whatsoever code)?
  • How to design displays with flexible position values?
  • More than resources

Basic work with context attributes and variables in Due east-Basic inline scripts

Yous probably won't go far beyond very simple experiments without using these.. This might non be the most precise picture show, but should be useful for beginners (who are at least somewhat familiar with the basics of E-Prime).

Variables

E-Basic (a VB-based language used in Eastward-Prime number) variables are variables similar in many other programming languages. You can define new ones in the User tab of Script (ALT+5) by the Dim keyword, and you can later work with them in the code in various means. They can be of many types, like Integer or Cord, but can also be complex objects, with many properties and methods (associated functions) to work with them. 1 of the nigh useful object types is Summation, which serves as a container for storing numeric values and computing some statistics on these stored values. A simple case:

'User tab of Script: Dim DetectionACC Equally Summation 'Ascertain new variable  'Inline code, useful to place it as the get-go item in your experiment: Set DetectionACC = New Summation 'Initialize the variable (brand it empty and set up to utilise)  'Inline object, subsequently a response: DetectionACC.AddObservation StimulusSlide.ACC 'Add together a new value to the container, in this example accuracy property of a response to a Slide object which was displayed before, which tin can be one for a right or nil for incorrect response  'Inline object, finish of experiment, e.one thousand.: Debug.Print DetectionACC.Hateful 'Impress a mean of all the values in the container, in our case the mean accuracy        

Context attributes

Context attributes are simply said a special type of variables that can agree string and numeric values and are accessible using special means every bit described below. Their advantage is mainly that they can exist used non just within inline code, but straight in the graphical interface. You lot tin create them by adding columns in a List and you can read them by but writing their name in square brackets in some text-field.

For example, it is useful to define stimulus motion-picture show file names equally context variables, because and then you just alter the filename at only one place (the starting time inline script).

  • Specify the filename of an prototype equally a context attribute using the square brackets. Hither [ImgTop] will specify the name of an paradigm that volition be displayed at the top location.

E-Prime image name attribute

  • We want to vary from trial to trial what picture show volition be displayed here. Instead of a specific file we only enter a proper noun of a context attribute [ImgTop]. We set the possible values of this attribute through a List object, where we create a cavalcade with the same name as this aspect, and within the rows of this columns enter what values that this attribute will take on the various trials (each line of the table corresponds to one or more than trials):

E-Prime list context attributes

  • On some trials the [ImgTop] attribute will be a neutral item, on some trials it will exist a target item. Both items are represented by a different picture. These two pictures occur many times here then it would be impractical to write directly the file name inside this List table. Instead, we ascertain ii more context variables, [Target] and [Neutral]. We assign existent file proper noun values to them in an Inline script with the c.SetAttrib function (it is useful to place this inline script as the starting time object in the experiment):
c.SetAttrib "Target", "target1.bmp"        

Equally you tin see, yous can read the context attributes in the graphical interface using the square brackets. Y'all can as well read them via code with the c.GetAttrib function. For case here we want to ascertain unlike response keys for dissimilar subject groups:

c.SetAttrib "FirstResponseKey", "c" c.SetAttrib "SecondResponseKey", "chiliad" If CStr(c.GetAttrib("Group")) = "2" So 	c.SetAttrib "FirstResponseKey", "m" 	c.SetAttrib "SecondResponseKey", "c" Stop If        

Note that the method for reading the attributes has a dissimilar syntax than the one for writing values to information technology:

WhatIRead = c.GetAttrib("NameOfAttribute") c.SetAttrib "NameOfAttribute", WhatIWrite        

How to run experiments on multiple computers (without the total East-Prime suite)?

Yous are likely to accept only a one or a similarly express number of licenses for E-Studio and the whole E-Prime suite, just y'all want to run your experiments on multiple computers. How to do that?

Your license allows you to install several (around 25) so called Subject field stations, which is exactly what we want hither: It includes but E-Run, the component of East-Prime that allows you lot to run compiled Due east-Basic script .ebs2 files. But it does not allow you to change the script (no Eastward-Studio) or export the collected information into some sensible format (no E-DataAid). Actually, both of these thing are sort-of possible fifty-fifty without the full Eastward-Prime suite, more on this later! To install Subject stations, simply run the E-Prime installation file on the given computers, select that yous want merely the Subject station, and enter in the license details.

How to adjust a script on a bailiwick station without Eastward-Studio?

You cannot directly edit the compiled .ebs2 script, but you can make your experiment adjustable in diverse ways via various parameters. The easiest way is to define "startup info parameters" (basically, context attributes) in the properties of your experiment (CTRL+E) for which the experimenter/participant will exist prompted at the start of the experiment:

E-Prime prompt startup info

Just maybe you want to create many of these parameters, which will not vary across participants, merely volition remain the same for the given computer. Or you desire to exist able to easily send your experiment'due south parameters to someone else. Or you don't want your participant to see you entering the values, etc. For these purposes it is handy to employ a split up XML file that tin can hold many parameters and settings of your experiment. One instance is the number of trials, screen resolution, refresh charge per unit or font size, which could be nice to accommodate e.thousand. if you ship your experiment to a different lab which has computers with different screens, etc. You tin set any context variable that you use in your script in this way.

To create or modify this startupInfo file, become to: Top menu bar – Edit – Experiment… (CTRL+Due east). On Startup Info tab check "Load values from external.." and click on "Edit Local Values".

E-Prime external startupinfo parameters

This opens an editor, where you can set congenital-in backdrop (e.g. Display.XRes) or create new attributes (eastward.g. LetterSize hither, to gear up font size of stimuli). The editor is quite easy to utilize. Relieve the file and then that it has the same name as your script, and extension .startupInfo.

E-Prime startup info editor

You tin open this editor from Windows Start menu besides:

E-Prime start menu

And importantly, you can easily edit this file e.g. in a Notepad on the target computer:

E-Prime startup info xml file

You tin can use the variables (context attributes) that you define in the startup file in typical ways:

E-Prime context attribute in text field E-Prime context attribute in text

Or using c.GetAttrib("LetterSize") in inline scripts.

How to read & consign nerveless information (.edat2) without E-DataAid?

When I collect data on field of study stations, I have to copy the .edat2 files to the computer with the full Due east-Prime suite, merge information technology in E-Merge, and consign it using E-DataAid in some sensible format, eastward.g. tab-delimited (.csv). It has happened to me several times that I wasn't able to do this, because the only PC with Due east-DataAid was occupied, and at any rate, it was a lot of running to and fro, so I idea nigh a way to become independent of E-DataAid. Yous can notice E-Run creates another output file (.txt, tin can exist opened by E-Recovery to convert it into .edat2). Information technology contains the aforementioned data as .edat2 file, just is stored equally plain text. I.eastward., it is possible to read information technology by a parser, that tin convert information technology into an east.k. tab-delimited file. I wanted to write my own parser, but found out there is an existing one for R, chosen rprime, which is perfect, because R is the best tool for data analysis anyhow:-) You can download the project and read how to utilise information technology here. I had to build the packet myself and took me some time to acquire to use it well, merely overall it is simple, so if you demand some help, feel free to contact me. Now at that place seems to be a finished parcel that you tin can easily install: install.packages("rprime").

Example of R script that was sufficient in my case to load the .txt file and covert it into a .csv (information technology might differ in your case, depending on due east.g. how your experiment is structured into levels, you will surely effigy out how to make it work):

library(rprime)  datapath <- "D:/Experiments/SomeExperiment/data/" Files <- list.files(datapath, pattern = ".txt") # convert all .txt files in the given folder for (i in 1:length(Files)){   dataname <- Files[i]   filename <- paste(datapath, dataname, sep="")    elog <- read_eprime(filename)   elist <- FrameList(elog)   level2 <- keep_levels(elist, two)   edf <- to_data_frame(level2)    write.table(edf, file=paste0(datapath, "tsv_", dataname), quote=FALSE, sep="\t") }        

But yous might want a simpler solution and/or practise not need to export all the logged information. In that instance have a await especially at the custom logger solution in the next section:

How to easily output just some values during the experiment?

Sometimes y'all don't want to export all your data to find out something of involvement, like the error rate of your participant or the threshold outcome of a staircase process. There are several ways how to output such a value.

  • If you are running the experiment via Eastward-Studio, you tin can print it to debug panel, e.g., I desire to know the mean accurateness (DetectionACC is a Summation object, see to a higher place):
Debug.Impress DetectionACC.Mean        
  • If you run the experiment at a subject station, yous tin can print the value on screen inside a TextDisplay or other object, using an Inline script placed before the output TextDisplay, e.g. (EndFB is the name of the TextDisplay object):
EndFB.Text = "Accurateness=" & CStr(CLng(DetectionACC.Mean*100))        
  • Or, if you want to relieve the output value or don't want the participant to see it, you can write it into a file. If information technology is just a few values, the easiest manner can be to use the StartupInfo file (see above), which can non merely store values that are input to the experiment, but can store outputs as well. You can use such a code within an Inline script:
Rte.StartupInfo.Local.SetProperty "SCAcc", CLng(DetectionACC.Hateful*100)        

You can and then open up the file using Notepad (and run into that the accurateness was 84 % in this case):

E-Prime startup info writing

  • You can also create a custom log file and suspend multiple lines into it, due east.g. selected info for each trial. For instance here we create a file named co-ordinate to the subject and session numbers, e.g. 12-1-Staircase.dat, and write some info into it. (This Inline object is placed inside a Procedure inside a List, therefore performs a write operation on each trial. Modified from Hairston and Maldjian, encounter below.)
Open c.GetAttrib("Subject") & "-" & c.GetAttrib("Session") & "-" & "log.dat" For Suspend Equally #1 	Impress #1, c.GetAttrib("Bailiwick") & chr(9) & c.GetAttrib("Session") & chr(9) & TrialNum & chr(9) & Response.RT  Close        

How to create a staircase procedure in E-Prime number?

Previous section leads me to the following problem: Creating a staircase procedure that can find a threshold value for some stimulus (e.g., duration of a display, loudness of a sound..). I accept constitute a nice bones solution past Hairston and Maldjian and further worked on it to allow the kind of adaptive staircase procedures equally described in the squeamish paper Garcı́a-Pérez, One thousand. A. (1998). Forced-selection staircases with fixed pace sizes: asymptotic and modest-sample properties. Vision inquiry, 38(12), 1861-1881. I take generalized it to permit combining diverse up-down rules with step-upwards/stride-downwards ratios (e.thou. I am using a iii-down/1-upwards rule with a 3/four delta-down/delta-up ratio to achieve ca. 84% accuracy; it works very well), and fixed what I call back was an error in determining the occurrence of a reversal in sequences longer than 1. Information technology is quite likely the original authors have made some improvements on their code before they published it, but I wasn't able to get my hands on the new code. If yous are interested in my solution, I have uploaded the staircase lawmaking with some basic explanation to GitHub.

How to send markers/triggers from E-Prime to EEG or other device (without any code)?

If you lot desire to record EEG during your behavioral experiment and want to later know at what times in the EEG recording experimental events occurred (e.g. to create ERPs), y'all need to ship trigger signals to the EEG device from E-Prime number at specified times. In older versions of E-Prime you needed to practice this via Inline scripts. In new version you lot can use the graphical interface to exercise it! In many object, like the TextDisplay or a Slide there is a new tab in the object properties, called Task Events. Hither y'all can define signals that should be sent when various events (display onset, keypress, etc.) occur.

In my case I wanted to send a sure value (a byte, i.east. a number between 0 and 255) to an EEG device via parallel port (LPT) at the fourth dimension of the onset of the stimulus. Therefore I added a new OnsetTime result to the Slide object which presents my stimulus display, with these parameters: filibuster kept equally 0 (send the trigger exactly at the onset time), as a Task I selected a parallel port device (defined in experiment properties, encounter picture below), action is to write a byte (because that's what our EEG recording software wants), DisplayTrigger is the value to be sent, which is defined equally a context aspect elsewhere (as a proficient programming practise, to exist able to change it easily), data type is Byte.

Information technology works the same style for response events, e.g., Keyboard.Press events. Or (I had a reason for this once), you lot tin can create a dummy (empty) TextDisplay object which will be displayed for e.g. 20ms right after the response had been made, and send the trigger using OnsetTime events.

E-Prime task event define EEG trigger

An important affair to note is that here one has to fix the signal value, keep information technology for a short time, and then set it back to zero, because it is the change of the bespeak value from cypher to something that is important. For this you need to add the same event again, and change the Delay and Custom (signal) values. I ready the signal to zero after 10 ms, because that is twice the recommended minimum duration for my sampling rate of 500 Hz in our EEG recording software manual. But it can be fifty-fifty longer (eastward.k. 50 ms), to make sure information technology is long enough to be registered by your software. You can read more than about this in the E-Prime number New Features Reference Guide, which I recommend, too as the basic User Guide, or here.

E-Prime task event reset parallel port

Here is how I defined the parallel port device, merely you can use a general Port device, and set it using the address of your port (how to determine it is described in the resources linked below, only often information technology is &H378).

E-Prime define parallel port

More on this topic and on doing these things by inline code, here, here, hither, etc..

How to design displays with flexible position values?

In (east.g.) vision scientific discipline you often need to pattern search displays with many items. Mayhap your locations stay fixed and you only change the items that are displayed at these locations. Maybe you vary the locations from trial to trial completely. In either case, it is a good idea to define the locations

  1. as relative values (in percentages) to brand your script piece of work with different screen resolutions (although percentage values are not as precise equally pixel values..), and
  2. non as fixed values but as variables (divers in an in-line script or an external file) and so that you can easily change them.

All the same, if you do this, you lot volition likely see a mess in your E-Studio: all the (e.g.) Image items on your (e.chiliad.) Slide object will overlap in the center and it will be hard to change their properties (you can use the dropdown box for that).

E-Prime slide items

Useful practice is thus to write the positions like this: [contextAttribute]:defaultPercentage%, e.g. [loc6x]:30%. The role after the colon specifies the default location, if nosotros don't know the variable value, e.g. when displaying the slide object in the E-Studio.

E-Prime image position settings

It all then looks nicely:

E-Prime search display items

BTW, if you demand to create displays with many concentric, equally spaced items (like the one beneath), I have a nice Matlab script for computing the location values, feel costless to contact me.

E-Prime visual search display

More resources

Depending on your level of expertise, you lot can read portions of the bones Users Guide, from which I recommend reading affiliate on Critical Timing, and the New Features Reference Guide. The official website has a lot of info as well, there is a support forum and y'all can find many other resources online (in google information technology helps to write "e-prime" in quotation marks;-))

Other useful resources that I've stumbled upon..

Many more tips at the official website: https://www.pstnet.com/eprimelegFAQ.cfm

Examples of experiments: http://step.psy.cmu.edu/scripts-plus/

terrycoman1975.blogspot.com

Source: http://www.ondrejhavlicek.com/2015/09/e-prime-tips-and-tricks/

0 Response to "Matlab Program for Reading Eprime Text Files"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel