Skip to content

Commit 88f9d31

Browse files
committed
Performance optimization
1 parent 91795b5 commit 88f9d31

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bidscoin/plugins/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def eventstable(self) -> pd.DataFrame:
266266
df['onset'] -= df['onset'][start].iloc[0] # Take the time of the first occurrence as zero
267267

268268
# Loop over the row groups to filter/edit the rows
269-
rows = pd.Series([len(self.rows) == 0] * len(df), index=df.index) # All rows are True if no row expressions were specified
269+
rows = pd.Series(len(self.rows) == 0, index=df.index) # All rows are True if no row expressions were specified
270270
for group in self.rows: # With a group the expressions are AND between groups they are OR
271271

272272
rowgroup = pd.Series(True, index=df.index)

bidscoin/plugins/events2bids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def add_started(time, started: float):
369369
if (stopped := f"{event}.stopped") in df:
370370
duration = df[stopped] - df[started]
371371
else:
372-
duration = pd.Series([float('nan')] * len(df), index=df.index)
372+
duration = pd.Series(pd.NA, index=df.index)
373373
df_piv_ = pd.DataFrame({'onset': onset, 'duration': duration, 'event_type': [event]*len(df)}, index=df.index).dropna(subset=['onset'])
374374
df_misc = df.filter(regex=r'^(?!.*\.(started|stopped)$)').loc[df_piv_.index,:] # Drop all columns that end with '.started', '.stopped'
375375
if not df_piv_.empty: # Only concatenate if df_piv_ has data

0 commit comments

Comments
 (0)