Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-pfarr committed Jun 27, 2024
1 parent ab171fb commit fc3f015
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions eye2bids/edf2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,15 @@ def edf2bids(

e2b_log.info(f"file generated: {output_filename_eye2}")

# %%
# Messages and events to dataframes

events_after_start = _df_events_after_start(events)
physioevents_reordered = _df_physioevents(events_after_start)
physioevents_eye1 = _physioevents_eye1(physioevents_reordered)
physioevents_eye2 = _physioevents_eye2(physioevents_reordered)

# %%
# Messages and events to physioevents.tsv.gz

if not _2eyesmode(df_ms_reduced):
Expand Down
28 changes: 20 additions & 8 deletions tests/test_edf2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path

import pandas as pd
import numpy as np
import pytest

from eye2bids.edf2bids import (
Expand Down Expand Up @@ -160,7 +161,7 @@ def test_edf_nan_in_tsv(eyelink_test_data_dir):
)

expected_eyetrack_tsv = output_dir / f"{input_file.stem}_recording-eye1_physio.tsv.gz"
df = pd.read_csv(expected_eyetrack_tsv, sep="\t")
df = pd.read_csv(expected_eyetrack_tsv, sep="\t", header=None)
count = sum(i == "." for i in df[0])
assert count == 0

Expand Down Expand Up @@ -636,7 +637,7 @@ def test_number_columns_physioevents_tsv(eyelink_test_data_dir):


@pytest.mark.parametrize(
"folder, expected",
"folder, expected",
[
(
"rest",
Expand Down Expand Up @@ -677,10 +678,21 @@ def test_number_columns_physioevents_tsv(eyelink_test_data_dir):
],
)
def test_physioevents_value(folder, expected, eyelink_test_data_dir):
"""Check content physioevents.tsv.gz.
function _df_events_after_start, _df_physioevents, _physioevents_eye1, _physioevents_eye2
"""
input_dir = eyelink_test_data_dir / folder
asc_file = asc_test_files(input_dir=input_dir, suffix="*_events")[0]
events = _load_asc_file(asc_file)
events_after_start = _df_events_after_start(events)
physioevents_reordered = _df_physioevents(events_after_start)
physioevents_eye1 = _physioevents_eye1(physioevents_reordered)
assert physioevents_eye1.iloc[3:10, 2].tolist() == expected
input_file = edf_test_files(input_dir=input_dir)[0]

output_dir = data_dir() / "output"
output_dir.mkdir(exist_ok=True)

edf2bids(
input_file=input_file,
output_dir=output_dir,
)

expected_eyetrackphysio_tsv = output_dir / f"{input_file.stem}_recording-eye1_physioevents.tsv.gz"
df = pd.read_csv(expected_eyetrackphysio_tsv, sep="\t", header=None)
assert df.iloc[3:10, 2].tolist() == expected

0 comments on commit fc3f015

Please sign in to comment.