Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #1 
I'm aware of the user_text function to display text on the control screen...but I was curious if there is a function to display a text string as a taskobject on the stimuli screen.

We are trying to display per-trial reward and cumulative reward after each trial.

Thank you!
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #2 
Does the subject need to see this string? It sounds like you need this for a display purpose, not for a tracking target.
0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #3 
The subject would read the string after the trial to understand how much reward they earned. A simple string denoting the value (e.g. '20') would be all we would need.
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #4 
I would like to make a permanent solution, but you can do it by calling MGL functions directly, if you are using ML2.

----- beginning of timing file -----
per_trial = 0.2;
cumulative = 3.6;

str1 = mgladdtext(sprintf('Per trial: %g',per_trial));
str2 = mgladdtext(sprintf('Cumulative: %g',cumulative));

% * Text property
% origin: [x y] in screen coordinates, The left-top corner of the screen is [0 0].
% 'normal', 'bold', 'italic', 'underline', 'strikeout'
% text: To replace the existing text
% halign, valign: 1, left (or top), 2, center (or middle), 3, right (or bottom)
mglsetproperty(str1,'origin',[100 100],'bold','fontface','Arial','fontsize',20,'color',[1 0 0]);
mglsetproperty(str2,'origin',[100 200],'italic','fontface','Time New Roman','fontsize',30,'color',[0 1 0]);

idle(1000);

mgldestroygraphic([str1 str2]);  % You must destroy MGL objects when you are done
----- end of timing file -----
0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #5 
Thanks Jaewon!
0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #6 
Hey Jaewon -

I'm having a little trouble displaying white text on my screen. I tried to do so using the following code in my timing file:

 

Code:

% Showing score from last trial
percent = 100;
str1 = mgladdtext(sprintf('%g percent', round(percent)));

% * Text property
% origin: [x y] in screen coordinates, The left-top corner of the screen is [0 0].
% 'normal', 'bold', 'italic', 'underline', 'strikeout'
% text: To replace the existing text
% halign, valign: 1, left (or top), 2, center (or middle), 3, right (or bottom)
mglsetproperty(str1,'origin',[100 100],'normal','fontface','Arial','fontsize',20,'color',[1 1 1]);
idle(1000);
mgldestroygraphic([str1]);

 
When I try to run this, the task simply idles, and I've confirmed that these lines are being executed. However, no text appears on the subject screen.

Any thoughts?

Thanks,
Pete
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #7 
Your code works fine on my computer.

100.png

Can you try it again with the latest package? I initially made the object to display text on the control screen, so probably had to change something to show it on both monitors, but do not remember when I changed things.

http://forums.monkeylogic.org/post/nimh-monkeylogic-2-8444337?trail=175

0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #8 
Hi Jaewon -

I've updated monkeylogic (2018-01-29), and I see the text on the control screen. However, it is still not appearing on the subject screen. I've tried entering different 'device' arguments (1,2,3) to mgladdtext(), but still cannot get the text to display on the subject screen.

Is there another option to modify?

Thank you,
Pete
0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #9 
A little more information - this is a two-monitor setup (one subject, one control). I've tried swapping which monitor is the subject/control, but that does not seem to work either.
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #10 
The 'device' argument should be 3, if you want it to show up on both screens. It should not matter whether you use two monitors or not.

Would you try the attached task? It is the same task as yours. I just moved the text to the center of the screen and added a red circle behind the text. Can you let me know whether you see them or not?

 
Attached Files
zip test.zip (571 Bytes, 1 views)

0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #11 
Thank you Jaewon - that task by itself works on my computer. However, if I place this code into my task, the objects still do not appear. I worry that another TaskObject is interfering with the display of these objects...I'll start debugging a bit.

Many, many thanks for your help.

Pete
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #12 
If you send me the full version of the code, I can take a look.
0
pmlauro

Junior Member
Registered:
Posts: 10
Reply with quote  #13 
Hey Jaewon -

Once I replaced a movie-TaskObject with a static picture-TaskObject, the text display worked! Thank you for all of your help.

Pete
0
Jaewon

Administrator
Registered:
Posts: 708
Reply with quote  #14 
It should not matter whether you use a movie or not. I am still wondering how your code works.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.