Welcome! Log In Create A New Profile

Advanced

Tasks Crashes after Updating to the Dec Version

Posted by binxu 
Tasks Crashes after Updating to the Dec Version
December 20, 2021 05:44PM
Hi Jaewon,

Recently my lab updated the Monkeylogic 2.2 to the Dec07 version.
But after the update, our previous scene-based tasks no longer work.
All the trials seem to be recognized as fails even if the monkey / mouse are fixating at the correct fixation point.
The failed experiments include

selectivity &
rfMapper

When we downgrade the ML2 to Nov or Oct release, this problem disappeared without any change of code.
So I think this is some compatibility issue of the recent update and these tasks.

Do you have a clue of why this might happen?
Thanks so much !

Best
Binxu, Oliva & Carlos
Attachments:
open | download - rfMapper_basic.txt (25 bytes)
open | download - rfMapper_basic.m (11 KB)
open | download - rfMapper_basic_userloop.m (7.6 KB)
Re: Tasks Crashes after Updating to the Dec Version
December 20, 2021 05:52PM
These are codes for the selectivity experiments.
It functions well on our machine using 2.2.19 version ,but not the 2.2.22 version.
Attachments:
open | download - selectivity_basic_userloop.m (8.4 KB)
open | download - selectivity_basic.m (7.8 KB)
open | download - selectivity_basic.txt (28 bytes)
Re: Tasks Crashes after Updating to the Dec Version
December 20, 2021 11:27PM
First of all, I cannot run the files because you did not include some functions and stimuli. Nevertheless, it is obvious why your scripts do not work as you want. You reassigned new objects to the variables, such as fix2, wth2 and wth3, multiple times in a loop and tried to access those objects with the same variable names later. Just like any numeric or char variable, those variables lose their old values once you assign new ones to them. Against your belief, the scripts were not working correctly in the old version, either. At least the new version shows you better what you need to fix.
Re: Tasks Crashes after Updating to the Dec Version
December 22, 2021 11:32AM
Hi Jaewon!

Thanks so much for your insight! we didn't expect that will be an issue.

I think you were mentioning this part of code below.
Before I believed that the `create_scene` copied `wth2` variable and `fix2` variable is copied in `WaitThenHold` initialization. So even if the variable changed in the next loop the previous value has been saved in the scene object.

But if these variables are not copied but just a reference is sent to `WaitThenHold` or `create_scene`, then as you said, in the next iteration, these variables value will change and the `sceneON` object will not store the correct value.
Then I believe the whole thing will be messed up.

So is it value copy or reference copy in `create_scene` and creation of nodes (like `WaitThenHold`).?

for iScene = 1:nPicsToShow
    % scene 2: image 1
    fix2 = SingleTarget(eye_);
    fix2.Target = fixation_point;
    fix2.Threshold = hold_radius;
    wth2 = WaitThenHold(fix2);
    wth2.WaitTime = 0;            % We already knows the fixation is acquired, so we don't wait.
    wth2.HoldTime = sample_time;
    sceneON{iScene} = create_scene(wth2,[fixation_point iScene]);
    
    %  delay
    wth3 = WaitThenHold(fix2);
    wth3.WaitTime = 0;
    wth3.HoldTime = delay;
    sceneOFF{iScene} = create_scene(wth3,fixation_point);
    
end % of iScene

BTW, if we just want to implement a good old fashion Rapid Serial Visual Presentation task, (monkey fixating, 4-5 different images come on and off in sequence)
Which of your examples should we adapt? I didn't really find a counterpart in the `examples` folder....

Thanks so much for your help Jaewon!

Best,
Binxu
Re: Tasks Crashes after Updating to the Dec Version
December 22, 2021 12:54PM
You misunderstood what was copied or referenced, but I am not teaching programming here and it is irrelevant anyway. The problem is in the next for loop where you check the results of each scene with wth2.Success and wth3.Success, because wth2 and wth3 are not the objects that you think they are anymore.
Re: Tasks Crashes after Updating to the Dec Version
December 22, 2021 03:02PM
I see! So your point is that the wth2.Success and wth3.Success are where the issue is.
So a preferred way to fix this without overwriting is to store the wth2 and wth3 in an array when creating them and check if each Success when `run_scene`?

    
    run_scene(sceneON{iScene},thisImage_code_on);     % Run the second scene (eventmarker 20)
    if ~wth2.Success          % If the WithThenHold failed,
        run_scene(endscene);  %     that means the subject didn't keep fixation on the sample image.
        trialerror(3);        % So this is the "break fixation (3)" error.
        return
    end
    
    run_scene(sceneOFF{iScene},thisImage_code_off);     % Run the third (delay) scene (eventmarker 30)
    if ~wth3.Success
        run_scene(endscene);
        trialerror(3);        % break fixation (3)
        return
    end

Best,
Binxu

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.