Welcome! Log In Create A New Profile

Advanced

Change AdapterParameters Within Trial

Posted by MoonL 
Change AdapterParameters Within Trial
June 14, 2023 04:17AM
Hi,
I need to change the fixation window size during a trial, which can last up to 200 seconds for an fMRI scan. Breaking the trial to make this change would require stopping the scan, which is expensive. Therefore, I modified the singletarget so that we can adjust the window threshold during a scene using a hotkey:
hotkey('i', "fix1.WaitForChange = 1; fix1.ChangeVal = 1;");
hotkey('o', "fix1.WaitForChange = 1; fix1.ChangeVal = -1;");

I hope this information is helpful to anyone who needs it smiling smiley
Attachments:
open | download - ChangeableSingleTarget.m (7.8 KB)
Re: Change AdapterParameters Within Trial
June 15, 2023 07:50PM
Thanks for sharing the adapter. I just have a couple of suggestions.

You wrote your addition right on the code of an existing adapter. This can cause a problem, because the interfaces of an adapter (i.e., the names of properties and methods) may be preserved during updates but the code lines are not. If the adapter that your work was based on is rewritten in a new ML version, your adapter may become incompatible. Indeed, SingleTarget has been changed a couple of times already from the version you used. The better practice is to inherit the interfaces of SingleTarget rather than copy its code.

I think some codes are redundant in your implementation and can be simplified. For example, WaitForChange and ChangeVal can be combined into one variable that indicates both value change and value amount. Also, a new fix window graphic is created automatically when a new value is assigned to the Threshold property, so many graphic-related codes you added are not necessary.

I tried modifying your adapter. Please take a look at the attached file. The hotkey definitions need to be changed like the following.
hotkey('i', "fix1.ChangeVal = change_step;");
hotkey('o', "fix1.ChangeVal = -change_step;");
change_step = 1.05;
editable('change_step');
Attachments:
open | download - ChangeableSingleTarget.m (718 bytes)
Re: Change AdapterParameters Within Trial
June 17, 2023 02:53AM
Hi Jaewon:
Thank you for your valuable suggestions and modifications! I apologize for the redundancy caused by my unfamiliarity with class inheritance. I have already tried implementing your suggestions and incorporated them into my code. Thank you!

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.