Skip to content

Commit

Permalink
Merge branch 'julia' of github.com:bids-standard/eye2bids into julia
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-pfarr committed Oct 27, 2023
2 parents 46e229f + ce7b0c6 commit c364418
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions eye2bids/edf2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from __future__ import annotations

import json
import subprocess
import os
import subprocess
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -349,8 +350,6 @@ def edf2bids(
substring_eyetrack = '_eyetrack'
substring_events = '_events'

# to json
# Eyetrack.json Metadata

eyetrack_json = {
"Manufacturer": "SR-Research",
Expand Down Expand Up @@ -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 = {
Expand All @@ -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')}")
Expand All @@ -427,6 +425,7 @@ def edf2bids(




if __name__ == "__main__":
parser = global_parser()
args = parser.parse_args()
Expand Down

0 comments on commit c364418

Please sign in to comment.