-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: add support for multiple recording specs per file to gaze.from_asc() #887
base: main
Are you sure you want to change the base?
Changes from 18 commits
92f5b21
8b99481
a3f70c1
1b6c59d
dcc2d64
78077e5
14a6f9f
c11db5d
10cce18
86f67b2
8542fc1
95f6b3e
ad168c8
ec9f99d
18414fb
8d1a7e6
8dafbee
0267ad1
253d9f2
67d07de
034c5ab
25a8693
9acb926
5e4c659
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2023-2024 The pymovements Project Authors | ||
# Copyright (c) 2024 The pymovements Project Authors | ||
# | ||
saphjra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -17,6 +17,25 @@ | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
# Copyright (c) 2023-2024 The pymovements Project Authors | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# git | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
"""Tests pymovements asc to csv processing.""" | ||
import datetime | ||
from pathlib import Path | ||
|
@@ -65,6 +84,7 @@ | |
START 10000004 RIGHT SAMPLES EVENTS | ||
10000004 850.7 717.5 714.0 0.0 ... | ||
END 10000005 SAMPLES EVENTS RES 38.54 31.12 | ||
MSG 10000013.5 RECCFG CR 2000 1 1 R | ||
MSG 10000005 METADATA_1 123 | ||
MSG 10000005 START_B | ||
the next line now should have the task column set to B | ||
|
@@ -102,6 +122,7 @@ | |
EBLINK R 10000018 10000020 2 | ||
10000021 . . 0.0 0.0 ... | ||
END 10000022 SAMPLES EVENTS RES 38.54 31.12 | ||
|
||
""" | ||
|
||
PATTERNS = [ | ||
|
@@ -160,12 +181,7 @@ | |
'version_2': 'EYELINK II CL v6.12 Feb 1 2018 (EyeLink Portable Duo)', | ||
'model': 'EyeLink Portable Duo', | ||
'version_number': '6.12', | ||
'sampling_rate': 1000.00, | ||
'file_sample_filter': '2', | ||
'link_sample_filter': '1', | ||
'pupil_data_type': 'AREA', | ||
'tracking_mode': 'CR', | ||
'tracked_eye': 'L', | ||
'calibrations': [], | ||
'validations': [], | ||
'resolution': (1280, 1024), | ||
|
@@ -189,6 +205,24 @@ | |
'metadata_2': 'abc', | ||
'metadata_3': True, | ||
'metadata_4': None, | ||
'recording_config': [ | ||
{ | ||
'sampling_rate': '1000', # MSG 2154555 RECCFG CR 1000 2 1 L | ||
'file_sample_filter': '2', | ||
'link_sample_filter': '1', | ||
'timestamp': '2154555', | ||
'tracked_eye': 'L', | ||
'tracking_mode': 'CR', | ||
}, | ||
{ | ||
'sampling_rate': '2000', # MSG 10000013.5 RECCFG CR 2000 1 1 R | ||
'file_sample_filter': '1', | ||
'link_sample_filter': '1', | ||
'timestamp': '10000013.5', | ||
'tracked_eye': 'R', | ||
'tracking_mode': 'CR', | ||
}, | ||
], | ||
} | ||
|
||
|
||
|
@@ -425,7 +459,9 @@ def test_parse_val_cal_eyelink_monocular_file(): | |
('metadata', 'expected_blinks'), | ||
[ | ||
pytest.param( | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'EVENTS GAZE LEFT RATE 1000.00 TRACKING CR FILTER 2\n' | ||
'SBLINK R 10000018\n' | ||
'10000019 . . 0.0 0.0 ...\n' | ||
|
@@ -497,15 +533,17 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
('metadata', 'expected_blink_ratio', 'expected_overall_ratio'), | ||
[ | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000018 RIGHT SAMPLES EVENTS\n' | ||
'SBLINK R 10000018\n' | ||
'10000019 . . 0.0 0.0 ...\n' | ||
'10000020 . . 0.0 0.0 ...\n' | ||
'EBLINK R 10000018 10000020 2\n' | ||
'END 10000020 SAMPLES EVENTS RES 38.54 31.12\n', | ||
1, | ||
1, | ||
# asc snipped which gets processed by the function | ||
1, # expected_blink_ratio | ||
1, # expected_overall_ratio | ||
id='only_blinks', | ||
), | ||
pytest.param( | ||
|
@@ -521,6 +559,7 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='unknown_sampling_rate_only_blinks', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000018 RIGHT SAMPLES EVENTS\n' | ||
'10000019 . . 0.0 0.0 ...\n' | ||
|
@@ -530,6 +569,7 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='lost_samples_no_blinks', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000018 RIGHT SAMPLES EVENTS\n' | ||
'SBLINK R 10000018\n' | ||
|
@@ -552,6 +592,7 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='lost_samples_no_sampling_rate', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000018 RIGHT SAMPLES EVENTS\n' | ||
'10000019 850.7 717.5 714.0 0.0 ...\n' | ||
|
@@ -563,6 +604,7 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='missing_timestamps', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000018 RIGHT SAMPLES EVENTS\n' | ||
'10000019 850.7 717.5 714.0 0.0 ...\n' | ||
|
@@ -574,6 +616,7 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='missing_timestamps_lost_samples', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000020 RIGHT SAMPLES EVENTS\n' | ||
'10000020 850.7 717.5 714.0 0.0 ...\n' | ||
|
@@ -584,9 +627,10 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
'END 10000024 SAMPLES EVENTS RES 38.54 31.12\n', | ||
0.25, | ||
0.75, | ||
id='missing_timestamps_lost_samples', | ||
id='missing_timestamps_lost_samples4', | ||
), | ||
saphjra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these added date strings aren't really necessary, right? Your other changes here, like adding documentation or changing test ids, are of course the spirit that we need! 🥇 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for all your Feedback 😄 The thing is, without this additional line, the metadata will be empty, since the MSG line gets parsed into the recording_config and not metadata anymore. However if metadata is empty/ none the code will raise a warning and all the tests, where I added the Date line, will fail due to that. line 367 Is there a better way, to solve this? |
||
'SBLINK R 10000018\n' | ||
'10000019 . . 0.0 0.0 ...\n' | ||
|
@@ -599,12 +643,13 @@ def test_parse_eyelink_blinks(tmp_path, metadata, expected_blinks): | |
id='blinks_and_lost_samples_no_start_end', | ||
), | ||
pytest.param( | ||
'** DATE: Wed Mar 8 09:25:20 2023\n' | ||
'MSG 2154555 RECCFG CR 1000 2 1 L\n' | ||
'START 10000020 RIGHT SAMPLES EVENTS\n' | ||
'END 10000021 SAMPLES EVENTS RES 38.54 31.12\n', | ||
0, | ||
1, | ||
id='missing_timestamps_lost_samples', | ||
id='missing_timestamps_lost_samples12', | ||
), | ||
], | ||
) | ||
|
@@ -615,6 +660,7 @@ def test_parse_eyelink_data_loss_ratio( | |
filepath.write_text(metadata) | ||
|
||
_, parsed_metadata = pm.utils.parsing.parse_eyelink(filepath) | ||
print(f'parsed_metadata: {parsed_metadata}, \nmetadata: {metadata}') | ||
|
||
saphjra marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert parsed_metadata['data_loss_ratio_blinks'] == expected_blink_ratio | ||
assert parsed_metadata['data_loss_ratio'] == expected_overall_ratio | ||
|
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 it's sufficient for now to just check for consistency and raise a warning if it's inconsistent.
We can improve on that in a follow-up. Moreover, the logic for calculating data loss will be moved away from this module into the measure module. This way users will be able to calculate these measures on any
GazeDataFrame
not just when parsed viafrom_asc()
.