Skip to content

Commit

Permalink
change how/if TaskName is extracted
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-pfarr committed Jul 5, 2024
1 parent 5c8c545 commit dde9437
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions eye2bids/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BasePhysioEventsJson(dict[str, Any]):

input_file: Path
two_eyes: bool
TaskName: bool

def __init__(self, metadata: None | dict[str, Any] = None) -> None:

Expand Down Expand Up @@ -48,6 +49,7 @@ def update_from_metadata(self, metadata: None | dict[str, Any] = None) -> None:
"ScreenRefreshRate": metadata.get("ScreenRefreshRate"),
"ScreenSize": metadata.get("ScreenSize"),
}
self["TaskName"] = metadata.get("TaskName")

def output_filename(self, recording: str | None = None) -> str:
"""Generate output filename."""
Expand Down
10 changes: 7 additions & 3 deletions eye2bids/edf2bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,16 @@ def _extract_ScreenResolution(df: pd.DataFrame) -> list[int]:
.split(" ")
)
return [eval(i) for i in list_res]



def _extract_TaskName(events: list[str]) -> str:
return (
" ".join([ts for ts in events if ts.startswith("** RECORDED BY")])
.replace("** RECORDED BY ", "")
.replace("\n", "")
)

def _has_TaskName(events: str) -> bool:
return not _extract_TaskName(events) == ""

def _extract_StartTime(events: list[str]) -> int:
StartTime = (
Expand Down Expand Up @@ -520,8 +521,11 @@ def edf2bids(

events_json.input_file = input_file
events_json.two_eyes = _2eyesmode(df_ms_reduced)
events_json.has_TaskName = _has_TaskName(events)

if events_json.has_TaskName:
events_json["TaskName"] = _extract_TaskName(events)

events_json["TaskName"] = _extract_TaskName(events)
events_json["StimulusPresentation"]["ScreenResolution"] = _extract_ScreenResolution(
df_ms_reduced
)
Expand Down

0 comments on commit dde9437

Please sign in to comment.