New to MWorks questions

ereming's Avatar

ereming

30 Jun, 2014 02:18 PM

Hi,

I've been keeping a list of questions as I've been building a few of my current experiments in MWorks over the past week or so. Here are the ones I haven't been able to answer on my own yet. This is written as if it's an email to Chris, but if anyone else has answers I'll be very grateful! I'm still working on them, so I may delete some of these:

Selection variables:
-What is a selection object? I get the idea of selection variables, and I've read that Blocks and Tasks can do the same things, are they also considered selection objects?

-In the calibration routine you (Chris) wrote for me, you used a "next selection" action before using the variable for the first time, and it doesn't have a problem with hitting the end too early. I am having that problem in a different program. It seems like the a selection variable starts at the first choice, and the first call of "next selection" moves it to the second. The only difference I can think of is that I'm using a task system whereas you used a Trial component.

-Do I ever need to accept a selection? Is it bad practice to just ignore the accept/reject concept if I'm not going to ever have "do-overs?"

-It seems that "advance on accept" and "autoreset" don't play nice.

-"sequential" doesn't seem to work as a choice for the "selection" property, which is odd considering it is the default. I’m assuming I’m doing something wrong, but I haven’t misspelled it or anything.

General MWorks questions
-Is angle interpreted as degrees or radians? It seems like it's different in different places. For example, "rotation" in rectangle stimulus seems to be interpreted in degrees, while trigonometric functions are interpreted in radians.

-What exactly does stop and start do? It doesn't seem to re-initialize variables (e.g. reset selection variables). Can I dequeue all stimuli at once?

I/O Devices
-If Eye Cal is an I/O device, why doesn't it need to be started?

-Fake monkey error:

WARNING: Scheduled task (/Users/mwdev/Documents/mworks_buildbot/slave/build_all/build/plugins/core/.dicarlolab_mwcore_plugins/FakeMonkeyPlugin/FakeMonkey.cpp:137: eye movement channel) not on time (off by 5228; task = 0x7fdfa7ef2b70; priority=95)

Specific functionality
-Are there min() and max() functions? Are there any functions that aren't listed in the knowledge base? Can we create our own functions? Is this the sort of thing that the Matlab/Python bridges are intended for?

-Can variables be defined as expressions that don’t need to be manually assigned? Again, maybe this is something for Matlab/Python.

-Can I get the max screen size values?

-How do I know what task system state a program is currently in? Is this available somewhere in the client?

Data Analysis:
-I'm not sure what I need to do to analyze data files. I've downloaded the /mworks/tools/matlab directory, but when I try to build the mex files in Matlab I'm getting errors. For example:

mex getEvents.cpp
Building with 'Xcode Clang++'.
Error using mex
In file included from /Users/Evan/Documents/MWorks/mworks/tools/matlab/MEXFile/getEvents.cpp:9:
In file included from /Users/Evan/Documents/MWorks/mworks/tools/matlab/MEXFile/getEvents.h:12:
/Users/Evan/Documents/MWorks/mworks/tools/matlab/MEXFile/MEXInputs.h:16:10: fatal error: 'boost/filesystem/path.hpp' file not found
#include ^ 1 error generated.

