Millisecond Forums

Switching parts of the code included for eye-tracker ON and OFF using a variable

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

By nidhi_desai - 12/16/2020

I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 
By Dave - 12/16/2020

nidhi_desai - 12/16/2020
I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 

It's not possible to build such a switch per se. It *may* be possible to do something with <include>, namely switching the <port> elements out for placeholder <text> elements in the non-eyetracker version. Whether that's possible depends on the code as a whole, though. Provide the script and any files it requires to run by attaching it to a reply here and I can tell you whether that's feasible or not.
By nidhi_desai - 12/16/2020

Dave - 12/16/2020
nidhi_desai - 12/16/2020
I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 

It's not possible to build such a switch per se. It *may* be possible to do something with <include>, namely switching the <port> elements out for placeholder <text> elements in the non-eyetracker version. Whether that's possible depends on the code as a whole, though. Provide the script and any files it requires to run by attaching it to a reply here and I can tell you whether that's feasible or not.

Thank you for your reply. Here is a sample of code which I want to have a switch for. experiment1.iqx is the main code and eyetracker_setup.iqx has the idea which I was mentioning for having a switch. If you see the main concern is having port.portET.setitem in the main code which makes it not possible to switch.
By Dave - 12/16/2020

nidhi_desai - 12/16/2020
Dave - 12/16/2020
nidhi_desai - 12/16/2020
I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 

It's not possible to build such a switch per se. It *may* be possible to do something with <include>, namely switching the <port> elements out for placeholder <text> elements in the non-eyetracker version. Whether that's possible depends on the code as a whole, though. Provide the script and any files it requires to run by attaching it to a reply here and I can tell you whether that's feasible or not.

Thank you for your reply. Here is a sample of code which I want to have a switch for. experiment1.iqx is the main code and eyetracker_setup.iqx has the idea which I was mentioning for having a switch. If you see the main concern is having port.portET.setitem in the main code which makes it not possible to switch.

setitem() you should be able to get rid of by refactoring the code a little bit. With that done, the include approach should be workable, see attached.
By nidhi_desai - 12/22/2020

Dave - 12/16/2020
nidhi_desai - 12/16/2020
Dave - 12/16/2020
nidhi_desai - 12/16/2020
I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 

It's not possible to build such a switch per se. It *may* be possible to do something with <include>, namely switching the <port> elements out for placeholder <text> elements in the non-eyetracker version. Whether that's possible depends on the code as a whole, though. Provide the script and any files it requires to run by attaching it to a reply here and I can tell you whether that's feasible or not.

Thank you for your reply. Here is a sample of code which I want to have a switch for. experiment1.iqx is the main code and eyetracker_setup.iqx has the idea which I was mentioning for having a switch. If you see the main concern is having port.portET.setitem in the main code which makes it not possible to switch.

setitem() you should be able to get rid of by refactoring the code a little bit. With that done, the include approach should be workable, see attached.

Thank you for your previous solution. In my experiment, the value of the marker sent to eyetracker changes based on the response during the experiment. I don't have a set of numbers that can be sent to the eyetracker, so your solution won't be helpful. I tried having /items = (values.markerET) in the eyetracker port (codes are attached) but this gives me an error "-1 is invalid. Value must greater than 0." I checked my code the markerET values are always set to a value of 0 or greater, so I am not sure the source of this error. Could you suggest how might I resolve this error and/or have something like values.markerET as a port item. 

Also, I don't think port.portET.setitem(values.markerET) would be helpful as portET is either a port or a text element based on parameters.includeEyetracker being true or false.
By Dave - 12/22/2020

nidhi_desai - 12/22/2020
Dave - 12/16/2020
nidhi_desai - 12/16/2020
Dave - 12/16/2020
nidhi_desai - 12/16/2020
I am looking to record eye-tracking with my behavioral experiment. But as I debug the code when I am not connected to a computer with eye-tracker setup, I need a method for switching the parts of my codes related to eye-tracker OFF using a variable values.includeEyetracker = 1 or 0. Is there a way to do this, since the markers that I send to eye-tracker are ports that are added as stimuli in the corresponding trials?  

My idea for solving this problem was to have a separate file with the eye-tracker setup which includes the ports for markers to be sent to eye-tracker and using <include> and insertstimulusframe insert these into the main trials. But the issue is that I need the eye-tracker port to dynamically change its value as the experiment is run. I saw the example on Inquisit of building a dynamic marker and then doing setitem. If I do this the main code gives an error when values include.Eyetracker is set to 0 and the other file where the eyetracker setup and ports were defined is not included. So the main code does not find the port which the code would setitem only if values.includeEyetracker = 1. Is there a work around this? Or any other method of having switch in the code to turn the codes for eye-tracker on or off. 

It's not possible to build such a switch per se. It *may* be possible to do something with <include>, namely switching the <port> elements out for placeholder <text> elements in the non-eyetracker version. Whether that's possible depends on the code as a whole, though. Provide the script and any files it requires to run by attaching it to a reply here and I can tell you whether that's feasible or not.

Thank you for your reply. Here is a sample of code which I want to have a switch for. experiment1.iqx is the main code and eyetracker_setup.iqx has the idea which I was mentioning for having a switch. If you see the main concern is having port.portET.setitem in the main code which makes it not possible to switch.

setitem() you should be able to get rid of by refactoring the code a little bit. With that done, the include approach should be workable, see attached.

Thank you for your previous solution. In my experiment, the value of the marker sent to eyetracker changes based on the response during the experiment. I don't have a set of numbers that can be sent to the eyetracker, so your solution won't be helpful. I tried having /items = (values.markerET) in the eyetracker port (codes are attached) but this gives me an error "-1 is invalid. Value must greater than 0." I checked my code the markerET values are always set to a value of 0 or greater, so I am not sure the source of this error. Could you suggest how might I resolve this error and/or have something like values.markerET as a port item. 

Also, I don't think port.portET.setitem(values.markerET) would be helpful as portET is either a port or a text element based on parameters.includeEyetracker being true or false.