AllenNeuralDynamics / dynamic-foraging-task

Bonsai/Harp workflow for Dynamic Foraging with Python GUI for visualization and control
MIT License
5 stars 4 forks source link

Add reward delivery to dev #454

Closed ZhixiaoSu closed 2 months ago

ZhixiaoSu commented 2 months ago

Pull Request instructions:

Describe changes:

  1. Added 'reward delay' field to nwb.trials. It is a delay between choice time and reward delivery.
  2. Additional description about 'reward_outcome_time': It is time when choice is registered.

    What issues or discussions does this update address?

    This columns makes it possible to calculate actual reward delivery time when there's a reward delay in session.

    Describe the expected change in behavior from the perspective of the experimenter

    There will be no change in behavior.

    Describe any manual update steps for task computers

    There will be no manual update,

    Was this update tested in 446/447?

    No, it is tested locally on my laptop and desktop.

Additional info:

In current version, 'reward_outome_time' is the time when reward is determined, not when it is delivered. If a choice is made, it's time of first lick, if not, it's time of end of lick window. It makes sense in sessions where there's no reward delay. But when we introduce a reward delay, this time should be called 'response_time' or 'decision_time' and additional 'reward_delay' information (not saved in nwb yet) should be added to calculate time of outcome.

Given how big impact this file may have downstream, minimum change is made here to enable analysis. One column called 'reward_delay' was added to NWB.

XX-Yin commented 2 months ago

@ZhixiaoSu There is an edge case. The old session does not have obj.TP_RewardDelay.

ZhixiaoSu commented 2 months ago

@ZhixiaoSu There is an edge case. The old session does not have obj.TP_RewardDelay.

@XX-Yin Can I fix it by first checking if it has the field? If it doesn't, I'll put it as 0.0.

XX-Yin commented 2 months ago

0.0

Yes, it will work. You can run the file directly to pass the test.

ZhixiaoSu commented 2 months ago

Update: set default to 0 to take care of earlier sessions without reward delay parameter by setting it to 0.