Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Aug 24, 2023
1 parent 2c94fc9 commit 2028483
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ds116/code/clean_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pandas as pd
from pathlib import Path
from rich import print

root = Path(__file__).parent.parent

Expand All @@ -8,8 +9,10 @@
events_tsv = root.glob("sub-*/func/*task-*_events.tsv")

for event in events_tsv:
df = pd.read_csv(event, sep="\t")
# remove rows with "n/a" in the "onset" column
df = df[df["onset"] != "n/a"]
# save
df.to_csv(event, sep="\t", index=False)
# replace "n/a" with "NaN"
df = pd.read_csv(event, sep="\t", na_values="n/a")
print(df)
# # remove rows with NaN in the "onset" column
df = df.dropna(subset=["onset"])
# save replacing NaN with "n/a"
df.to_csv(event, sep="\t", na_rep="n/a", index=False)

0 comments on commit 2028483

Please sign in to comment.