-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Calibration Interrupt #359
base: main
Are you sure you want to change the base?
Conversation
@larsoner It looks like circle build is working |
I don't think any should, I think you should make a function to do this. It should probably be a method of
This sounds too messy, as it requires burdening generic press-event code with paradigm-specific checks. A cleaner design is probably to know that there is some interval during which a recalibration can be requested, and press the button then. |
@rkmaddox and I were talking about how this might work in an experiment. Perhaps writing |
Sounds reasonable to me |
Codecov Report
@@ Coverage Diff @@
## master #359 +/- ##
=========================================
- Coverage 89.07% 88.98% -0.1%
=========================================
Files 44 44
Lines 5682 5717 +35
Branches 917 926 +9
=========================================
+ Hits 5061 5087 +26
- Misses 426 430 +4
- Partials 195 200 +5 |
Have not tested this with an actual eyelink connected yet and have not added tests. I've started with what I think the minimum scope of |
My feeling is that putting the functions into the base waiting function (which I think is |
Ahh, I see what you're saying. Functions like |
Yes, Upshot, it should check at the beginning of those functions (but actually doesn't in my test script). Update: calibration checking doesn't work because |
Tested with real eyelink and seems to behave |
expyfun/_experiment_controller.py
Outdated
|
||
Notes | ||
----- | ||
See `flip_and_play` for order of operations. Can be called multiple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not look correct / relevant
expyfun/_eyelink_controller.py
Outdated
|
||
Notes | ||
----- | ||
The data will be saved to the ExperimentController ``output_dir``. | ||
If this was `None`, data will be saved to the current working dir. | ||
""" | ||
@verbose_dec | ||
def __init__(self, ec, link='default', fs=1000, verbose=None): | ||
def __init__(self, ec, link='default', fs=1000, verbose=None, | ||
calibration_key=['c']): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not use mutable default arguments. Tuple is immutable so ('c',)
is better here
@@ -46,6 +47,9 @@ def test_eyelink_methods(): | |||
# run much of the calibration code, but don't *actually* do it | |||
el._fake_calibration = True | |||
el.calibrate(beep=False, prompt=False) | |||
fake_button_press(ec, 'c') | |||
el.check_recalibrate(prompt=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you assert that this is True ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test gets hung up on the prompt screen. Could put in a fake_button_press
if you want to test the prompt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. It currently gets stuck, or will get stuck with my suggested addition of an assert
in this line preceding the el...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read too quickly, you are correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to understand what this does just by reading the docstrings and the code, so I have several docstring suggestions. I haven't tested the code itself.
expyfun/_experiment_controller.py
Outdated
Parameters | ||
---------- | ||
function : function | None | ||
The function to call. If ``None``, all the "on every flip" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this say all the "on every wait"
?
expyfun/_eyelink_controller.py
Outdated
@@ -137,14 +137,17 @@ class EyelinkController(object): | |||
Sample rate to use. Must be one of [250, 500, 1000, 2000]. | |||
verbose : bool, str, int, or None | |||
If not None, override default verbose level (see expyfun.verbose). | |||
calbration_keys : list | |||
Keys that will trigger recalibration when check_recalibration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you expand this docstring line a bit? The reference to check_calibration
needs context (i.e., it's not a parameter of this constructor, so explain what it is / where it lives)... is it referring to the new check_recalibrate
method? (if so, the method name is wrong here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, you say it should be list
but you initiate it with a tuple. Will it work with any iterable? if so, say iterable
instead of list
expyfun/_eyelink_controller.py
Outdated
def check_recalibrate(self, keys=None, prompt=True): | ||
"""Compare key buffer to recalibration keys and calibrate if matched. | ||
|
||
This function always uses the keyboard, so is part of abstraction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand ths note.
expyfun/_eyelink_controller.py
Outdated
Parameters | ||
---------- | ||
keys : list or string | ||
keys to check if prompt recalibration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keys to check against the (set of) key(s) that trigger calibration.
expyfun/_eyelink_controller.py
Outdated
keys : list or string | ||
keys to check if prompt recalibration | ||
prompt : bool | ||
Whether to show the calibration prompt or not |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whether to show the calibration prompt screen before starting the calibration procedure
I'd attempted this before and it was surprisingly messy so guidance/debate is welcome. @larsoner @drammock @rkmaddox
The goal is to be able to re-calibrate during an experiment when a given key is pressed.
Things to consider:
ec
has the button press info butel
needs to be called -- so which should the function live in? I'd previously gotten it to "work" with the function living inec
and importingel
toec
after both were initialized but it was pretty gross._retrieve_keyboard_events
or_correct_presses
will need to recognize the calibration key.