Millisecond Forums

MCT showing a picture before skip

https://forums.millisecond.com/Topic8624.aspx

By pprat - 8/29/2012

Hi,

I am trying to show a picture before each clock skip (let's say every 1 second before the clock skips). How would I go about in doing that? Eventually I want the time before the clock skip to be randomized (between 3 to 5 seconds), but for simplicity, let's use 1 second for now. Any help on this would be much appreciated. Thanks.
By Dave - 8/29/2012

As a high-level response: The way to do this is to (a) first work through the original unmodified script to develop a decent understanding of how it works and only then (b) start introducing well-planned modifications based on said understanding. You'll particularly want to focus on how skips are scheduled in the script / the given procedure. Once you've got that down, you can use very much the same logic / approach to schedule your picture cues preceeding the skips.

Hope this helps,
~Dave
By pprat - 9/3/2012

So, in the GenerateSkipTimes trial, we have this formula to calculate skip_times:

values.skip_time = values.avg_event_interval*values.current_event_num + rand(-1*values.max_event_offset, values.max_event_offset)

And then, we save these values into the counter SkipEvent_Time through this line:
insert(counter.SkipEvent_Time, values.skip_time, values.current_event_num)

What happens when I want to make a variable called time_before_skip, and I want this new variable to be 1 second earlier than the generated skip times?

Can I do the following code:
values.time_before_skip = counter.SkipEvent_Time.value - 1000?

Afterwards, I want to do a different trial when values.time_before_skip equals the elapsed time. I tried this and I compiled the code without any error, but it would not do what I want it to do. It's like the condition values.time_before_skip == script.elapsedtime is never true and thus the trial I wanted is never reached.

Do you see an error in this? I am new at coding with Inquisit, and I suspect that something may be wrong with the line:

values.time_before_skip = counter.SkipEvent_Time.value - 1000



Thanks.
By pprat - 9/3/2012

By the way, is there something special that I have to do to show the appropriate spaces in my forum posts? Because I do not mean to write everything as one big paragraph; it is just what happens when I hit the button post.
By pprat - 9/5/2012

Dave,

Is there a way on Inquisit to see the values of the variables as the code is being run? This would help in debugging my code. Without it, I am having a hard time trying to determine which conditions in the code are not being met.

And also, if you could still reply to my old post, I would greatly appreciate it.

Thanks.
By Dave - 9/6/2012

values.time_before_skip = counter.SkipEvent_Time.value - 1000


The <counter> element has no such thing as a 'value' property. See its documentation for the available properties and what they represent. And in case you haven't done so yet, you need to look at how the respective counter is then used throughout the script's

elements.





Is there a way on Inquisit to see the values of the variables as the code is being run? This would help in debugging my code.






Yes. Set up a text element displaying the values of interest and include in your trials' /stimulustimes or /stimulusframes. Alternatively, in Inquisit 4, press CTRL+D at runtime.





Regards,




~Dave

By pprat - 10/9/2012

I have the following excerpt from the mackworth clock test code:



<trial GeneralSkipTimes>


/ ontrialbegin = [


if ( values.current_event_num <= values.total_skip_events)


values.skip_time = values.avg_event_interval*values.current_event_num + rand(-1*values.max_event_offset, values.max_event_offset)


else


values.skip_time = values.total_runtime


...


insert(counter.SkipEvent_Time, values.skip_time, values.current_event_num)



This excerpt generates the pseudo-random times for the skipping of the Mackworth clock and stores it in the SkipEvent_Time counter.  The variables used in the calculation of the skip times are pre-defined in an earlier portion of the code.


Now, I want to add another variable called sign_time.  I want the values of sign time to be always let's say 0 to 3 seconds before the values of the skip time.  I tried simply entering another line inside the if-statement for what values.sign_time would be, and also adding a SignEvent_Time counter to store the respective sign times.  This looks something like the following:




<trial GeneralSkipTimes>


/ ontrialbegin = [


if ( values.current_event_num <= values.total_skip_events)


values.skip_time = values.avg_event_interval*values.current_event_num + rand(-1*values.max_event_offset, values.max_event_offset)


values.sign_time = values.skip_time - rand(0,3000)


else


values.skip_time = values.total_runtime


values.sign_time = values.total_runtime


...


insert(counter.SkipEvent_Time, values.skip_time, values.current_event_num);


insert(counter.SignEvent_Time, values.sign_time, values.current_event_num);




Is this even possible to do?  Or am I not using the if-else-statement correctly here?  I am assuming like in any other programming language that you can have multiple lines of code within if-else-statements.  Am I missing maybe a delineator?  I know this doesn't work, I've already tried it.  But I'd like to know if the error lies in this particular section of the code, or some place else.  Maybe someone can give me some insights here.



Thanks


-pprat

By Dave - 10/9/2012

The correct syntax is


/ ontrialbegin = [if (expression) {expression; expression; ...} else {expression; expression; ...}]


Regards,


~Dave

By pprat - 10/12/2012

If I have this within a trial:



/ stimulusframes = [1=flashmark; 2=picture]


/ trialduration = 500



Then, should the 2 stimuli be appearing for as long as the specified trial duration?


I am having trouble with the picture stimulus.  The flashmark appears to be appearing for the specified time.  However, the picture sometimes appears for exactly the specified time, and other times the picture only flashes and immediately disappears.  I am not sure what is causing this.  Any ideas?



Thanks


- Popa

By Dave - 10/12/2012

/ stimulusframes = [1=flashmark; 2=picture]


means 'flashmark' will be drawn to the screen in the trial's 1st display frame, 'picture' will be drawn to the screen in the 2nd frame.


/ trialduration = 500


means the trial will last a fixed duration of 500ms.


Whether stimuli will be erased upon response or not  (and consequently be visible for the entire duration or not) depends on their /erase setting as well as the trial's /responseinterrupt setting. See the documentation for those attributes for details. Also see the "How to erase stimuli" and the "How to control trial duration and inter-trial intervals" topics in the Inquisit documentation.


Regards,


~Dave

By pprat - 10/17/2012

I am having some issues with the duration of the experiment.  I have set a variable called total_runtime to 60000, which is 60 seconds.  So I expect that when I run my code, it will be for 60 seconds.


I also have set a condition in my code that it should end when the following condition is met:


the stimuli count is bigger or equal to the total number of stimuli wanted && script.elapsed time is bigger or equal to total_runtime


However, everytime I start Inquisit and immediately run the code, there's always an issue.  It would run shorter than the total_runtime that I have set, and also it does not even present the stimuli for the wanted number of times.. This happens when I sign off of the computer and sign back in, and also when I lock the computer and unlock it later on (using Windows).  After a few runs though, I notice that the code starts working as I intended to. 


Is there a glitch in Inquisit 3 or am I just not doing the timing right?



Thanks.

By Dave - 10/17/2012

Is there a glitch in Inquisit 3 or am I just not doing the timing right?


I would suspect the latter. But that is pure speculation.

By Dave - 10/17/2012

the stimuli count is bigger or equal to the total number of stimuli wanted && script.elapsed time is bigger or equal to total_runtime


FWIW, if this is indeed the stop condition you are testing for, note that a logical AND (&&) means *both* statements must be true for the script to stop. If any single true statement is supposed to stop the script you need to apply a logical OR (||).

By pprat - 10/17/2012

Yes, that is indeed what I am intending.  All the more reason the script shouldn't stop.


Thanks anyway.  I will look at my script and see if I can find the error.


By Dave - 10/17/2012

You are welcome to attach the script to this thread. I'll gladly check if I can reproduce the issue (or spot an error) running it through Inquisit 3 on my system.

By pprat - 10/17/2012

Great, that would awesome!  What is the best way to do that?  Copy and paste the script?  Or should I send the file through email?  There is also a picture file (.jpg) that I'll need to send you as well.

By Dave - 10/17/2012

Put everything in a zip file and attach it to this thread via the 'options' tab.

By pprat - 10/17/2012

I'm sorry, where is the options tab?

By pprat - 10/17/2012

Oh I got it.  My apologies.

By pprat - 10/17/2012

Attached is the zip file.  Thank you!

By Dave - 10/18/2012

The problem is in your branching logic in <trial EraseDot>


/ branch = [if (values.sign == false && values.skip == false && script.elapsedtime <= values.total_runtime) trial.NoSkipNoSign]
/ branch = [if (values.sign_and_skip == false && values.sign== true && values.skip == false && script.elapsedtime <= values.total_runtime) trial.NoSkipWithSign]
/ branch = [if (values.sign_and_skip == false && values.skip == true && script.elapsedtime <= values.total_runtime) trial.DoSkip]
/ branch = [if (values.sign_and_skip == true && values.skip == true && script.elapsedtime <= values.total_runtime) trial.DoSkipWithSign]


In short, you don't cover all possible cases there. I.e., situations may arise when none of the branches evaluates to 'true' and thus the script has nowhere to go and must terminate.


To debug this, you can for example add


<expressions>
/ b1 = if (values.sign == false && values.skip == false && script.elapsedtime <= values.total_runtime) true else false
/ b2 = if (values.sign_and_skip == false && values.sign== true && values.skip == false && script.elapsedtime <= values.total_runtime) true else false
/ b3 = if (values.sign_and_skip == false && values.skip == true && script.elapsedtime <= values.total_runtime) true else false
/ b4 = if (values.sign_and_skip == true && values.skip == true && script.elapsedtime <= values.total_runtime) true else false
</expressions>


to the script, set <trial EraseDot>'s /recorddata to true and log the above expressions (which check the branch conditions) to the data file.


Regards,


~Dave

By pprat - 10/19/2012

Dave,


Thanks a lot.  That was very helpful. 

By pprat - 10/22/2012

Dave,


I was able to modify the MCT to include visual stimuli and now I want to basically do the same type of thing, but instead of visual stimuli, I want to do sound stimuli. 


How might I do that? Could you point me to the right direction?



I know the basics of setting up the sound item, etc.  But how would I present the stimulus in a trial at the same time as the clock flashes?  Does it work the same way as the visual?  Meaning could I just set the stimulusframe equal to the sound and have it be presented each time the trial is called?  Or is there a special way to deal with sounds?



I attached what I think is the debugged version of the MCT with visual stimuli for you to see how I've set the experiment up.  Basically the visual stimulus is given either at the same time as the skip of the clock or before the skip.  And I want to do the same type of thing with the sound stimulus.



Thanks!



By Dave - 10/22/2012

There essentially isn't any difference between displaying a <sound> or a <picture> as cue stimulus.

By pprat - 10/22/2012

For some reason, my script won't run when I change the stimulus into a sound stimulus.  I've set up the sound stimulus as shown below:


<item sounds>


/1 = "sound1.mp3"


</item>



<sound sound1>


/items = sounds


/erase = false


/playthrough = true


</sound>



Then at a trial called <trial NoSkipWithSign>, I have set the following:


/stimulusframes = [1=FlashMark, sound1]



Everything else I kept the same as what I had when it was a picture stimulus, so the timing of the cue should still be the same.  Do you see anything wrong with what's above?

By Dave - 10/22/2012

The <sound> element doesn't play mp3s, only straight, uncompressed wavs. For mp3s and other streaming audio formats, use the <video> element.

By pprat - 10/23/2012

Dave,


My experiment involves giving vibrational cues to the participants.  I have been in contact with other users of Inquisit and they advised me to use the sound element of Inquisit and connect a vibrating motor into the audio jack. 


Has anyone ever attempted this?


Do you have any ideas on what type of motor I can use?  What type of voltage can be received from the audio jack?  I purchased a motor that requires 3V (you can see the specs in this website: https://www.sparkfun.com/products/8449), and I also purchased an amplifier (http://www.bhphotovideo.com/bnh/controller/home?O=&sku=763204&Q=&is=REG&A=details) to be used for it.  There hasn't been any success. 


I am assuming that Inquisit does not have USB capabilities, is that right?  The only ways to send vibrational cues would be through the sound port or the parallel/serial port, is that right?


If you could point me in the right direction, I would greatly appreciate it.


Thanks. 


By Dave - 10/23/2012

Interesting idea.


Has anyone ever attempted this?


I am not aware of anyone.


Do you have any ideas on what type of motor I can use?


No.


What type of voltage can be received from the audio jack?


This would depend on your hardware specs, i.e., it's unrelated to Inquisit. I'd try a voltmeter to check.


I am assuming that Inquisit does not have USB capabilities, is that right?


No, there are no generic capabilities to interface w/ USB devices. However, if your device comes with drivers installing a COM (serial) port, it may be possible to trigger the device via Inquisit's <port> facilities.


The only ways to send vibrational cues would be through the sound port or the parallel/serial port, is that right?


Yes. FWIW, any person familiar with electronics you have around would probably be able to assemble something to get the job done without too much hassle.


Regards,


~Dave


By pprat - 10/25/2012

Thanks,


I have another question: can Inquisit call on an executable from inside the script?

By Dave - 10/25/2012

No, it can't.

By pprat - 10/26/2012

Can I send a signal through the serial port in the same manner as sending a visual or sound cue?  We may try to do the vibration aspect of our experiment through the serial port instead.

By Dave - 10/26/2012

Yes.<port> signals are just like other stimuli -- it does not matter if you are outputting <text>s or <pictures> to the screen, <sound>s on an audio device or <port> signals to a COM interface.

By pprat - 10/29/2012

What if I get an adapter for the serial port so that I can use USB devices?  Would I then still be able to output signals through the serial port and then have the adapter convert the signals into the USB devices?


If this is possible, is there any delay issue with this process because I need the signal I send through the serial port to be at specific times with minimal delay?



Thanks.

By Dave - 10/29/2012

What if I get an adapter for the serial port so that I can use USB devices?  Would I then still be able to output signals through the serial port and then have the adapter convert the signals into the USB devices?


This will depend on the actual devices / hardware. There is no general answer to this question, I'm afraid. You'll have to simply try and see if it works in your particular case.


If this is possible, is there any delay issue with this process because I need the signal I send through the serial port to be at specific times with minimal delay?


This will also depend on the actual hardware as well as any involved device drivers.

By pprat - 11/1/2012

Dave,


I am trying to devise a simple script that would send the word "HELLO" in binary format through the serial port.  I am testing this by using a pair of virtual series ports where what is sent to one port is received by the other port.  I am able to see what is being received by the other port, and the script that I have (attached in this thread) appears to only successfully send the letter "H" through but not the "ELLO".  I am suspecting that there is an error in my script, so could you have a quick look at it and see if you can spot the error?  I'm trying to make the script as simple as possible.



Thanks

By Dave - 11/1/2012

I'm not seeing any obvious error in the script -- I suspect something else must be going on. You may want to toy around with the <port> element's /erase settings and/or send another <port> signal between trials to re-set all bits to zero.

By pprat - 11/9/2012

Is there a way to incorporate a survey page at the end of an experiment (in this case, a mackworth clock experiment)?

By Dave - 11/9/2012

A <surveypage> is a special kind of <trial>, a <survey> is a special type of <block>. All the usual rules apply.

By pprat - 11/9/2012

Will <survey> always create its own data file?  Or can I just have 1 data file that contains the data from the clock test and also that data from the survey?

By Dave - 11/9/2012

Will <survey> always create its own data file?


Yes.


Or can I just have 1 data file that contains the data from the clock test and also that data from the survey?


Yes, you can. Run your <surveypage>s via a <block> element's /trials attribute.

By pprat - 11/9/2012

Thank you!

By pprat - 11/12/2012

Dave,


If we do not want to record data (i.e. for a training session), what do we use to set no data recording?  Or is data recording the default?


Thank you.

By Dave - 11/12/2012

By default Inquisit will record data -- a sensible default, I might add. To exclude certain elements from being recorded to the data file, set the respective /recorddata attribute to 'false' (see the documentation for details). Otherwise simply discard data from training sessions prior to analysis.