[solved] Selective sampling... with a ratio!?!? Help please!
Whilst I dislike melodrama such as I have typed in the title, I do need help (and this is not one that I will find the answer to in few minutes time...).
So here's the situation:
I have a collective resource of 100 word-pairs (split is: 60 not rhyming to 40 rhyming pairs), which I am aiming to use as an ongoing task. However I only want to use 50 of these per session, with pairs being 'randomly' selected every 2-3 seconds, whilst maintaining a 3:2 ratio for not rhyming to rhyming pairs. Oh, and individual pairs cannot be reused within a session (there will be 6 sessions overall, but this is somewhat irrelevant as the loop can be copied once written).
So essentially a session will consist of 50 word pairs (drawn from 100); 30 not rhyming and 20 rhyming. Being presented every 2/3 seconds. Psuedo-randomly of course!
At the moment I have: Loop --> sequence.... not very far at all.
Any help would be greatly appreciated - Please bear in mind I am oblivious to the world of programming languages...
Thanks!
Comments
... Just as a postscript: I also realise that I will need to put the solution in a sketchpad item...
Hi Lee,
To randomly draw samples containing only half of the 60 non-rhyming and 40 rhyming word pairs, and to combine the two into one randomised block list, you will need some Python inline scripting.
For more info on the use Python inline code in OpenSesame, see:
More specifically:
1.) Append an inline_script item at the very beginning of your experiment where you define the complete list of non-rhyming and rhyming word pairs, for example by reading them from a .csv file. The two .csv files have to placed either in the file pool or in the same folder as your experiment.
Place something like the following code in the Prepare-phase tab of the inline_script item (see comments for more information):
2.) Append an inline_script item at the very beginning of your block_sequence, where you will randomly draw two samples containing only half of the word-pairs from the original lists. Use something like the following code (in the Prepare-phase tab) to do so:
3.) Append an inline_script item to the beginning of your trial_sequence to draw one word pair from the block list, without replacement (again, place the code in the Prepare-phase tab):
4.) Finally, set the appropriate number of cyles (in your case 50) in the block_loop and use the square-bracket method to display word1 and word2 in a sketchpad item.
After applying this, your overview area should look something like this:
A working example experiment can be downloaded here (rename the extension from .txt into .opensesame.tar.gz and open as normally). Note that two .csv files with the appropriate names are assumed to be placed either in the file pool or in the same folder as your experiment.
In order to program experiments like the one you're building now, I would strongly advise you to learn some Python. A good start:
Best,
Lotje
Did you like my answer? Feel free to

Lotje,
That is amazingly helpful, and I really appreciate you taking the time to reply.
My Python-less-ness is because I'm quite new to this sort of thing (3rd year undergraduate 'mature' student) - it's actually for a final project for next year.
Whilst I fully intend to become intimately acquainted with Python at some point, at the moment I find myself with more to do than time to do it in!
Dank je wel,
Lee
Hi Lotje,
I've written the inline scripts and my program is identical to the code in your example.... only difference is that your example file works and mine tells me that I have AttributeError: 'numpy.ndarray' object has not attribute 'split'. Having read Byte I now get the terminology of the error but I have tried to find the root of the problem with no luck (after all the split happens in the trial script!) - the only thing that mine has that your doesn't is the rest of my experiment (i.e. instruction screens, countdown timers, 5 further experimental stages). They are all GUI objects and I don't believe that they should affect the inline script.
Hopefully you have some thoughts? Or anyone?
Thanks
Lee
Hi Lee,
Would it be possible to upload the spreadsheet you're using (for example on Dropbox or Filedropper, or simply by making a screenshot of it)?
Also, could you either upload the full code of your experiment (via pastebin, for example) or paste the Python code from your inline_script items here?
I'm sure we can figure out what's going on.
Best,
Lotje
Did you like my answer? Feel free to

I have dropped you an email with the files in a .zip (I'm at work so it was the only way!)
Thanks!
Lee
Hi Lee,
Thanks for your email! I can't see why this is going wrong either. However, when I simply open your .csv files in a text editor, resave them with the extension .txt, and change the corresponding piece of coding accordingly:
everything works.
If I find out why this is the case, I'll let you know.
Best,
Lotje
Did you like my answer? Feel free to

Interesting! I was worried about a knock-on effect from one of the other elements. Hopefully this means that I can get it all working tonight.
Just as an off topic query, you don't know where I might find 'spatial rotation resources' for experiments by any chance? I am fully prepared to make some, but it would be easier if there is some kind of cognitive-library-of-resources somewhere!
Thanks!
Lee
Hi Lee,
No, sorry, I don't know about such a stimulus set...
Good luck and let us know if you have more questions!
Lotje
Did you like my answer? Feel free to

Thanks Lotje, I certainly will
Lee
It didn't take long
I'm trying to relate the keyboard response 'm' to rhyming pairs and the keyboard response 'z' to non-rhyming pairs (as in the instructions for the block), here's what I have so far:
http://pastebin.com/JmW4yH3Z
Full code is here:
http://pastebin.com/PbeekeyB
This is probably simple fix but I'm not seeing the wood for the trees!
Thanks,
Lee
Hi Lee,
Firstly, you should separate the allowed responses in the keyboard_response with a semicolon instead of a comma. So:
m;z.Secondly, to determine whether a given stimulus pair comes from the rhyming or the non-rhyming list, and to define the corresponding correct response, you could use something like the following Python inline code:
Good luck!
Lotje
Did you like my answer? Feel free to

It's amazing how clear things become after they are explained by an 'expert other'
I did actually continue with my own efforts after posting, but it was fruitless as I tried to set 'list_rhymes' as a range and search for the stimulus in it... didn't work....
However I am learning a lot through your helpful guidance!
Thanks once more!
Lee