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

Water Calibration overhaul #502

Closed alexpiet closed 3 months ago

alexpiet commented 4 months ago

Pull Request instructions:

Describe changes:

What issues or discussions does this update address?

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

When you open the water calibration dialog, it will look like this:

MicrosoftTeams-imagef0a6eee9a98f5fc5be41f31683ebefb2c48f9149acb48497197222caedb2187e

After pressing Calibrate Left, you will be prompted to enter the before weight:

MicrosoftTeams-imagec32d4f56aafb9bcfb84a8746652a3560f33bda23123ae99b0bc2747547e6ba64

The calibration will run and provide progress reports in purple text. When its finished, you will be prompted to enter the after weight.

MicrosoftTeams-image6e2e3fb1a8061e81f3d0cff9e63396aa69be31f67eebfae8a7975da8b02d7d6a

You can then press "Continue" to perform the next measurement. "Repeat" to repeat the measurement of the valve open time currently selected. Or "Finish" to stop measurements. You can perform repeats immediately, or do all measurements and then repeat any measurements you like.

MicrosoftTeams-image500609bbec3c8ab9d571f6c80238fb0fb3214c024a596e541c2667477f064bc5

Describe any manual update steps for task computers

Was this update tested in 446/447?

alexpiet commented 4 months ago

Consistency of new calibration code with old calibration code

calibration_test

In order to test the new calibration system. I calibrated 1A several times, the results are plotted here. The labels are confusing:

We observe a difference in slope between the calibrations (all done today, in a row), and previous calibrations. But all of today's calibrations on old and new system are in agreement. I conclude the new system works, and 0.1s intervals are fine

alexpiet commented 4 months ago

Consistency of calibration across 8 measurements

To assess what threshold we should use for valve drift, I performed 8 spot checks in a row targetting 2uL volumes. I got back: 2.1 +/- 0.0299 mg (mean +/- std). None of the samples would have been flagged by my proposed tolerance of 10% error ( < 1.8, or > 2.2 mg).

If we had used the old calibration settings to target the 2uL volumes, then the results would have been flagged.

I conclude the spot checks are valuable, and the tolerance I used is ok.

I attach to this comment the results of the water calibration test

calibration_notes.txt

Test_1_WaterCalibration_1.json

alexpiet commented 4 months ago

@XX-Yin @hanhou This is ready for review. See two validation test results in the comments

XX-Yin commented 4 months ago

@alexpiet Overall it looks good. I don't have time to review it this week. I will review it next week so we can merge it next week.

alexpiet commented 3 months ago

@hanhou @XX-Yin I added two additional features, and this is ready to review again:

XX-Yin commented 3 months ago

@alexpiet It's better the GUI can be open without the WaterCalibrationPar_#.json. We can set some default parameters.

alexpiet commented 3 months ago

@alexpiet It's better the GUI can be open without the WaterCalibrationPar_#.json. We can set some default parameters.

Good call @XX-Yin. I updated the code to: