Tidying an if.. then statement in E-Prime script for attention capture paradigm

David McFarlane mcfarla9 at msu.edu
Fri May 14 20:43:28 UTC 2010


Chloe,

Wow.  I would like to know how others here feel, 
but when I see someone post more than about a 
dozen lines of code I get the feeling that they 
are so hopelessly lost that they are beyond any 
help that I can offer.  Still, I will hazard a 
couple of thoughts on this situation.

If I were to use arrays for this (instead of 
Lists, which I will come back to), then I would 
put everything into one array instead of 
separated into so many arrays as you have 
done.  Using all those separate arrays just 
complicates matters and wastes the power of 
arrays.  With all the file names in one array, I 
could then use Mid() or InStr() to inspect any 
string for the presence of tags like "Neut" or 
"Hap", and I would need only one array name to 
use in my conditional expressions for the If...Thens.

Sticking with arrays, I might go a step further 
and put all this into one mult-dimensional 
array.  I could use one dimension for eye color, 
another for orientation, etc.  Now, by a suitable 
choice of index values, I could immediately 
single out ranges from any dimensions I like.

But I would probably not use arrays anyway.  More 
likely I would put all this into a List.  After 
all, if you are not going to use the specialized 
features of E-Prime, why use it at all? -- You 
could just as well use any general-purpose 
programming platform, which would both cost less 
and make more portable programs.  Anyway, my List 
could contain a column or "attribute" for each, 
well, attribute, e.g., ID, EyeColor, Orientation, 
Emotion.  I could then generate my file names 
simply by concatenating attribute references in 
my Image or Slide objects, 
thus: 
[ID]-[EyeColor]-[Orientation]-[Emotion].bmp 
(note that I do not have to include the ".bmp" in 
any of the strings of either arrays or Lists).  I 
might even go a bit further and use nested Lists 
to indicate which files may be used with each 
other file.  With enough care, I might do 
everything with Lists and not need any If...Thens at all!

In any case, I think this could all be cleared up 
with a little more study into elementary computer 
programming combined with a little more exercise 
in the specifics of E-Prime.  So I will close 
with a bit of more general advice that others here are sick of seeing from me:

1) First, decide whether you want to be a 
researcher who dabbles in computer programming, 
or a computer programmer who dabbles in psychology research.

2) If the former, then hire this out to someone 
who actually enjoys this sort of work and is good 
at it, while you do something else that you enjoy 
and are good at.  That's what the division of 
labor is all about, learn to use it.

3) In any case, do take an Introduction to 
Computer Programming class, if not to make you 
into a programmer then to help you communicate 
and collaborate better with any programmer that 
you hire to shore up the technical needs of your research.

And if you haven't even done the tutorials that 
come with E-Prime, then you should really start there.

-- David McFarlane, Professional Faultfinder
"For a successful technology, reality must take 
precedence over public relations, for nature 
cannot be fooled."  (Richard Feynman, Nobel prize-winning physicist)


