Anna4142 / PrisonerDilemmaPy

1 stars 0 forks source link

Reward Valve Control #64

Closed MickyHoltzman closed 5 months ago

MickyHoltzman commented 5 months ago

I have a feeling we are not controlling the valve opening times accurately enough. This feeling is only getting stronger in light of the fact that the mice are learning the wrong strategy.

Before we make a final decision let's test it. Ben has these neat digital signal recorders. Take one of them, connect the valve control signal to the recorder (in parallel). Maybe even all of the valves, the thing probably has more then one channel.

record a session and let's see how accurate we are.

Do you want me to get Ben involved in this discussion, or will you do it?

Anna4142 commented 5 months ago

I spent the whole day stuck on this issue today as you are right .The minimum opening time of all valves seems to be 1.2 seconds.values greater than that are accurate .there is no problem in the hardware as I have tested it independently of the rest of the code .I feel the latency is induced because of the camera and all the other processing that takes place between opening and closing the valves .we need to restucture the ValveControl to manage this(perhaps use threading).I will open a new branch to test this further

Also I checked the issue with both the simulated version of the arduino and real version and the default minimum value of 1.2 seconds persists

Anna4142 commented 5 months ago

Here is the output for you to get more isnsight on the problem

Event logged: Trial 0, Event: States.CenterReward, Time: 1706449729.804132 {} delivering to valve 4 start open 1706449729.804132 Arduino Digital channel 11 set to Low. Time Stamp= 48:49.804132 Current State: States.TrialStarted Event logged: Trial 0, Event: States.TrialStarted, Time: 1706449731.1044877 open Arduino Digital channel 11 set to High. Time Stamp= 48:51.104487 open duration 1.3003556728363037

The opening time was set to 0.1!!

Anna4142 commented 5 months ago

Upon further investigation ive found the root of the problem which is the VideoAnalyser.

'Start Time': 1706450949.1417592, 'Decision Time': 6.491410732269287, 'Return Time': 0} time in mm 1706450968.6213531 delivering to valve 4 time in rm 1706450968.6213531 opening time in vc 1706450968.6213531 Arduino Digital channel 11 set to Low. Time Stamp= 09:28.621353 time in video analyser 1706450968.6213531 Current State: States.TrialStarted Event logged: Trial 1, Event: States.TrialStarted, Time: 1706450969.9076698 open Arduino Digital channel 11 set to High. Time Stamp= 09:29.907669 open duration 1.2863166332244873 time in video analyser 1706450969.9076698 time in video analyser 1706450971.220732 time in video analyser 1706450972.5290272 time in video analyser 1706450973.8329542 time in video analyser 1706450975.1338713

As you can see the time to process each frame is approximately 1.3 seconds which corresponds to the the minimum valve opening time.I will look at how I can further reduce this time but i doubt that I can bring it down to values as low as 0.002 seconds