Fill an array from an (unreferenced) list?
liwenna
liwenna at gmail.com
Wed Aug 5 12:18:19 UTC 2009
Sure..!
The code to fill the triallist from the array is actually quite some
work to type out (it's probably also possible in a more automated
way... i just don't trust my own codes enough to do that) but it's
very easy to understand.
This is the complete code I use now. (I'd use some different coloured
fonts but I don't think google groups supports that). Peter's code
mentioned above is also shown, but I left out the part where it counts
the lines in the .txt-files and gave the arrays a fixed length, as
this works just as fine for my task. I use 12 trialpairs total = 24
screens of 2 stimuluswords each and this requires 24 negative words,
24 positive words and 16 neutral words in total, as will be more
explained halfway the code. Therefore the positive and negative arrays
run from 0 to 23 and the neutral array runs from 0 to 15.
The code begins with resetting the triallist. Then there's a lot of
dimming followed by the reading of the stimwords, filling the the
arrays and lastly randomizing them. This is done for each type of
stimulus: negative, positive and neutral respectively.
================================
'reset the triallist
TrialList.Reset
Dim negwords(23) As String
Dim poswords(23) As String
Dim neutwords(15) As String
Dim lineword As String
Dim LineCount As Integer
Dim n As Integer
'fill the array negwords
'Read in the stimuli into the array negwords
Open "negative.txt" For Input As #1
For n = 0 To 23
Input #1, negwords(n)
Next n
Close #1
'Randomize the contents of the array
RandomizeArray negwords
'fill the array poswords
'Read in the stimuli into the array poswords
Open "positive.txt" For Input As #2
For n = 0 To 23
Input #2, poswords(n)
Next n
Close #2
'Randomize the contents of the array
RandomizeArray poswords
'fill the array neutwords
'Read in the stimuli
Open "neutral.txt" For Input As #3
For n = 0 To 15
Input #3, neutwords(n)
Next n
Close #3
'Randomize the contents of the array
RandomizeArray neutwords
=================================
For the next part it simply uses the values in the array to fill a
triallist that has four attributes. As explained in the opening post;
each screen shows two stimuluswords and two screens with a total of 4
stimuluswords make up 1 trial (or 1 trialpair if you like). Subjects
have to respond to one of the stimuluswords (target) and ignore the
other (distractor). In an experimental trialpair the target in the
probetrial is of the same valence as the distractor in the primetrial,
and the NAP effect is a slowing down on the probe trial with a
negative target due to the distractor in the preceding primetrial also
being negative. There are four types of trials, two experimental and
two control with different arrangements of postive, negative and
neutral valenced words in the target and distractor 'positions'.
By filling the triallist level by level with words from the three
arrays control is gained over which wordtype (valence) will appear in
which position. The list is called triallist and for instance "
triallist.setattrib 4 " referes to the 4th level of the triallist. I
use 12 total levels (so 12 trialpairs per block) but only the first 4
are shown here as the others are repeats. Trialproc is nested into
triallist and contains of two slides, one for the primetrials and one
for the probetrials.
=================================
'Populate the Triallist with current array values
'fill level 1 to 12 with experimental trials
'Fill level 1 of Triallist (positive control)
TrialList.SetAttrib 1, "primedistractor", negwords(0)
Triallist.setattrib 1, "primetarget", negwords(1)
Triallist.setattrib 1, "probedistractor", neutwords(0)
Triallist.setattrib 1, "probetarget", poswords(0)
'Fill level 2 of Triallist (positive experimental)
TrialList.SetAttrib 2, "primedistractor", poswords(1)
Triallist.setattrib 2, "primetarget", negwords(2)
Triallist.setattrib 2, "probedistractor", neutwords(1)
Triallist.setattrib 2, "probetarget", poswords(2)
'Fill level 3 of Triallist (negative control)
TrialList.SetAttrib 3, "primedistractor", poswords(3)
Triallist.setattrib 3, "primetarget", poswords(4)
Triallist.setattrib 3, "probedistractor", neutwords(2)
Triallist.setattrib 3, "probetarget", negwords(3)
'Fill level 4 of Triallist (negative experimental)
TrialList.SetAttrib 4, "primedistractor", negwords(4)
Triallist.setattrib 4, "primetarget", poswords(5)
Triallist.setattrib 4, "probedistractor", neutwords(3)
Triallist.setattrib 4, "probetarget", negwords(5)
========================
That's all there is to it, basically... :)
Not even that hard I see now ^.^
Thanks again for your help Peter!
On Aug 5, 11:13 am, Peter Quain <pqu... at une.edu.au> wrote:
> good, i hadn't run that code. there should be no timing problems
> because of the import routine - that is all going on before your
> trial procedure starts, i gather, so been and gone by the time
> important things are afoot.
>
> Can you post how you go about populating list from array, if you have
> the time? ta
>
> At 07:08 PM 5/08/2009, you wrote:
>
> >The script works just fine Peter!
>
> >(only the s$ was not allowed but simply replacing it by a normal word
> >does the trick)
>
> >Thanks so much!
>
> >Now the timing question remains.... anyone experience with that?
>
> >On Aug 4, 12:44 pm, liwenna <liwe... at gmail.com> wrote:
> > > Thank you for your quick reply Peter!
>
> > > I will definitely try your suggestion! I never used external files to
> > > feed info into e-prime so that's a nice thing to 'get my hands on'.
>
> > > However: doesn't the use of external files influence timing?
> > > (anyone?). And if so: would this also be the case if the whole
> > > retrieveing of info is done in the beginning of a blockproc BEFORE the
> > > trials start running (i.e. in my set-up combined with your/Peter's
> > > suggestion, arrays would be filled, randomised and used to fill a
> > > triallist BEFORE each block of trials starts running).
>
> > > I think I won't have time to try it before tomorrow but I'll post back
> > > when succesfull (and also when not actually ;) )
>
> > > Thanks again!
>
> > > liwenna
>
> > > On Aug 4, 12:03 pm, Peter Quain <pqu... at une.edu.au> wrote:
>
> > > > If you want flexibility and to avoid finicky typing, perhaps you could:
> > > > - type the words in text documents, 1 word to a line. you have
> > > > seperate arrays for each stimulus type ... and you need to type the
> > > > stim sometime
> > > > - open the text documents to read, 1 at a time
> > > > - run a loop, reading each line of the document and saving it as the
> > > > string in each cell of your array
>
> > > > Something like this would allow lists of differing length to be read in.
> > > > ...
> > > > ' for 0 option base
> > > > Dim YourArray() As String
> > > > Dim s$ As String
> > > > Dim LineCount As Integer
> > > > Dim n As Integer
>
> > > > ' Find out the number of lines
> > > > Open "YOURFILE.txt" For Input As #1
> > > > LineCount = -1
> > > > Do While Not EOF(1)
> > > > LineCount = LineCount + 1
> > > > Input #1, s$
> > > > Loop
> > > > Close #1
>
> > > > ' make the array the size of the document...
> > > > ReDim YourArray(LineCount)
>
> > > > ' Read in the stimuli
> > > > Open "YOURFILE.txt" For Input As #1
> > > > For n = 0 To LineCount
> > > > Input #1, YourArray(n)
> > > > Next n
> > > > Close #1
>
> > > > At 07:13 PM 4/08/2009, you wrote:
>
> > > > >Hi all!
>
> > > > >I got something....
>
> > > > >Does anyone know how to fill an array with words from an
> > > > >(unreferenced) list???
>
> > > > >Elaborated background info:
> > > > >I'm working on a NAP task which demands control over two pairs of
> > > > >stimuli in consecutive trials. I.E. a prime trial may show a negative
> > > > >distractorword and a negative targetword and is followed by a probe
> > > > >trial that shows a neutral distractorword and a positive targetword.
> > > > >To put it differently: each trials consists of 2 displays with 4
> > > > >stimuli in total and control over which type of word (pos neg neutral)
> > > > >appears in which position is needed. Moreover... blocks of trial
> > > > >(pairs) are repeated and the stimuliwords need to be randomized each
> > > > >time.
>
> > > > >I got this all working by using arrays. I got separate arrays for
> > > > >negative, positive and neutral words and at the beginning of each
> > > > >block these 3 arrays are randomised and then used to fill a triallist.
> > > > >The trialpair described above for instance is one level in this list
> > > > >that has four attributes (primetarget = negarray(0) primedistractor =
> > > > >negarray(1), probetarget = posarray(0) and probedistractor = neutarray
> > > > >(0), etc etc, with one level per trialpair.
>
> > > > >So far so good.... but now about filling the arrays... in my testsetup
> > > > >I filled the arrays by typing out each word in the array-inline for
> > > > >instance:
>
> > > > >negarray(0) = "negword1"
> > > > >negarray(1) = "negword2"
> > > > >etc
>
> > > > >This works fine but it means that each single word in every list has
> > > > >to be written out in the inline and completed with " " at the start
> > > > >and beginning. As I like my setups to be 'versatile' and easy to
> > > > >adjust for later use I would think it to be more elegant (and less of
> > > > >a pain in adding " -wise) if the stimuliwords could more simply be
> > > > >pasted in to an (unreferenced) list and the arrays being filled from
> > > > >these lists.... but I can't get this to work.... I tried it with
> > > > >colon notation and unreferenced lists ( negarray(0) = [negative:0] and
> > > > >with getattrib/setattrib setattrib ( "negarray(0)", [negative:0] as
> > > > >well as negarray(0) = getattrib ([negative:0]) ), both in all kinds of
> > > > >bracket-arrangements and with the list that contains the attribute
> > > > >'negative' placed in different locations (trashthing, sessionproc,
> > > > >blockproc, trialproc etc) but to no avail....
>
> > > > >I'm just hoping that I'm majorly overlooking something and/or that
> > > > >someone just happens to know how to do this. The task is working fine
> > > > >as it is, I just think it would be more elegant if the arrays could be
> > > > >filled from lists. Or could this perhaps be another instance of colon-
> > > > >notation not working properly?
>
> > > > >Best regards,
>
> > > > >liwenna
--~--~---------~--~----~------------~-------~--~----~
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