At 5/13/2010 06:05 PM Thursday, you wrote:
>I’m having some problems with scripting an If, then clause in my
>program. I’ve edited an emotional capture paradigm in which people
>view 3 faces on the screen, one face has blue eyes (the target) and
>the other two faces have brown eye (the distractors). When
>participants find the blue eyed face, they must respond with what
>direction the face is tilted in (left or right). On 2/3 trials, all
>faces have a neutral emo expression. However, on 1/3 trials, one face
>will show a discrepant emotion (either happy or sad) and this
>discrepant emotion can appear on either the target face or on the
>distractor faces. The emotion is always irrelevant to the task (find
>blue eyes).
>
>I use four face identities in this task, and the pictures are edited
>so each face has blue eyes and brown eyes. So, for example, I have a
>picture of ID1 with blue eyes and a picture of ID1 with brown eyes.
>Also, the faces can appear in Left or Right orientation. So, the
>picture files I have are listed in program as thus:
>LBluNeut(1) = "M1_Bl_L_Neut.bmp"
>LBluNeut(2) = "M2_Bl_L_Neut.bmp"
>LBluNeut(3) = "F1_Bl_L_Neut.bmp"
>LBluNeut(4) = "f2_Bl_L_Neut.bmp"
>
>RBluNeut(1) = "M1_Bl_R_Neut.bmp"
>RBluNeut(2) = "M2_Bl_R_Neut.bmp"
>RBluNeut(3) = "F1_Bl_R_Neut.bmp"
>RBluNeut(4) = "F2_Bl_R_Neut.bmp"
>
>LBluHap(1) = "M1_Bl_L_Hap.bmp"
>LBluHap(2) = "M2_Bl_L_Hap.bmp"
>LBluHap(3) = "F1_Bl_L_Hap.bmp"
>LBluHap(4) = "F2_Bl_L_Hap.bmp"
>
>RBluHap(1) = "M1_Bl_R_Hap.bmp"
>RBluHap(2) = "M2_Bl_R_Hap.bmp"
>RBluHap(3) = "F1_Bl_R_Hap.bmp"
>RBluHap(4) = "F2_Bl_R_Hap.bmp"
>
>LBluSad(1) = "M1_Bl_L_Sad.bmp"
>LBluSad(2) = "M2_Bl_L_Sad.bmp"
>LBluSad(3) = "F1_Bl_L_Sad.bmp"
>LBluSad(4) = "F2_Bl_L_Sad.bmp"
>
>Etc… and repeated for all the brown eyes.
>
>I then have this code:
>
>'position objects
>'dim nIndex as integer
>
>for fill_loop = 1 to 3          ‘POSITION OF DISPLAY ITEMS
>  pos(fill_loop) = fill_loop
>next fill_loop
>
>for fill_loop = 1 to 4   'WHICH BROWN EYE (DISTRACTOR) FACE
>  bro_eye(fill_loop) = fill_loop
>next fill_loop
>
>
>'MAKE TARGET NOT SAME AS TARGET ON TRIAL n - 1
>do
>  curr_tar = random(1,4)
>loop while (curr_tar = prev_tar)
>‘MAKE DISTRACTOR NOT SAME AS DISTRACTOR ON TRIAL n - 1
>do
>  RandomizeArray bro_eye, 1, 4
>loop while (bro_eye(1) = prev_dis)
>prev_tar = curr_tar
>prev_dis = bro_eye(1)
>
>/
>*=========================================================================
>''''Choose target face (blue eyes) as first item in list face
>=========================================================================*/
>
>select case c.getattrib("Target_Emotion")
>case "neutral"
>
>  select case c.getattrib("T_Orient")    'READ TARGET FROM TABLE
>  case "left"
>   c.setattrib"rc","m"    'SET RESPONSE
>   stim(1) = LBluNeut(curr_tar)
>  case "right"
>   c.setattrib"rc","k"     'SET RESPONSE
>   stim(1) = RBluNeut(curr_tar)
>  end select
>
>case "happy"
>  select case c.getattrib("T_Orient")
>  case "left"
>   c.setattrib"rc","m"
>   stim(1) = LBluHap(curr_tar)
>  case "right"
>   c.setattrib"rc","k"
>   stim(1) = RBluHap(curr_tar)
>  end select
>
>
>case "sad"
>  select case c.getattrib("T_Orient")
>  case "left"
>   c.setattrib"rc","m"
>   stim(1) = LBluSad(curr_tar)
>  case "right"
>   c.setattrib"rc","k"
>   stim(1) = RBluSad(curr_tar)
>  end select
>end select
>
>/
>*============================================================================*/
>/
>*=========================================================================
>''''Choose brown eyes face for 2nd item in list - CAN be emotional
>=========================================================================*/
>
>select case c.getattrib("Distractor_Emotion")
>case "neutral"
>
>  select case c.getattrib("D1_Orient")    'READ DISTRACTOR 1
>ORIENTATION CONDITION FROM TABLE
>  case "left"
>   stim(2) = LBroNeut(bro_eye(1))
>  case "right"
>   stim(2) = RBroNeut(bro_eye(1))
>  end select
>
>case "happy"
>  select case c.getattrib("D1_Orient")
>  case "left"
>   stim(2) = LBroHap(bro_eye(1))
>  case "right"
>   stim(2) = RBroHap(bro_eye(1))
>  end select
>
>
>case "sad"
>  select case c.getattrib("D1_Orient")
>  case "left"
>   stim(2) = LBroSad(bro_eye(1))
>  case "right"
>   stim(2) = RBroSad(bro_eye(1))
>  end select
>end select
>
>/
>*==============================================================================
>''''Choose second brown eye face as distractor item - never the
>emotional one.
>===============================================================================*/
>
>select case c.getattrib("D2_Orient")
>  case "left"
>   stim(3) = LBroNeut(bro_eye(2))
>  case "right"
>   stim(3) = RBroNeut(bro_eye(2))
>  end select
>
>/
>*============================================================================*/
>
>RandomizeArray pos, 1, 3
>
>
>/*Assign filenames to locations in slide*/
>
>c.setattrib "e1", stim(pos(1))
>c.setattrib "e2", stim(pos(2))
>c.setattrib "e3", stim(pos(3))
>
>
>strImageFile = c.GetAttrib("e1")
>  LoadSlideImageFile search.States(search.ActiveState), "image1",
>strImageFile
>  strImageFile = c.GetAttrib("e2")
>  LoadSlideImageFile search.States(search.ActiveState), "image2",
>strImageFile
>  strImageFile = c.GetAttrib("e3")
>  LoadSlideImageFile search.States(search.ActiveState), "image3",
>strImageFile
>
>
>Okay, so the problem is, I need to insert a clause so that if the
>target being shown is a picture of person1/ID1 with blue eyes, then
>none of the distractors show ID1 with brown eyes. So something like:
>
>If curr_tarr = LBluNeut(1) or RBluNeut(1) or LBluSad(1) or RBluSad(1)
>or LBluHap(1) or RBluHap(1)
>then distractors can’t be LBroNeut(1) or RBroNeut(1) or LBroSad(1) or
>RBroSad(1) or LBroHap(1) or RBroHap(1)
>or if curr_tar = LBluNeut(2) or RBluNeut(2) or LBluSad(2) or
>RBluSad(2) or LBluHap(2) or RBluHap(2)
>then distractors can’t be LBroNeut(2) or RBroNeut(2) or LBroSad(2) or
>RBroSad(2) or LBroHap(2) or RBroHap(2)
>
>etc. for all four IDs. But 1) this doesn’t work! And 2) there must be
>a simpler way of doing this?!
>
>Please help!

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list