To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 4c8dbf9b authored by Martynka's avatar Martynka 🐕
Browse files

Update tasks.py

parent 6ef639cc
......@@ -19,7 +19,7 @@ def left_right_task_data_preparation():
preparator.addFilter(name='Keep immediate saccade', f=lambda events: events['type'].isin(cue) & events['type'].shift(-1).isin(saccade))
preparator.addFilter(name='Keep right direction', f=lambda events: (events['type'].isin(['10']) & events['type'].shift(-1).isin(saccade) & (events['end_x'].shift(-1) < 400))
| (events['type'].isin(['11']) & events['type'].shift(-1).isin(saccade) & (events['end_x'].shift(-1) > 400)))
preparator.addFilter(name='Keep saccade if it comes after a delay', f=lambda events: events['latency'].shift(-1) - events['latency'] > 50)
preparator.addFilter(name='Keep saccade if it comes after a meaningful reaction time', f=lambda events: events['latency'].shift(-1) - events['latency'] > 50)
preparator.addFilter(name='Keep only the ones with big enough amplitude', f=lambda events: events['amplitude'].shift(-1) > 2)
preparator.addLabel(name='Giving label 0 for left and 1 for right', f=lambda events: events['type'].apply(lambda x: 0 if x == '10' else 1))
preparator.run()
......@@ -40,7 +40,7 @@ def left_right_task_feature_extraction_data_preparation():
preparator.addFilter(name='Keep saccade that has previously a cue', f=lambda events: events['type'].isin(saccade) & events['type'].shift(1).isin(cue))
preparator.addFilter(name='Keep right direction', f=lambda events: (events['type'].shift(1).isin(['10']) & events['type'].isin(saccade) & (events['end_x'] < 400))
| (events['type'].shift(1).isin(['11']) & events['type'].isin(saccade) & (events['end_x'] > 400)))
preparator.addFilter(name='Keep saccade if it comes after a delay', f=lambda events: events['latency'] - events['latency'].shift(1) > 50)
preparator.addFilter(name='Keep saccade if it comes after a meaningful reaction time', f=lambda events: events['latency'] - events['latency'].shift(1) > 50)
preparator.addFilter(name='Keep only the ones with big enough amplitude', f=lambda events: events['amplitude'] > 2)
preparator.addLabel(name='Giving label 0 for left and 1 for right', f=lambda events: events['type'].shift(1).apply(lambda x: 0 if x == '10' else 1))
preparator.run()
......@@ -64,7 +64,7 @@ def direction_task_data_preparation():
preparator.blocks(on_blocks=['55'], off_blocks=['56']) # take only blocks 55
preparator.ignoreEvent(name='Ignore microsaccades', f=(lambda events: events['type'].isin(saccade) & (events['amplitude'] < 2)))
preparator.ignoreEvent(name='Ignore microfixations', f=(lambda events: events['type'].isin(fixation) & (events['duration'] < 150)))
preparator.addFilter(name='Keep saccade if it comes after a delay', f=lambda events: events['latency'].shift(-3) - events['latency'].shift(-2) > 50)
preparator.addFilter(name='Keep saccade if it comes after a reasonable RT', f=lambda events: events['latency'].shift(-3) - events['latency'].shift(-2) > 50)
preparator.addLabel(name='amplitude', f=lambda events: np.sqrt((events['end_x'].shift(-3) - events['start_x'].shift(-3))**2 + (events['end_y'].shift(-3) - events['start_y'].shift(-3))**2))
preparator.addLabel(name='angle', f=lambda events: np.arctan2(events['end_y'].shift(-3) - events['start_y'].shift(-3), events['end_x'].shift(-3) - events['start_x'].shift(-3)))
preparator.run()
......@@ -93,7 +93,7 @@ def direction_task_feature_extraction_data_preparation():
& events['type'].shift(1).isin(cue)
& events['type'].isin(saccade)
& events['type'].shift(-1).isin(fixation))
preparator.addFilter(name='Keep saccade if it comes after a delay', f=lambda events: (events['latency'] - events['latency'].shift(1) > 50))
preparator.addFilter(name='Keep saccade if it comes after a reasonable RT', f=lambda events: (events['latency'] - events['latency'].shift(1) > 50))
preparator.addLabel(name='amplitude', f=lambda events: np.sqrt((events['end_x'] - events['start_x'])**2 + (events['end_y'] - events['start_y']) ** 2))
preparator.addLabel(name='angle', f=lambda events: np.arctan2(events['end_y'] - events['start_y'], events['end_x'] - events['start_x']))
preparator.run()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment