Skip to content
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 trial_columns argument in from_asc() #898

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/pymovements/gaze/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def from_csv(
file: str | Path,
experiment: Experiment | None = None,
*,
trial_columns: list[str] | None = None,
trial_columns: str | list[str] | None = None,
time_column: str | None = None,
time_unit: str | None = 'ms',
pixel_columns: list[str] | None = None,
Expand All @@ -56,7 +56,7 @@ def from_csv(
Path of gaze file.
experiment : Experiment | None
The experiment definition. (default: None)
trial_columns: list[str] | None
trial_columns: str | list[str] | None
The name of the trial columns in the input data frame. If the list is empty or None,
the input data frame is assumed to contain only one trial. If the list is not empty,
the input data frame is assumed to contain multiple trials and the transformation
Expand Down Expand Up @@ -276,6 +276,7 @@ def from_asc(
metadata_patterns: list[dict[str, Any] | str] | None = None,
schema: dict[str, Any] | None = None,
experiment: Experiment | None = None,
trial_columns: str | list[str] | None = None,
add_columns: dict[str, str] | None = None,
column_schema_overrides: dict[str, Any] | None = None,
) -> GazeDataFrame:
Expand All @@ -295,6 +296,11 @@ def from_asc(
Dictionary to optionally specify types of columns parsed by patterns. (default: None)
experiment: Experiment | None
The experiment definition. (default: None)
trial_columns: str | list[str] | None
The names of the columns (extracted by patterns) to use as trial columns.
If the list is empty or None, the asc file is assumed to contain only one trial.
If the list is not empty, the asc file is assumed to contain multiple trials and
the transformation methods will be applied to each trial separately. (default: None)
add_columns: dict[str, str] | None
Dictionary containing columns to add to loaded data frame.
(default: None)
Expand Down Expand Up @@ -434,6 +440,7 @@ def from_asc(
gaze_df = GazeDataFrame(
gaze_data,
experiment=experiment,
trial_columns=trial_columns,
time_column='time',
time_unit='ms',
pixel_columns=['x_pix', 'y_pix'],
Expand Down
Loading