Skip to main page content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Access keys NCBI Homepage MyNCBI Homepage Main Content Main Navigation
. 2019 Jul 15:323:13-21.
doi: 10.1016/j.jneumeth.2019.05.002. Epub 2019 May 6.

NIMH MonkeyLogic: Behavioral control and data acquisition in MATLAB

Affiliations

NIMH MonkeyLogic: Behavioral control and data acquisition in MATLAB

Jaewon Hwang et al. J Neurosci Methods. .

Abstract

Background: Computerized control of behavioral paradigms is an essential element of neurobehavioral studies, especially physiological recording studies that require sub-millisecond precision. Few software solutions provide a simple, flexible environment to create and run these applications. MonkeyLogic, a MATLAB-based package, was developed to meet these needs, but faces a performance crisis and obsolescence due to changes in MATLAB itself.

New method: Here we report a complete redesign and rewrite of MonkeyLogic, now NIMH MonkeyLogic, that natively supports the latest 64-bit MATLAB on the Windows platform. Major layers of the underlying real-time hardware control were removed and replaced by custom toolboxes: NIMH DAQ Toolbox and MonkeyLogic Graphics Library. The redesign resolves undesirable delays in data transfers and limitations in graphics capabilities.

Results: NIMH MonkeyLogic is essentially a new product. It provides a powerful new scripting framework, has dramatic speed enhancements and provides major new graphics abilities.

Comparison with existing method: NIMH MonkeyLogic is fully backward compatible with earlier task scripts, but with better temporal precision. It provides more input device options, superior graphics and a new real-time closed-loop programming model. Because NIMH MonkeyLogic requires no commercial toolbox and has a reduced hardware requirement, implementation costs are substantially reduced.

Conclusion: NIMH MonkeyLogic is a versatile, powerful, up-to-date tool for controlling a wide range of experiments. It is freely available from https://monkeylogic.nimh.nih.gov/.

Keywords: Cognition; Human; Monkey; Neurophysiology; Psychophysics; Software.

PubMed Disclaimer

Figures

Figure 1.
Figure 1.
Detection of eye fixation in the previous scripting method and the scene framework. A. In the previous scripting method, the stimulus (fixation point) is turned on and off by toggleobject() and the target behavior (eye fixation) is monitored by eyejoytrack(). During eyejoytrack(), behavior samples are checked every millisecond. eyejoytrack() ends as soon as the fixation is detected, but the fixation point may not be turned off until the end of the next frame. B. In the scene framework, the presentation of the fixation point and the detection of eye fixation are processed in parallel by run_scene(). run_scene() repeats a cycle of analyzing behavior samples, drawing visual stimuli on a background buffer and presenting the buffer every frame. All the samples collected during the previous frame are analyzed together at the beginning of each frame. Therefore, the occurrence of the fixation may not be known until the next frame, although the time of the fixation can still be calculated online accurately.
Figure 2.
Figure 2.
An example task written with the scene framework. This is a working example that is executable in ML2. A video clip of this task and the complete task files are available at NIMH MonkeyLogic website. A. The fixation timer task. The total duration of fixation is indicated by the annulus-shaped counters that continuously change over time. The counter stops when the fixation is broken but resumes if the fixation is re-acquired within 4 s. B. The script for the fixation timer task. Three adapters are used and combined into a chain. Each adapter can be manipulated by changing its properties. The chain is executed via create_scene() and run_scene(). C. The cycle during run_scene(). Each adapter has two member functions: analyze() and draw(). run_scene() calls analyze() and draw() of the top-most adapter, the adapter given as an input argument to create_scene(), which triggers the iteration of all linked adapters. run_scene() repeats this cycle until analyze() of the top-most adapter returns false.
Figure 3.
Figure 3.
Analog input recordings with MATLAB DAQ Toolbox and NIMH DAQ Toolbox. The input signal was a 20-Hz sine wave and the sampling rate was 1 kHz. A. Due to the delay in sample transfers, MATLAB DAQ can check new samples only at a rate of ~67 Hz during the logging-mode recordings, which results in aliasing (see the main text). The buffer size was adjusted so that the sample transfers could occur as frequently as possible. B. NIMH DAQ Toolbox retrieves new samples at any time requested even in the logging mode and shows no aliasing. C. The number of available samples increases by 1 every millisecond in NIMH DAQ Toolbox, whereas it increases by 15 every 15 milliseconds in MATLAB DAQ Toolbox. D. The temporal cost of checking the current input state as a function of the number of channels.
Figure 4.
Figure 4.
Sampling intervals of the Windows software timer. The samples are collected for 100 trials. The bin size is 0.1 ms.
Figure 5.
Figure 5.
Screenshots of NIMH MonkeyLogic (ML2). A. The subject’s screen. B. The experimenter’s screen. MonkeyLogic Graphics Library (MGL) displays visual stimuli on both screens in parallel but overlays task-related information (fixation window, eye trace, button input, user text, etc.) on the experimenter’s screen only. It supports transparent colors so that the visual stimuli can be overlapped.

References

    1. Acquiring high-resolution time stamps [WWW Document], 2018. Microsoft Docs. URL https://docs.microsoft.com/en-us/windows/desktop/SysInfo/acquiring-high-... (accessed 12.6.18).
    1. Asaad WF, Eskandar EN, 2008a. A flexible software tool for temporally-precise behavioral control in Matlab. J. Neurosci. Methods 174,245–58. 10.1016/j.jneumeth.2008.07.014 - DOI - PMC - PubMed
    1. Asaad WF, Eskandar EN, 2008b. Achieving behavioral control with millisecond resolution in a high-level programming environment. J. Neurosci. Methods 173, 235–40. 10.1016/j.jneumeth.2008.06.003 - DOI - PMC - PubMed
    1. Asaad WF, Santhanam N, McClellan SM, Freedman DJ, 2012. High-performance execution of psychophysical tasks with complex visual stimuli in MATLAB. J. Neurophysiol 249–260. 10.1152/jn.00527.2012 - DOI - PMC - PubMed
    1. Brainard DH, 1997. The Psychophysics Toolbox. Spat. Vis 10, 433–6. - PubMed

Publication types

MeSH terms