-
Notifications
You must be signed in to change notification settings - Fork 963
BF: fix trial data writing when there are multiple key presses including None #6718
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #6718 +/- ##
==========================================
- Coverage 48.96% 41.15% -7.81%
==========================================
Files 332 332
Lines 61181 61188 +7
==========================================
- Hits 29956 25183 -4773
- Misses 31225 36005 +4780
|
TEParsons
left a comment
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 think this is fine - if I follow: You're keeping None present up to the point of the eval call, then removing it after so that behaviour after is unchanged from current?
I'd also advise adding a test to psychopy.tests.test_data.test_TrialHandler:TestTrialHandler to check this - we actually have one called test_multiKeyResponses that's been disabled for about 10 years so it would be good to have something more up to date :')
| strVersion = str(tmpData.tolist()) | ||
| # for numeric data replace None with a blank cell | ||
| if tmpData.dtype.kind not in ['SaUV']: | ||
| if tmpData.dtype.kind not in 'SaUV': |
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.
What's the motivation for removing the []? Is it possible for .dtype.kind to be just part of the string "SaUV", and if so do we want to catch it 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.
Yeah I don't think 'SaUV' itself is a valid dtype.kind. I think it has always meant to check whether .dtype.kind is part of the string, and it was a typo to include the []. Right now even for string data, 'None' gets replaced by '' because tmpData.dtype.kind is never the same as 'SaUV'.
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.
Ah okay, I don't know much about dtypes tbh so I'll take your word on it. To be clearest we should probably do ("S", "a", "U", "V"), but this is a minor point, the string is fine :P
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.
Might be worth checking with Jon or whoever wrote it in the first place? I don't think "a" is one of the valid character codes anymore: https://numpy.org/doc/stable/reference/generated/numpy.dtype.kind.html
Yeah that's right. I'm adding the
I agree, although I still don't know well enough why this issue came up. The strange thing is that I ran into this problem by spamming a key when a response_key component is active (and it's set to store all keys). Sometimes, but not always, when I press too quickly, one of the durations becomes |
When there are multiple key presses in a trial, data from all trials are stored as a list of lists. However, for numerical data that underwent replacing
'None'with'', this creates invalid syntaxes when convertingstrVersionback to a tuple usingeval().This is because
eval("[1, , 2]"), etc. is not a valid syntax. Current PR fixes the issue to allow an empty cell to be written into the output file for trials containing data in the form of lists of lists.