Welcome! Log In Create A New Profile

Advanced

Taking subject input via keyboard.

Posted by Somesh 
Taking subject input via keyboard.
March 17, 2025 10:36AM
Hi, I have a task where the subject sees a certain arrangement of numbers (image in the attachment) with a solid circle graphic tracing the periphery of the arranged number. Once the space bar key is pressed, I want the subject to report the selected number by entering the number in the input dialogue box presented on the 'subject screen' (i.e. second screen), which gets recorded in the ML by pressing the enter key.
I have gone through ML adapters(v2) and runtime variables commands, but I could not figure out a suitable command to meet my requirements.
I also tried to use Matlab's 'inputdlg' command to generate the input dialogue box (mentioned in the timing file code); however, the input dialogue box occurs behind the experimenter's window (which ideally should pop on the subject screen), and I am unable to access it. The task freezes until the input dialogue box is forced closed.

Please let me know any possible adapters or commands to apply to suffice my requirement.
Attachments:
open | download - 0degrees.png (27.1 KB)
open | download - 90degrees.png (26 KB)
open | download - 180degree.png (27 KB)
open | download - 270degrees.png (40.5 KB)
open | download - userloop_aim_test.m (1.3 KB)
open | download - single_trgnojump_aim_report.m (2.6 KB)
Re: Taking subject input via keyboard.
March 18, 2025 06:42PM
I took the liberty of moving the timing script to the attachments. I have a few questions.

1. Is pressing the space bar the act of selecting a number? What should be displayed on the screen, when the subject enters the number?

2. Do you need to know the time when the enter is pressed?

3. Other than space, numbers and enter, what keys can the subject type?
Re: Taking subject input via keyboard.
March 19, 2025 05:16AM
Thanks, Jaewon. The following are the replies to your query.

1. Yes, the subjects are informed to press the key when the revolving circle around the graphics reaches their desired number. The screen should go blank once they press the spacebar, and an input dialogue box should appear. By pressing the enter key, they should confirm their responses.

2. No timing information on the key press is needed; if needed, I could use event markers, I guess?

3. The entire keyboard is at the deploy; just for the sake of simplicity, I chose the space bar for their readiness to report, the numpad keys for their response (as I want numeric response for the task), and the enter key for their confirmation of the choice.

Another variation of the proposed task I could think of is to remove the entire curve tracing component (which seems redundant anyway, as I don't require timing information anymore) and show the required images for sufficient time. An input dialog box appears once the image scene is completed (or we could stop it with any key press if the subject is ready to response). The input dialogue box appears, and they can input the desired response and confirm the choice by the key press.

Please let me know if anything else is needed from my end.

Thanks again.
Re: Taking subject input via keyboard.
March 19, 2025 09:05PM
I modified your task with a custom adapter. See the attached zip file. Before running the task, update your NIMH ML to the latest version.

If you need to know exactly when the number was reported, you should record the status of the Enter key, as you do the Space bar. If you use just eventmarkers, you cannot avoid a 10-20 ms delay because sample analysis is done frame by frame in the scene framework. After all, eventmarkers are sent only after something already happened.
https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#RuntimeVersion2_Background
Attachments:
open | download - Somesh.zip (113 KB)
Re: Taking subject input via keyboard.
March 21, 2025 06:57AM
Hi Jaewon, thanks for the custom adapter; I followed your instructions, and the required task (taskA) worked perfectly.

A few things to report: when I run other tasks ( say, taskB ), the following errors appear.

Unrecognized property 'KeyStroke' for class 'RunSceneParam'.

Error in Single_trgnojump_runtime/run_scene (line 192)
param_.KeyStroke=kbdgetkey;

Error in Single_trgnojump_runtime/warming_up (line 1135)
run_scene(ml_s);

Error in Single_trgnojump_runtime (line 1217)
warming_up();[/i]

Error in run_trial (line 129)
        runtime(MLConfig,TrialRecord,TaskObject,TrialData);

Error in monkeylogic/UIcallback (line 919)
                    result = run_trial(MLConfig,datafile);
 
Error while evaluating UIControl Callback.


Following are the steps I did in debugging:
1. I moved the 'RunSceneParam.m' copy to the ML installation path; the error occured.
2. I added the taskA folder to the Matlab directory (by set path); the error persisted.
3. I moved the 'RunSceneParam.m' copy to the taskB folder, and the taskB worked.

Further, the ML example task also produced the same errors (unless I executed step 3).

I guess I must add a 'RunSceneParam.m' copy to each task folder to avoid these errors?

Is there any better solution you could provide?


Also, other errors appeared while using ML Player.
Unrecognized method, property, or field 'nKey' for class 'mldaq_playback'.

Error in KeyChecker/set.KeyNum (line 20)
            if keynum<1 || obj.Tracker.DAQ.nKey<keynum, error('KeyNum must be 1-%d.',obj.Tracker.DAQ.nKey); end %#ok<*MCSUP>

Error in mladapter/import (line 56)
                obj.(fn{m}) = val{idx,2};

Error in mlplayer/reconstruct_adapter (line 403)
                            o.import(args{m});

Error in mlplayer/reconstruct_adapter (line 378)
                    s = cell(1,ns); for n=1:ns, s{n} = reconstruct_adapter(args{m}{n}.AdapterList,args{m}{n}.AdapterArgs); end

Error in mlplayer/reconstruct_adapter (line 378)
                    s = cell(1,ns); for n=1:ns, s{n} = reconstruct_adapter(args{m}{n}.AdapterList,args{m}{n}.AdapterArgs); end

Error in mlplayer/render_scene (line 326)
                        scene = reconstruct_adapter(adapter,args);

Error in mlplayer/UIcallback (line 948)
                        render_scene();
 
Error while evaluating UIControl Callback.


Thanks again.
Re: Taking subject input via keyboard.
March 24, 2025 10:40PM
You need a new version of NIMH ML, but I am still working on it. Please be patient.
Re: Taking subject input via keyboard.
March 27, 2025 07:40AM
Ok, Understood.

Thanks again.
Re: Taking subject input via keyboard.
July 09, 2025 03:51PM
Hi, I was wondering if this issue was fixed yet or not? I am experiencing the same issue.

This post says a new version of Monkey Logic is needed to fix this. Has this version been released yet? No pressure, just gathering information.

If it has been fixed and this is potentially a new, maybe related, issue, I can provide more information.

Thank you!
Re: Taking subject input via keyboard.
July 09, 2025 06:50PM
There was no issue. Somesh's problem was because he did not copy a necessary file to his new task.

Later I incorporated the file into the ML package and removed it from the task attached above, so now you need to update your NIMH ML to run the above task.

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.