What you could do is use the Builder to set up the study as if there was just one block. Then switch to the coder view. It will have done all the mechanical aspects of creating the experiment for you (Jon has done a great job of this: the code is even nicely commented for you.) This is what we often do in our lab: use the Builder to do the 90% monkey work and then switch to the coder view to add the finer level of control that might be needed.
Find the line where the csv file is loaded which contains your trial data for the block. The only Python coding you'll need to do is replace that with a loop so that it runs multiple times, each time loading another (randomly ordered) file.
# i.e. create a list of four filenames containing your block information:
blockList = ['Block1.csv', 'Block2.csv', 'Block3.csv', 'Block4.csv']
random.shuffle(blockList) # reorder them each time
# then find the lines that looks something like these:
#set up handler to look after randomisation of trials etc
trials=data.TrialHandler(nReps=5.0, method=u'random', extraInfo=expInfo,
trialList=data.importTrialList(u'../../../../Users/michael/parameters.csv'))
and replace them with:
for fileName in blockList:
trials=data.TrialHandler(nReps=5.0, method=u'random', extraInfo=expInfo,
trialList=data.importTrialList(fileName))
# i.e. we are now loading a variable file name four times rather than a hard-coded one just once.
# Make sure that the subsequent code which runs each of the trials is also indented
# so that it also gets repeated for each loop.
Hope that helps (but bear in mind this is all just code typed into e-mail and I have no idea if it will actually work). I'm not a real Python programmer either but using the Builder view gives a very good insight into how to learn to write in it just well enough to get things done.
Cheers,
Michael
--
Michael R. MacAskill, PhD michael....@vanderveer.org.nz
Chief Scientist,
Van der Veer Institute
for Parkinson's & Brain Research
66 Stewart St http://www.vanderveer.org.nz
Christchurch 8011 Ph: +64 3 3786 072
NEW ZEALAND Fax: +64 3 3786 080
If you really need completely different routines for your different
blocks then this may not work and it's going to get very ugly very
quickly. Here are a couple of examples.
1) Consider an FFA/PPA localiser in fMRI. You want randomly chosen faces
to appear for a block/epoch and then randomly chosen 'place' stimuli to
appear for another block (and maybe scrambled faces). Have folders for
your different stimuli with the same names inside:
/faces
/stim1.jpg
/stim2.jpg
...
/places
/stim1.jpg
/stim2.jpg
...
Set up a loop called stimulus with a set of Trial Types determining
sitmulus names (stim1.jpg...) and around that create a loop for blocks
that determines the folder to be used. Now, for the stimulus being
presented in your experiment set the image to update 'every repeat' with
a value of
$folderName+'/'+stimName
(folderName is a column in your blocks spreadsheet and stimName is
defined in your stimuli spreadsheet).
2) Consider an experiment to test contrast sensitivity for a range of
spatial freqs that you want to be presented in blocks (no idea why! ;-)
). Set the contrast to be determined in the trials loop, and surround
that by a blocks loop that sets the SF.
Actually, one slight caveat here is that I don't know how data output is
(or should be) handled for nested loops. That might need some tweaking...
Jon
--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience
On a side- but very relevant topic:
when the goal is to randomize trials, remember that not every random is
random. E.g. for two conditions A and B, fully legal, but not highly
probable sequence could be ABABABAB, which, I bet, you would like to
avoid (similarly AAAABBBB etc). Thus please assure that your
random sequence is good enough in terms of trials conditional
probabilities.
It would be great if in addition to 'random' psychopy provided some
additional methods to generate appropriate stimulation sequences
(e.g. m-sequence [1] etc).
[1] http://www.cfn.upenn.edu/aguirre/wiki/public:m_sequences
On Tue, 08 Feb 2011, Jonathan Peirce wrote:
> 1) Consider an FFA/PPA localiser in fMRI. You want randomly chosen
> faces to appear for a block/epoch and then randomly chosen 'place'
> stimuli to appear for another block (and maybe scrambled faces).
> Have folders for your different stimuli with the same names inside:
> /faces
> /stim1.jpg
> /stim2.jpg
> ...
> /places
> /stim1.jpg
> /stim2.jpg
> ...
--
.-.
=------------------------------ /v\ ----------------------------=
Keep in touch // \\ (yoh@|www.)onerussian.com
Yaroslav Halchenko /( )\ ICQ#: 60653192
Linux User ^^-^^ [175555]
yes, great idea!
optseq for fMRI designs would be cool. haven't used it myself but its
well regarded.
for behavioral studies I generally (but not always) like to: a) cycle
through all items in a list before repeating them, and repeat in a
different random order the next time through (we called this
"mini-blocking" in grad school, not sure how widely that term is
used), b) constrain the number of possible consecutive items in a row
(e.g., no more than 3 otherwise people start to wonder if the next
item will also be the same), and c) fix the first 3-5 items so that
all subjects in a study will experience the same thing initially,
avoiding potential differences in anchoring (especially if some items
are low frequency but by chance are over represented early in a random
sequence).
what others do people like?
--Jeremy
> --
> You received this message because you are subscribed to the Google Groups "psychopy-users" group.
> To post to this group, send email to psychop...@googlegroups.com.
> To unsubscribe from this group, send email to psychopy-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/psychopy-users?hl=en.
>
>
Also very useful when you have a mixed design and want to make sure
that all the items were seen by all the subjects the same number of
times (albeit in crossed conditions), e.g.,
subject 1: ABBAABABBABA
subject 2: BAABBABAABAB
subject 3: BABABBABABB
subject 4: ABABAABABAA
just use the same seed in each pair and flip the condition values
-----------------------------------------------------
Gary Lupyan - lup...@wisc.edu
Assistant Professor of Psychology
University of Wisconsin, Madison
http://mywebspace.wisc.edu/lupyan/web/
-----------------------------------------------------
Gary's idea of using a fixed seed is already built into trial handler.
Give the seed attribute the same number twice and it will produce the
same sequence (using random.seed()) fixes the seed for all calls to the
numpy random number generator, whereas this only sets the seed for trial
randomisation.
Jeremy mentioned the method that he tentatively calls mini-bocking. That
is what PsychoPy calls random - ie the random setting is not a full
randomisation of all trials, just the trials within one repeat.
Jon
--
Dr. Jonathan Peirce
Nottingham Visual Neuroscience
This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
This message has been checked for viruses but the contents of an attachment
may still contain software viruses which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
GK Aguirre, MG Mattar, L Magis-Weinberg (2011). de Bruijn cycles for
neural decoding. NeuroImage 56: 1293-1300. (DOI)
which is also described at
http://cfn.upenn.edu/aguirre/wiki/public:de_bruijn
might be a valuable addition to psychopy ;-) initial code is in C++ so
might be a fun evening project to get a Python equivalent ;-)
On Thu, 10 Feb 2011, Jeremy Gray wrote:
> > It would be great if in addition to 'random' psychopy provided some
> > additional methods to generate appropriate stimulation sequences
> > (e.g. m-sequence [1] etc).
> yes, great idea!
> optseq for fMRI designs would be cool. haven't used it myself but its
> well regarded.
--
=------------------------------------------------------------------=
Keep in touch www.onerussian.com
Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic
--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/e5b_Lddu4G0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/4784e721-19c2-47ce-84c3-8bc1da1c4305%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/6540c7db-aca5-4fa7-ae35-fc8720259f69%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- Jonathan Peirce Nottingham Visual Neuroscience http://www.peirce.org.uk
--
You received this message because you are subscribed to a topic in the Google Groups "psychopy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psychopy-users/e5b_Lddu4G0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psychopy-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/53C8E365.4090307%40gmail.com.
On 7/07/2016, at 06:15, Danielle Taylor <danielle...@gmail.com> wrote:Hello Jon,
I have taken these instructions and modified them to an experiment I have been working on, which pulls from different excel files instead of folders, and I have had some success! For example, I have an outside loop that pulls from a file called BlockOrder.xlsx and an inside loop that pulls from Block. Block is a condition in my BlockOrder file that references 1 of 4 other excel files. The routine inside my inner loop references a condition in either Block1.xlsx, Block2.xlsx, etc. This experiment runs successfully!
HOWEVER, I have one issue that I cannot seem to resolve. I also have a different set of instructions for each block, that I only want to appear once at the start of the block, so I have placed this routine outside my inner loop (which I understand is problematic, but I only want it to appear once, not each loop). Is there a way I can make my instructions vary with my block type (by, say referencing a condition in my Block#.xlsx file), but not get repeated each trial?
Thank you very much for your time and help!
Danielle