Hey Chris,
I’m currently exploring, how powerful mwel can be in comparison to the xml approach of earlier versions.
I came across two behaviors, that I unfortunately fail to solve myself:
%define present_stim(stim_fix_id, position_id)
// Queue fixation point
fixation_points[stim_fix_id]['x_position'] = positions[position_id]['x_position']
fixation_points[stim_fix_id]['y_position'] = positions[position_id]['y_position']
// This works:
queue_temp = fixation_points[stim_fix_id]['stim_fix_id']
queue_stimulus(stim_fix[queue_temp])
// This does not:
//queue_stimulus(stim_fix[fixation_points[stim_fix_id]['stim_fix_id']])
update_stimulus_display()
%end
As far as I understand how most parameters work, they are not assigned by value but by reference. Hence, you can change the value in the variable somewhere else, and it also gets updated across all components.
So I guess in this example the parameter for dereferencing stim_fix does not get correctly dereferenced before it is evaluated, or am I missing something? Is there a workaround for this?
The parser at least is not very happy about it:
00:29:40: ERROR: Illegal stimulus dimension reference: stim_fix
Extended information:
location: line 81, column 5; via line 111, column 17
object_type: action/queue_stimulus
parent_scope: Press the Circle
ref_id: idp105553178068607
parser_context: mw_anonymous_create
Second behavior:
When I for example want to organize my stimuli in a dictionary like this:
var trigger_correct = false
var trigger_incorrect = false
var STIM_CORRECT = 0
var STIM_INCORRECT = 1
var fixation_points = [
{'stim_fix_id': 0, 'x_position' : 0, 'y_position': 0, 'trigger': false},
{'stim_fix_id': 1, 'x_position' : 0, 'y_position': 0, 'trigger': false}
]
var stim_size = 30
stimulus_group stim_fix {
fixation_point 'stim_fix_correct'(
color = 0, 1, 0
x_size = stim_size
y_size = stim_size
trigger_width = stim_size
trigger_watch_x = pointer_x
trigger_watch_y = pointer_y
trigger_flag = trigger_correct // <-this works, but this does not work (or at least the variable stays unchanged on expected trigger): fixation_points[STIM_CORRECT]['trigger']
x_position = fixation_points[STIM_CORRECT]['x_position']
y_position = fixation_points[STIM_CORRECT]['y_position']
)
fixation_point 'stim_fix_incorrect'(
color = 1, 0, 0
x_size = stim_size
y_size = stim_size
trigger_width = stim_size
trigger_watch_x = pointer_x
trigger_watch_y = pointer_y
trigger_flag = trigger_incorrect // <-this works, but this does not work (or at least the variable stays unchanged on expected trigger): fixation_points[STIM_CORRECT]['trigger']
x_position = fixation_points[STIM_INCORRECT]['x_position']
y_position = fixation_points[STIM_INCORRECT]['y_position']
)
}
Here I try to have all my triggers organized together with the coordinates of the stimuli I’d like to present. The parser is also happy with this, but at runtime the values in the dictionaries don’t get updated, and I can’t use them for conditional goto’s. That feels a little strange to me, since in the other direction with the x_position for example this approach works like a charm.
As seen, I came up with a workaround for both cases, but I’m curious of the why, and I would like to do it the way I want if possible
Thanks in advance for your help and time!
Minimum example file (unfortunately, I cannot upload files yet here):