Skip to content

Commit

Permalink
Group by device in duration_util_screen
Browse files Browse the repository at this point in the history
  • Loading branch information
rantahar committed Oct 14, 2024
1 parent ed2ee2a commit 3620267
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions niimpy/preprocessing/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,14 @@ def duration_util_screen(df):

df.sort_index(inplace=True)
df.sort_values(by=["user","device"], inplace=True)
df['duration']=np.nan
df['duration']=df.index.to_series().diff()
df['duration'] = np.nan
df['duration'] = df.index.to_series().diff()
df['duration'] = df['duration'].shift(-1)

#Discard transitions between subjects
df = df.groupby("user").apply(lambda x: x.iloc[:-1], include_groups=False)
df = df.reset_index().set_index("level_1")
index_name = df.index.name
df = df.groupby(["user", "device"]).apply(lambda x: x.iloc[:-1], include_groups=False)
df.reset_index(["user", "device"], inplace=True)

#Discard any datapoints whose duration in “ON” and "IN USE" states are
#longer than 10 hours becaus they may be artifacts
Expand Down

0 comments on commit 3620267

Please sign in to comment.