background.py 1.1 KB

12345678910111213141516171819202122232425262728
  1. import logging
  2. def get_background_frames(p1_metadata, flags):
  3. onset_frame_first_stimulus = p1_metadata.pulsed_stimuli_handler.get_first_stimulus_onset_frame()
  4. default_background = flags["LE_DefaultBackgroundRange"]
  5. if flags["LE_StimulusBasedBackground"] and onset_frame_first_stimulus is not None:
  6. LE_StartBackground = flags["LE_StartBackground"]
  7. LE_PrestimEndBackground = flags["LE_PrestimEndBackground"]
  8. end_background = onset_frame_first_stimulus - LE_PrestimEndBackground
  9. if end_background <= LE_StartBackground:
  10. logging.getLogger("VIEW").warning(
  11. f"Encountered end_background <= start_background, which is invalid. "
  12. f"Defaulting to the background range {default_background}")
  13. return default_background
  14. else:
  15. return (LE_StartBackground, end_background)
  16. else:
  17. logging.getLogger("VIEW").warning(
  18. f"No stimuli information specified in measurement list file. "
  19. f"Defaulting to the background range {default_background}")
  20. return default_background