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

load gaze files with gaze.from_csv() #504

Closed
3 tasks done
dkrako opened this issue Sep 7, 2023 · 1 comment · Fixed by #557
Closed
3 tasks done

load gaze files with gaze.from_csv() #504

dkrako opened this issue Sep 7, 2023 · 1 comment · Fixed by #557
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@dkrako
Copy link
Contributor

dkrako commented Sep 7, 2023

Description of the problem

Currently we need the Dataset class to load GazeDataFrames.

Description of a solution

It would be much nicer to have a self-contained solution in a function like pymovements.gaze.from_csv() which returns a GazeDataFrame loaded from a csv file.

Most functionality is already included in dataset/dataset_files.py, so parts can be reused in gaze/io.py.
We won't need to add any fileinfo columns for now.
We will refactor dataset/dataset_files.py after finishing #508 and #518.

For a start, we can use **kwargs to forward all specific reading arguments to polars.read_csv()

Simply passing **kwargs will also shorten testing and documentation. But we should discuss if we want to add all the arguments explictly.
Although having all arguments explicit is probably the best solution, we would then need to keep the documentation up to date. We should therefore discuss if a more self-contained documentation is worth the effort. (probably it is)

Minimum acceptance criteria

  • pm.gaze.from_csv() in gaze/io.py
  • tests in tests/gaze/io/csv_test.py
  • create at least one monocular and a binocular csv test file with 10 rows (can be all zero) in tests/gaze/io/files/

Code example

proposed function signature:

def from_csv(
        file: str | Path,
        experiment: Experiment | None = None,
        *,
        trial_columns: list[str] | None = None,
        time_column: str | None = None,
        pixel_columns: list[str] | None = None,
        position_columns: list[str] | None = None,
        velocity_columns: list[str] | None = None,
        acceleration_columns: list[str] | None = None,
        **read_csv_kwargs,
) -> GazeDataFrame:
@dkrako dkrako added the enhancement New feature or request label Sep 7, 2023
@dkrako dkrako changed the title load gaze files with gaze.from_csv load gaze files with gaze.from_csv() Sep 7, 2023
@dkrako
Copy link
Contributor Author

dkrako commented Sep 9, 2023

the PR should include simple csv test files which should be then loaded in tests (maybe also write a fixture to simplify usage).

there should actually be a range of csv files, although the files should probably all be limited to about 10 rows
we can also test several header configurations (monocular, binocular, with/without time column, pixel data, dva data, stimulus, etc.)

this will probably help resolving #492 by a lot, because we could also create toy version csv files for gazebase and judo1000

@dkrako dkrako added this to the Sprint 18 milestone Sep 9, 2023
@prassepaul prassepaul self-assigned this Sep 13, 2023
prassepaul pushed a commit that referenced this issue Sep 15, 2023
@dkrako dkrako linked a pull request Sep 15, 2023 that will close this issue
13 tasks
SiQube added a commit that referenced this issue Sep 26, 2023
* added from_csv (#504)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix docstring error

* docstring error

* flake8 issue

* cyclic import

* added import to docstring

* added dataset gaze_on_faces

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* from_ipc

* error in path

* unused arguments

* bug fix

* fixed time column in feather file

* requested changes

* sbset dataset

* flake, pyling, mypy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* bib

---------

Co-authored-by: prassepaul <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: David R. Reich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants