Images randomised according to rules?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 10
- Joined: Wed May 13, 2009 4:04 am
Images randomised according to rules?
Hi,
I've done some searching on the forum and while I couldn't find answers to my questions it is apparent that the users here are very helpful, so I thought I'd ask questions myself.
The basic application of a program I am trying to write has two stages which are repeated numerous times. The second stage is a pair of images, the first stage will either be an image which matches one of the pair, an image which doesn't match either of the pair, or there will be no image at all.
Matching image/different image/no image -> Pair of images
Now the problem: I want every image randomised -- but -- there needs to be equal instances of there being matching/different/no image. So for example 10 instances where the first image matched one of the pair shown after it, 10 where the image didn't match either, and 10 where no image is shown at all (but the pair still is). Also I don't want any pairs to be repeated, and the images in the pair cannot be the same one.
I'm not sure how to approach this, and have limited Rev knowledge so I don't know where to begin. Any help would be greatly appreciated.
Edit: Also, this would be repeated around 60-120 times or more. So making a separate card for each set would be unworkable. How can I break it down into fewer cards?
I've done some searching on the forum and while I couldn't find answers to my questions it is apparent that the users here are very helpful, so I thought I'd ask questions myself.
The basic application of a program I am trying to write has two stages which are repeated numerous times. The second stage is a pair of images, the first stage will either be an image which matches one of the pair, an image which doesn't match either of the pair, or there will be no image at all.
Matching image/different image/no image -> Pair of images
Now the problem: I want every image randomised -- but -- there needs to be equal instances of there being matching/different/no image. So for example 10 instances where the first image matched one of the pair shown after it, 10 where the image didn't match either, and 10 where no image is shown at all (but the pair still is). Also I don't want any pairs to be repeated, and the images in the pair cannot be the same one.
I'm not sure how to approach this, and have limited Rev knowledge so I don't know where to begin. Any help would be greatly appreciated.
Edit: Also, this would be repeated around 60-120 times or more. So making a separate card for each set would be unworkable. How can I break it down into fewer cards?
Streamline,
welcome to the forum.
I do not completely understand what you want. But from what I gather you could do it all on one card with all the images on one card but hidden.
You would have lists of names of the images that you can easily handle to decide which images to show and how often.
If you put the names of matching pairs on a line and separate them by comma. So you could say
to hide images just do
If your images are large or the computer is slow then you can wrapp the image hide/show commands with lock screen/unlock screen.
The idea is that once you have the names of the images in a list then you have pretty good control over what you make visible and how and for how long you make it visible. Random is no problem in this approach.
does this make any sense in your setting?
regards
Bernd
welcome to the forum.
I do not completely understand what you want. But from what I gather you could do it all on one card with all the images on one card but hidden.
You would have lists of names of the images that you can easily handle to decide which images to show and how often.
If you put the names of matching pairs on a line and separate them by comma. So you could say
Code: Select all
show image (item 1 of line x of myList)
show image (item 2 of line x of myList)
if item 3 of line x of myList is not empty then
show image (item 3 of line x of myList)
end if
Code: Select all
repeat with i = 1 to the number of images
hide image i
end repeat
The idea is that once you have the names of the images in a list then you have pretty good control over what you make visible and how and for how long you make it visible. Random is no problem in this approach.
does this make any sense in your setting?
regards
Bernd
-
- Posts: 10
- Joined: Wed May 13, 2009 4:04 am
I'm not sure what you mean, how does that script make it random? It has to be different every time the program is run, I can't manually randomise it once and keep using those choices.
Also this may be complicated by the fact that I am recording things. After each pair is shown, the user will choose an image by pressing a button below the one they want, which will note the choice in a text file (not sure how I'm going to make it recognise matched pairs etc, I figured I'd work out the randomisation before how to record it). The button will make the buttons hide and be replaced by a new button which must be pressed to go to the next set of images.
Also this may be complicated by the fact that I am recording things. After each pair is shown, the user will choose an image by pressing a button below the one they want, which will note the choice in a text file (not sure how I'm going to make it recognise matched pairs etc, I figured I'd work out the randomisation before how to record it). The button will make the buttons hide and be replaced by a new button which must be pressed to go to the next set of images.
streamline,
to do some sort of random you would do
the keyword any is not random in a true mathematical sense (which seems to be hard to get) but for most purposes it is sufficent.
or you could say
which is the same as what you get with 'any'
look up 'random' and 'any' in the dictionary. It is helpful to look at how Rev operates on chunks (an item, a word, a line, a character) and so on. So if you make up your list of image as I suggested made up of lines (return delimited) and on each line items (all the text between commas) then you could do what I think you are doing. Of cours there are other ways, depending on what you want exactly. But the line/item thing is very flexible and easy to understand/manipulate. And for lists that are not very long (150 lines is not very long) speed should not be an issue. If speed is an issue you might want to use an array which on the other hand is a little more involved.
is it this what you mean? Apparently you are doing some experiments. In my opinion Rev is very well suited to do that. You have very good control over how long an image is displayed, how long it takes to answer, what the answer is and so on. Just keep asking.
Bernd
to do some sort of random you would do
Code: Select all
put any line of myListOfImages into myVariable
show image item 1 of myVariable
show image item 2 of myVariable
show image item 3 of myVariable
or you could say
Code: Select all
put line (random(the number of lines of myListOfImages) of myListOfImages into myVariable
look up 'random' and 'any' in the dictionary. It is helpful to look at how Rev operates on chunks (an item, a word, a line, a character) and so on. So if you make up your list of image as I suggested made up of lines (return delimited) and on each line items (all the text between commas) then you could do what I think you are doing. Of cours there are other ways, depending on what you want exactly. But the line/item thing is very flexible and easy to understand/manipulate. And for lists that are not very long (150 lines is not very long) speed should not be an issue. If speed is an issue you might want to use an array which on the other hand is a little more involved.
is it this what you mean? Apparently you are doing some experiments. In my opinion Rev is very well suited to do that. You have very good control over how long an image is displayed, how long it takes to answer, what the answer is and so on. Just keep asking.
Bernd
-
- Posts: 10
- Joined: Wed May 13, 2009 4:04 am
Yep, it's for a psychology experiment. The only coding I've done in the past is HTML/CSS (does that even count?) and I was first introduced to Revolution on Monday so this is a bit of a learning experience.
Also, here's the current script I've written on the main card, which might give more of an idea of what I'm doing.
Thanks for the help so far, the last post looks promising, I will play around with your suggestions soon.
Also, here's the current script I've written on the main card, which might give more of an idea of what I'm doing.
Code: Select all
on preOpenCard
hide image "Prime" -- must be randomised
hide image "Left" -- must be randomised
hide image "Right" -- must be randomised and different to Left
hide image "Mask"
hide field "txtReady"
hide group "grpQuestion"
hide button "btNextPair"
end preOpenCard
on openCard
show field "txtReady"
wait 2000 millisec
hide field "txtReady"
show image "Mask"
wait 500 millisec
lock screen
hide image "Mask"
show image "Prime"
unlock screen
wait 35 millisec
lock screen
hide image "Prime"
show image "Mask"
unlock screen
wait 500 millisec
lock screen
hide image "Mask"
show image "Left"
show image "Right"
unlock screen
wait 1500 millisec
show group "grpQuestion"
end openCard
-
- Posts: 10
- Joined: Wed May 13, 2009 4:04 am
Streamline,
You can do pretty much your entire study on one card, using "repeat" statements to loop through the images, checking for doubles with "if then" statements, etc. As Bernd noted, the random() or "any" functions are the way to go, although I believe they give you sampling with replacement, and I suspect you want sampling without replacement until all pictures are exhausted. Is that correct? Regardless, given that you've cleverly named your images 1.png, 2.png, etc. you do *not* have to type everything out, but can change the names dynamically. I started working on code last night to show you, but have gotten distracted (twice!). I'll try again tomorrow and send you what I complete. I'm an applied cognitive psychologist working on a guide to using Revolution in psychology experiments, so I feel a moral obligation to help! In the meantime, I'd love to hear more about the particulars of your priming study.
Actually, if you could send me (off list) a more thorough description of your experiment method, it would help me. Here's my address:
pezzo at mail dot usf dot edu
Cheers,
Mark P.
You can do pretty much your entire study on one card, using "repeat" statements to loop through the images, checking for doubles with "if then" statements, etc. As Bernd noted, the random() or "any" functions are the way to go, although I believe they give you sampling with replacement, and I suspect you want sampling without replacement until all pictures are exhausted. Is that correct? Regardless, given that you've cleverly named your images 1.png, 2.png, etc. you do *not* have to type everything out, but can change the names dynamically. I started working on code last night to show you, but have gotten distracted (twice!). I'll try again tomorrow and send you what I complete. I'm an applied cognitive psychologist working on a guide to using Revolution in psychology experiments, so I feel a moral obligation to help! In the meantime, I'd love to hear more about the particulars of your priming study.
Actually, if you could send me (off list) a more thorough description of your experiment method, it would help me. Here's my address:
pezzo at mail dot usf dot edu
Cheers,
Mark P.
-
- Posts: 10
- Joined: Wed May 13, 2009 4:04 am