Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #1 
Can anyone explain how and why user programmed timing files are "embedded" and a run-time variant is generated. Also, what is the trialholder.asv meant to do?
0
Wael.Asaad

Administrator
Registered:
Posts: 51
Reply with quote  #2 
Originally, we found that the first time Matlab loaded functions into memory, there would be small delays in task execution (several milliseconds, typically, but sometimes 10s of milliseconds).  Our first step around this was to "embed" the timing file code into a larger function that included all the sub functions, so there wouldn't be any delays loading these as the task ran (e.g., upon the first call to toggleobject or eyejoytrack).  This helped a fair amount, but there were still some delays, which is why we included the initialization trial (the first trial always runs much more slowly than subsequent ones).  

Given successive advances in processor, memory and storage access times, it may no longer be necessary to have "embedded" timing scripts into these runtime functions.  Certainly would make it easier to debug a single function, rather than have errors point to spots in the runtime function that then are fixed by editing the separate timing script...

0
Jaewon

Administrator
Registered:
Posts: 971
Reply with quote  #3 
I used to do DirectX programming and had the same issue that the first presentation of an image or a sound was delayed by tens of milliseconds. I assumed that it was a delay of loading DirectX DLLs, because I did not see the delay while the DLLs were in the memory. To avoid the delay, I also included some initialization step, like flipping a transparent image and playing a mute wav, and it worked fine.

I don't think embedding timing scripts into the runtime is a bad idea. MATLAB is an interpreter language, so there must be some unavoidable delay when scripts are loaded, as in the case of loading DLLs. Unless there is any other way to make MATLAB load all those scripts into the memory before a trial begins, maybe putting them together into a runtime file is the best practical way to prevent the delay.
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #4 
This adds a lot of complexity. Good to document why this was done and how it works.
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #5 
Related to this, I'm a little puzzled by when/how ML loads or reloads a timing script. Ostensibly, right after I load a conditions file (which specifies the name of the timing file), the timing file should get loaded. However, if I make any modifications to my timing script there after, even if I reload the conditions file, the timing script is not reloaded unless I restart ML entirely.

What am I missing/doing wrong?
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #6 
It appears that embedtimingfile is called in monkeylogic.m line 221 each time the runbutton is pressed. But changes in the timing file are not reflected during execution of the task unless I restart ML.
0
Wael.Asaad

Administrator
Registered:
Posts: 51
Reply with quote  #7 
We were having that problem, so we included code to delete and then re-write the runtime file in hopes this would force it to update.  I'm not certain which factors determine when a file is actually updated, and why it doesn't do so immediately when we ask it to...

0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #8 
okay, thanks for the sanity check. I will try to fix this...
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #9 
I think this is one of the most annoying issues. I find myself editing timing files constantly, and having to reload matlab for the changes to take affect is slower than recompiling a large C program! We need to fix this ASAP. This, along with the lack of easy break point tracing, negates all the advantages of using Matlab.
0
Edward

Administrator
Registered:
Posts: 260
Reply with quote  #10 
I have been investigating embedtimingfile.m and want to say that I find this program to be an absolute marvel. I'm wondering if the logic contained therein is robust enough to handle any timing file. I never studied syntactic parsing/analysis so I'm wondering if the rules you implemented in this program are based on some published protocol or did you brute force it? Either way, it's really cogent. Just that it seems like a LOT of work to nail the correct procedure down.
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.