@@ -275,56 +275,6 @@ def decorator(f):
275275 self ._hooks ["end" ].append (func )
276276 return self
277277
278- def duration (self , duration : float | list | tuple ):
279- """
280- Auto-close the trial after a fixed or jittered duration.
281-
282- Parameters
283- ----------
284- duration : float or list
285- Duration or (min, max) range for random sampling.
286- """
287- local_rng = random .Random ()
288-
289- if isinstance (duration , (list , tuple )):
290- if len (duration ) == 2 :
291- t_val = local_rng .uniform (* duration )
292- elif len (duration ) == 1 :
293- t_val = duration [0 ]
294- else :
295- raise ValueError (f"Duration list/tuple must have 1 or 2 elements, got { len (duration )} " )
296- elif isinstance (duration , (int , float )):
297- t_val = duration
298- else :
299- raise TypeError (f"Invalid duration type: { type (duration )} " )
300- def auto_close (unit : 'StimUnit' ):
301- unit .set_state (
302- duration = t_val ,
303- timeout_triggered = True ,
304- close_time = core .getTime (),
305- close_time_global = core .getAbsTime ()
306- )
307- return self .on_timeout (t_val , auto_close )
308-
309- def close_on (self , * keys : str ):
310- """
311- Auto-close the trial on specific key press.
312-
313- Parameters
314- ----------
315- keys : str
316- One or more response keys.
317- """
318- def close_fn (unit : 'StimUnit' , key : str , rt : float ):
319- unit .set_state (
320- keys = key ,
321- response_time = rt ,
322- close_time = core .getTime (),
323- close_time_global = core .getAbsTime ()
324- )
325- return self .on_response (list (keys ), close_fn )
326-
327-
328278 def run (self ,
329279 terminate_on_response : bool = True ) -> "StimUnit" :
330280 """Execute the full trial lifecycle.
0 commit comments