Welcome! Log In Create A New Profile

Advanced

Index in position 1 exceeds array bounds

Posted by chaoyi_zhang 
Index in position 1 exceeds array bounds
July 30, 2025 09:54PM
Hi Jaewon,

I recently encountered such an error when my animal was running with a lick-sensor-based task. Which happened pretty randomly, sometimes happened a few trials after start, sometimes happened after 30 minutes.

Here is the Bug report from MATLAB:

<<< MonkeyLogic >>> Index in position 1 exceeds array bounds. Index must not exceed 7544. (GNG_P2_P3_novisual_runtime/end_trial, Line 907)
Index in position 1 exceeds array bounds. Index must not exceed 7544.

Error in GNG_P2_P3_novisual_runtime/end_trial (line 907)
TrialData.AnalogData.Button.(sprintf('Btn%d',ml_))=DAQ.Button{ml_}(ml_SamplePoint,smiling smiley;
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in GNG_P2_P3_novisual_runtime (line 1312)
end_trial();
^^^^^^^^^^^
Error in run_trial (line 132)
        runtime(MLConfig,TrialRecord,TaskObject,TrialData);
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in monkeylogic/UIcallback (line 919)
                    result = run_trial(MLConfig,datafile);
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
Error while evaluating UIControl Callback.


AND below is my task runtime code (I added a touch sensor to button_1, and there is 3s response window)

pc = PulseCounter(button_)
pc.Button = 1; % Button #1 

od = OnsetDetector(pc);

tc3 = TimeCounter(null_);
tc3.Duration= 3000;


or = OrAdapter(tc3);
or.add(od);


scene3= create_scene(or);


Thanks in advance for any feedback.
Re: Index in position 1 exceeds array bounds
July 31, 2025 02:25PM
Update your NIMH ML if you are not using the latest version.
Re: Index in position 1 exceeds array bounds
July 31, 2025 03:01PM
I did it. But still have the same error.

Is there any other possibility?
Re: Index in position 1 exceeds array bounds
July 31, 2025 04:38PM
If you could replicate the error within 30 minutes, there must be something in your test environment. Please explain how you tested. Were you running a real experiment or simulation?
Re: Index in position 1 exceeds array bounds
July 31, 2025 05:33PM
I'm running it in a real environment, not a simulation. I'm using my finger to mimic licking the metal reward straw, which is connected to a touch sensor assigned to Button 1.

Thanks!
Re: Index in position 1 exceeds array bounds
July 31, 2025 06:59PM
If you have a data file from the interrupted session, can you send it to me?
Re: Index in position 1 exceeds array bounds
August 08, 2025 07:15PM
It turned out that there were undeleted, old copies of NIMH ML on the disk and they were being executed inadvertently in this case.

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.