diff --git a/eye2bids/edf2bids.py b/eye2bids/edf2bids.py index 869ce16..7cd199c 100644 --- a/eye2bids/edf2bids.py +++ b/eye2bids/edf2bids.py @@ -2,8 +2,8 @@ from __future__ import annotations import json -import subprocess import os +import subprocess from pathlib import Path import numpy as np @@ -229,13 +229,14 @@ def _extract_RecordedEye(df: pd.DataFrame) -> str: def _extract_ScreenResolution(df: pd.DataFrame) -> list[int]: - list_res = ((df[df[2] == "GAZE_COORDS"]) - .iloc[0:1, 3:5] - .to_string(header=False, index=False) - .replace(".00", "") - .split(" ") + list_res = ( + (df[df[2] == "GAZE_COORDS"]) + .iloc[0:1, 3:5] + .to_string(header=False, index=False) + .replace(".00", "") + .split(" ") ) - return [eval (i) for i in list_res] + return [eval(i) for i in list_res] def _extract_TaskName(events: list[str]) -> str: @@ -349,8 +350,6 @@ def edf2bids( substring_eyetrack = '_eyetrack' substring_events = '_events' - # to json - # Eyetrack.json Metadata eyetrack_json = { "Manufacturer": "SR-Research", @@ -384,11 +383,10 @@ def edf2bids( with open(output_dir / (filename + "_eyetrack.json"), "w") as outfile: json.dump(eyetrack_json, outfile, indent=4) e2b_log.info(f"file generated: {output_dir / (filename + '_eyetrack.json')}") - elif substring_eyetrack in filename: + elif substring_eyetrack in filename: with open(output_dir / (filename + ".json"), "w") as outfile: json.dump(eyetrack_json, outfile, indent=4) e2b_log.info(f"file generated: {output_dir / (filename + '.json')}") - # Events.json Metadata events_json = { @@ -402,12 +400,12 @@ def edf2bids( }, "TaskName": _extract_TaskName(events), } - + if substring_events not in filename: with open(output_dir / (filename + "_events.json"), "w") as outfile: json.dump(events_json, outfile, indent=4) e2b_log.info(f"file generated: {output_dir / (filename + '_events.json')}") - elif substring_events in filename: + elif substring_events in filename: with open(output_dir / (filename + ".json"), "w") as outfile: json.dump(events_json, outfile, indent=4) e2b_log.info(f"file generated: {output_dir / (filename + '.json')}") @@ -427,6 +425,7 @@ def edf2bids( + if __name__ == "__main__": parser = global_parser() args = parser.parse_args()