Translating between announceCurrentState and a name

Simon Bohn's Avatar

Simon Bohn

24 Sep, 2018 12:42 PM

Hi Chris,

I was wondering if you could help me understand how to translate an announceCurrentState variable into something meaningful. I have a state system that is hanging in an unknown (to me) state, and its announceCurrentState is 7285 when it hangs. However, when I try to load the .mwk file and try f.codec[7285], I get an error. Viewing the f.codec dict leads me to believe this is the variables codec. I then tried accessing the components codec by unpacking all the events and using all_events[2].data but it didn't tell me anything either, just some facts about the experiment (experiment name, etc...)

How do I access the component codec so I can figure out where my state system is hanging? It only happens about once every 1000 trials so it has been very annoying to debug!

Simon

  1. 1 Posted by Simon Bohn on 24 Sep, 2018 12:43 PM

    Simon Bohn's Avatar

    Alright, I actually figured it out in the end. Seems like all_events[0].data[7258] got me what I wanted. It would be nice a bit on how to access the component codec in the manual, I think, for those who come after me. It would be even nicer to have announce_state somewhere in plain text without having to unpack the mwk file, or even quick access to the component codec decoder in a window while an experiment is running.

    I have another question. Is there any way to access the state of an alt device with a variable? For example, I would like a variable to be set to 999 when the eyelink fails to initialize, so that this will be recorded in our csv log file of the experiment, if someone ever starts the program and then does a trial with the mouse, I don't want it to be mixed up with the real monkey data.

    Simon

  2. Support Staff 2 Posted by Christopher Sta... on 24 Sep, 2018 01:43 PM

    Christopher Stawarz's Avatar

    Hi Simon,

    How do I access the component codec so I can figure out where my state system is hanging?

    The component codec has code 2 (as documented in System Event Codes). As you discovered, it also happens to be the first event in the event file. However, that's not guaranteed to be true forever. The right way to get it is to select events with code equal to 2, e.g.

    cc = f.get_events(codes=[2])[0].data
    

    It would be nice a bit on how to access the component codec in the manual, I think, for those who come after me. It would be even nicer to have announce_state somewhere in plain text without having to unpack the mwk file, or even quick access to the component codec decoder in a window while an experiment is running.

    The component codec and #announceCurrentState variable aren't as useful as they might seem. When you read "state", you probably think of task system states. While those are announced in #announceCurrentState, so are all other paradigm components and, more significantly, all actions. A UI element that attempted to show the tag associated with the current state would mostly just be a blur, as MWorks changes "states" very, very often. Even when it was legible, it would often show junk like "idm34633081972176", which is what the component codec gives you for components that aren't named in the experiment (e.g. most actions).

    What would be more helpful, I think, would be to introduce a new system variable that only announced task-system states. The client could use that variable, along with the component codec, to display the name of the state.

    Is there any way to access the state of an alt device with a variable? For example, I would like a variable to be set to 999 when the eyelink fails to initialize, so that this will be recorded in our csv log file of the experiment, if someone ever starts the program and then does a trial with the mouse, I don't want it to be mixed up with the real monkey data.

    No. However, in the case of the EyeLink, you could set the initial value of the variable associated with e.g. pupil_lx to some sentinel value like -999. If the EyeLink fails to initialize, that value should never change, so you could use its presence to detect simulated trials.

    Cheers,
    Chris

  3. Christopher Stawarz closed this discussion on 01 Oct, 2018 02:34 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