stytra icon indicating copy to clipboard operation
stytra copied to clipboard

Clean-up Experiment dependencies inside Stimulus

Open fedem-p opened this issue 2 years ago • 1 comments

With this PR the protocol runner passes the calibrator object from the method initialise_external(). To avoid problems with existing custom stimuli which may have rewritten the method I added two warnings.

More specifically I expect two cases to throw errors:

  1. if the protocol runner calls a custom stimulus where the initialise_external() function doesn't accept the calibrator input.
  2. if the function initialise_external() is used without passing the calibrator input.

To fix 1:

in the protocol runner there's a try{} except{} block that tries to feed the calibrator object to the stimulus initialise_external() function. If this doesn't work then the protocol runner raises a warning and then calls the function without the calibrator input.

To fix 2:

the initialise_external() has an optional argument calibrator which has default value -999, if the default value is detected then the self._calibrator is initialized with the self._experiment and a warning is given to the user. else the self._calibrator is initialized with the calibrator input

Finally:

In all the others default stimuli the _calibrator object is used instead of _experiment.calibrator

fedem-p avatar Mar 01 '22 15:03 fedem-p