@@ -237,12 +237,13 @@ def eventstable(self) -> pd.DataFrame:
237237 """Returns the target events.tsv data"""
238238
239239 # Check the parser's data structure
240- if not len (self .logtable ):
240+ logtable = self .logtable
241+ if not len (logtable ):
241242 return pd .DataFrame (columns = ['onset' , 'duration' ])
242243 if not self .isvalid :
243244 pass
244245
245- df = self . logtable .copy () # Ensure we do not change the source data
246+ df = logtable .copy () # Ensure we do not change the source data
246247
247248 # Convert the timing values to seconds (with maximally 4 digits after the decimal point)
248249 timecols = list (set (col for col in df for pattern in self .time .cols if re .fullmatch (pattern , col )))
@@ -256,10 +257,10 @@ def eventstable(self) -> pd.DataFrame:
256257
257258 # Set the clock at zero at the start of the experiment
258259 if self .time .start :
259- start = pd .Series ([ True ] * len ( df ) , index = df .index )
260+ start = pd .Series (True , index = df .index )
260261 for column , value in self .time .start .items ():
261- if column in self . logtable :
262- start &= (self . logtable [column ].astype (str ) == str (value ))
262+ if column in logtable :
263+ start &= (logtable [column ].astype (str ) == str (value ))
263264 if start .any ():
264265 LOGGER .bcdebug (f"Resetting clock offset: { df ['onset' ][start ].iloc [0 ]} " )
265266 df ['onset' ] -= df ['onset' ][start ].iloc [0 ] # Take the time of the first occurrence as zero
@@ -268,15 +269,15 @@ def eventstable(self) -> pd.DataFrame:
268269 rows = pd .Series ([len (self .rows ) == 0 ] * len (df ), index = df .index ) # All rows are True if no row expressions were specified
269270 for group in self .rows : # With a group the expressions are AND between groups they are OR
270271
271- rowgroup = pd .Series ([ True ] * len ( df ) , index = df .index )
272+ rowgroup = pd .Series (True , index = df .index )
272273 for column , pattern in (group .get ('condition' ) or {}).items ():
273274
274- if column not in self . logtable :
275+ if column not in logtable :
275276 LOGGER .bcdebug (f"Unknown condition column: { column } " )
276277 continue
277278
278279 # Get the rows that match the expression, i.e. make them True
279- rowgroup &= self . logtable [column ].astype (str ).str .fullmatch (str (pattern ))
280+ rowgroup &= logtable [column ].astype (str ).str .fullmatch (str (pattern ))
280281
281282 # Write the value(s) of the matching rows
282283 for colname , values in (group .get ('cast' ) or {}).items ():
0 commit comments