Welcome! Log In Create A New Profile

Advanced

Delay Property Issue in TimeCounter and TTLOutput 2

Posted by younesvalibeigi 
Delay Property Issue in TimeCounter and TTLOutput 2
February 23, 2025 11:59PM
Hi,

Earlier, I asked a question regarding sending a TTL signal with a delay. I am using the following code:

ttl1 = TTLOutput(wth2);
ttl1.Port = 1;  % TTL #1 must be assigned in the I/O menu
ttl1.Delay = delay_microstim1;
tc1 = TimeCounter(ttl1);
tc1.Duration = 50; % I changed this from 100 to 50 to match the microstim duration
%tc1.Delay = delay_microstim1;
sceneStim1 = create_scene(ttl1, [fixation_point sample]);



I checked my recording data, and it seems that the TTL is being sent exactly at the same time the scene is being run. I am unsure how to introduce a proper delay for the TTL signal.

I have attached my code for reference. I define the TTL in the same way for three different scenes, but none of them show the expected delay in the recording data.

Would you be able to assist me with this issue?
Attachments:
open | download - dms.m (14.1 KB)
Re: Delay Property Issue in TimeCounter and TTLOutput 2
February 24, 2025 08:06PM
I see where the manual was not written clearly. You should set the duration of TTLOutput, like the following.
ttl1.Duration = 50;
Re: Delay Property Issue in TimeCounter and TTLOutput 2
February 24, 2025 09:00PM
Hi Jaewon,

Thanks for pointing that out.

The issue is that the delay was never actually applied. When I keep the code like this:

ttl1 = TTLOutput(wth2);
ttl1.Port = 1; % TTL #1 must be assigned in the I/O menu
ttl1.Delay = 50;
sceneStim1 = create_scene(ttl1, [fixation_point sample]);


I did not see the TTL being received with the delay in my recorded data.

It seems that the Duration property must be assigned for the Delay to work. I checked it with two TTL signals to see if the delay was applied, and I found that the delay is only applied if I assign the Duration. Otherwise, no delay is applied.

ttl2 = TTLOutput(wth2);
ttl2.Port = [1 3]; % TTL #1 must be assigned in the I/O menu
ttl2.Duration = [100 100]
ttl2.Delay = [50 1];
sceneStim2 = create_scene(ttl2, [fixation_point sample]);


However, the problem is that the above code somehow breaks my DMS code—it won’t let wth2 finish.

I have been trying to figure this out for a while, but it seems that TTLOutput somehow interferes with the code when specific Delay and Duration values are assigned.

Would you have any insight into this issue? Thank you.

I have attached my code for reference. TTL2 should apply for conditions between 56 and 84 in case you want to run it yourself.
Attachments:
open | download - dms.m (14.9 KB)
Re: Delay Property Issue in TimeCounter and TTLOutput 2
February 24, 2025 11:14PM
Read this manual page carefully.
https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#HowToCreateAdapterChains

In your code, TTLOutput is the topmost adapter, which means that the scene ends when TTLOutput stops. If fixation was the behavior you wanted to acquire in the scene, you should have made WaitThenHold the topmost adapter.

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.