Is there an instructional document that I'm missing for how to get these files installed?

  1. Support Staff 1 Posted by Christopher Sta... on 02 Jul, 2014 01:39 PM

    Christopher Stawarz's Avatar

    Hi Evan,

    I'm not sure what I need to do to analyze data files. I've downloaded the /mworks/tools/matlab directory, but when I try to build the mex files in Matlab I'm getting errors.

    The MWorks installer installs the MATLAB tools, so you don't need to build them yourself. For a demo of how to unpack a data file, see this discussion.

    My apologies for not responding to you sooner -- it's been a busy week. I'll try to answer the rest of your questions in the next day or two.

    Cheers,
    Chris

  2. 2 Posted by ereming on 02 Jul, 2014 02:34 PM

    ereming's Avatar

    Hi Chris,

    Thanks for the pointer. I tried running the program from that discussion and I'm being told that the file doesn't exist (which I then check to make sure it does).

    >> printEvents('Intercept2ClickBlocks.mwk')
    Error using mwfeval
    File "Intercept2ClickBlocks.mwk" does not exist

    Error in getEvents>@()mworks.mwfeval(mfilename,filename,codes,mintime,maxtime) (line 38)
    f = @() mworks.mwfeval(mfilename, filename, codes, mintime, maxtime);

    Error in getEvents (line 41)
        events = f();

    Error in getCodecs (line 6)
    for evt = getEvents(filename, 0)

    Error in printEvents (line 5)
    codec = getCodecs(filename);
     
    38 f = @() mworks.mwfeval(mfilename, filename, codes, mintime, maxtime);
    >> exist('Intercept2ClickBlocks.mwk','file')

    ans =

         2

  3. Support Staff 3 Posted by Christopher Sta... on 02 Jul, 2014 02:46 PM

    Christopher Stawarz's Avatar

    I tried running the program from that discussion and I'm being told that the file doesn't exist (which I then check to make sure it does).

    printEvents('Intercept2ClickBlocks.mwk')

    Is the file in MATLAB's current working directory? If not, you'll need to specify the path to it (either absolute or relative to the working directory).

    Chris

  4. 4 Posted by ereming on 02 Jul, 2014 02:54 PM

    ereming's Avatar

    Nope, that fixed it. I assumed it would do the standard search of the Matlab path. Thanks Chris.

  5. Support Staff 5 Posted by Christopher Sta... on 03 Jul, 2014 03:09 PM

    Christopher Stawarz's Avatar

    Selection variables:

    What is a selection object? I get the idea of selection variables, and I've read that Blocks and Tasks can do the same things, are they also considered selection objects?

    Selection variables, Protocols, Blocks, Trials, and Lists are all what MWorks calls selectable objects. They all support the same accept/reject/reset actions. However, only selection variables support the "Next Selection" action; for the others, advancing the selection takes place automatically.

    In the calibration routine you (Chris) wrote for me, you used a "next selection" action before using the variable for the first time, and it doesn't have a problem with hitting the end too early. I am having that problem in a different program.

    I don't have the routine I wrote in front of me, but I suspect the difference is that I call "reset selections" at the start of the trial. Selection variables do try to be helpful and automatically make the first selection (although exactly when and why that happens is a little confusing), but I find that behavior to be more problematic than helpful, so I usually do a reset before attempting to use one.

    Do I ever need to accept a selection? Is it bad practice to just ignore the accept/reject concept if I'm not going to ever have "do-overs?"

    No, you can safely ignore accept/reject if they aren't useful to you.

    It seems that "advance on accept" and "autoreset" don't play nice.

    I see what you're saying, although I'm not sure when you would want to use them together. Moreover, I think "autoreset" is of dubious value altogether.

    Is there a specific use case you were thinking of here, or were you just messing around with the options?

    "sequential" doesn't seem to work as a choice for the "selection" property, which is odd considering it is the default. I’m assuming I’m doing something wrong, but I haven’t misspelled it or anything.

    No, that's a bug, and it looks like it's been there for years. I'm not sure how no one else noticed until now, but I'll fix it. Thanks!

  6. Support Staff 6 Posted by Christopher Sta... on 03 Jul, 2014 03:30 PM

    Christopher Stawarz's Avatar

    General MWorks questions:

    Is angle interpreted as degrees or radians? It seems like it's different in different places.

    With the exception of the trigonometric functions, I believe MWorks uses degrees everywhere.

    What exactly does stop and start do? It doesn't seem to re-initialize variables (e.g. reset selection variables). Can I dequeue all stimuli at once?

    I assume you mean stopping and restarting the experiment. When the experiment is stopped,

    • all queued stimuli are dequeued,
    • all playing dynamic stimuli (e.g. drifting grating, movie) are stopped, and
    • all I/O devices are stopped.

    Variables are initialized only once, at load time. If you intend to run multiple protocols (or the same protocol more than once) between reloads, you'll need to reset variable values as part of the protocol.

  7. Support Staff 7 Posted by Christopher Sta... on 03 Jul, 2014 04:26 PM

    Christopher Stawarz's Avatar

    I/O Devices:

    If Eye Cal is an I/O device, why doesn't it need to be started?

    The eye calibrators are more like filters than I/O devices, in that their inputs and outputs are all internal to MWorks (i.e. variables), whereas a "true" I/O device transfers data between MWorks and the outside world. They probably should be moved out of the "Input/Output" section in the editor's library panel and in to a separate "Filters" category.

    Fake monkey error:

    WARNING: Scheduled task (/Users/mwdev/Documents/mworks_buildbot/slave/build_all/build/plugins/core/.dicarlolab_mwcore_plugins/FakeMonkeyPlugin/FakeMonkey.cpp:137: eye movement channel) not on time (off by 5228; task = 0x7fdfa7ef2b70; priority=95)

    You'll see warnings like this sometimes. It indicates that some component (usually an I/O device) is having trouble keeping up with its update schedule. This may indicate that the system is overloaded and too many threads are contending for CPU time. However, the fake monkey is particularly prone to these warnings, which I'd attribute more to flaws in its design than to system load.

  8. Support Staff 8 Posted by Christopher Sta... on 03 Jul, 2014 04:57 PM

    Christopher Stawarz's Avatar

    Specific functionality:

    Are there min() and max() functions?

    No, but we probably should add them.

    Are there any functions that aren't listed in the knowledge base?

    No, all the available functions are listed. If there are others you think we should add, please let me know.

    Can we create our own functions? Is this the sort of thing that the Matlab/Python bridges are intended for?

    No, you can't define functions in your experiment file.

    The MATLAB and Python bridges are intended primarily for doing online data analysis. The Python (but not MATLAB) bridge does support two-way communication with MWorks, so you can use it to set variable values and thereby affect the course of the experiment. However, doing that is a little tricky, so I suggest thinking of it more as a last resort to turn to only when other approaches fail.

    Can variables be defined as expressions that don’t need to be manually assigned?

    I don't understand this one. Can you explain a little more?

    Can I get the max screen size values?

    No. The display bounds are announced at load time, so you can read them from the server console. However, they aren't available within an experiment (but that feature can be added).

    How do I know what task system state a program is currently in? Is this available somewhere in the client?

    Currently, you have to do state tracking yourself. For example, you could create a "current state" variable and assign the state name to it at the beginning of each state.

    Obviously, that's sub-optimal, so we should think about providing that info automatically.

  9. 9 Posted by ereming on 07 Jul, 2014 04:17 PM

    ereming's Avatar

    Hi Chris,

    Thanks for all the detailed responses. I'll do all my followups in one
    response:

    1. I'm using selection variables for random variables, as others have done,
    e.g.:

    http://help.mworks-project.org/discussions/questions/28-generating-random-values-with-a-selection-variable

    I'm using autoreset so that I don't have to keep track of how many draws
    have occurred and perform resets. It works fine with "Next Selection," but
    it seems odd that the same thing doesn't work with "Accept Selection" and
    "Advance on Accept."

    2. Is there a way to programmatically reset all variables to their default
    values? I would expect a stop/start to do that, but I can see why it
    wouldn't.

    3. Min/max functions would be great.

    4. Don't worry about "can variables be defined as expressions that don’t
    need to be manually assigned?" That definitely isn't something I've ever
    used before.

    5. It would be great to have a way to find out display bounds from within
    the experiment.

    6. Ditto about the state tracking.

  10. 10 Posted by ereming on 10 Jul, 2014 08:39 PM

    ereming's Avatar

    Hi Chris,

    I was thinking about the selection variable question again and just wanted to clarify some behavior:

    Looking at the data stream, I noticed that if you use "reset selections," there is no value selected (or at least recorded) immediately afterwards (whereas there is a value selected immediately after starting a program). However, I don't have to perform a "next selection" right after - it appears that using a selection variable after calling "reset selections" must automatically call the next selection routine. I can call "next selection" immediately though, because doing so doesn't cause my values to get used up prematurely. So MWorks knows whether a selection has been made, and only if one hasn't, it will make that selection when the variable is used.

    Is that right?

  11. Support Staff 11 Posted by Christopher Sta... on 11 Jul, 2014 02:08 PM

    Christopher Stawarz's Avatar

    Hi Evan,

    I'm using autoreset so that I don't have to keep track of how many draws have occurred and perform resets. It works fine with "Next Selection," but it seems odd that the same thing doesn't work with "Accept Selection" and "Advance on Accept."

    My thinking was that if you're using accept/reject, then you probably don't want to also use autoreset, as it may mask bugs in your protocol. But I agree that there's no functional reason why they shouldn't work together, so I'll fix that.

    Is there a way to programmatically reset all variables to their default values?

    No. You have to explicitly re-assign the default values in your protocol.

    So MWorks knows whether a selection has been made, and only if one hasn't, it will make that selection when the variable is used.

    Is that right?

    Yes, that's correct. What makes this confusing is that the variable can be "used" even if it's not explicitly used in your experiment, because any attempt to access the variable's value will trigger the automatic first selection behavior. This is why there's a selected value immediately after starting the experiment: At experiment start up, the values of all variables are announced on the event stream, and the act of querying the selection variable for its value causes the first selection to be made.

    I think this is a well-intentioned feature, but I personally find it confusing, which is why I recommend doing an explicit reset before you start using the selection variable in your experiment.

    Chris

  12. Christopher Stawarz closed this discussion on 22 Jul, 2014 04:25 PM.

  13. Christopher Stawarz closed this discussion on 05 Sep, 2014 08:30 PM.

  14. Christopher Stawarz closed this discussion on 28 Mar, 2018 02:00 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac