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

Fix bug: _extract_EyeTrackingMethod #82

Merged
merged 10 commits into from
Jul 8, 2024
Prev Previous commit
Next Next commit
Merge branch 'main' into fix-bugs
julia-pfarr committed Jul 1, 2024
commit bcb573af9afaa1f64b1cb7aa24a3ab856d0d8a82
49 changes: 25 additions & 24 deletions eye2bids/edf2bids.py
Original file line number Diff line number Diff line change
@@ -136,36 +136,37 @@ def _extract_CalibrationCount(df: pd.DataFrame, two_eyes: bool) -> int:
return len(_calibrations(df)) // 2 if two_eyes else len(_calibrations(df))


def _extract_CalibrationPosition(df: pd.DataFrame) -> list[list[int]]:

if _has_validation == False:
CalibrationPosition = []
return CalibrationPosition

else:
cal_df = df[df[2] == "VALIDATE"]#.drop(columns=[2, 3, 4, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17]).reset_index(drop=True)
cal_df[5] = pd.to_numeric(cal_df[5], errors='coerce')
df_sorted = cal_df.sort_values(by=5)
def _extract_CalibrationPosition(df: pd.DataFrame) -> list[list[list[int]]]:

if _2eyesmode(df) == True:
df_sorted = df_sorted.drop(index=df_sorted.index[::(_extract_CalibrationCount(df) * 2)])
calibration_df = df[df[2] == "VALIDATE"]
calibration_df[5] = pd.to_numeric(calibration_df[5], errors="coerce")

if _extract_CalibrationCount(df) == 1:
CalibrationPosition = np.array((df_sorted[8]).str.split(",", expand=True)).astype(int).tolist()
return CalibrationPosition
else:
CalibrationPosition = []
if _2eyesmode(df):
# drop duplicated calibration position
# because they will be the same for both eyes
calibration_df = calibration_df[calibration_df[6] == "LEFT"]

for x in df_sorted:
cal_values = np.array((df_sorted[8][::_extract_CalibrationCount(df)]).str.split(",", expand=True)).astype(int).tolist()
CalibrationPosition.append(cal_values)
return CalibrationPosition
nb_calibration_postions = calibration_df[5].max() + 1

# initialize
CalibrationPosition: Any = [[[]] * nb_calibration_postions]

def _extract_CalibrationUnit(df: pd.DataFrame) -> str:
if len(_extract_CalibrationPosition(df)) == 0:
return ""
for i_pos in range(nb_calibration_postions):

results_for_this_position = calibration_df[calibration_df[5] == i_pos]

for i, calibration in enumerate(results_for_this_position.iterrows()):
values = calibration[1][8].split(",")

if len(CalibrationPosition) < i + 1:
CalibrationPosition.append([[]] * nb_calibration_postions)

CalibrationPosition[i][i_pos] = [int(x) for x in values]

return CalibrationPosition


def _extract_CalibrationUnit(df: pd.DataFrame) -> str:
cal_unit = (
(df[df[2] == "VALIDATE"][[13]])
.iloc[0:1, 0:1]
1 change: 1 addition & 0 deletions tests/test_edf2bids.py
Original file line number Diff line number Diff line change
@@ -291,6 +291,7 @@ def test_extract_CalibrationUnit(folder, expected, eyelink_test_data_dir):
[794, 444],
[960, 348],
],
],
),
],
)
You are viewing a condensed version of this merge commit. You can view the full changes here.