SilverLabUCL / PySilverLabNWB

Python tools for working with Silver Lab data in the NWB2 format
MIT License
1 stars 0 forks source link

Numerical errors with temporal data conversion? #60

Closed alessandrofelder closed 4 years ago

alessandrofelder commented 4 years ago

The dwell_time, obtained from the header, and the pixel_time_offsets, obtained from the Single_cycle_relatives_times(_HW).txt file, contain data in microsecond.

The CalcDataAnalysis code converts these to milliseconds and works with that. Our current code converts these to seconds and works with that. I wonder whether this can lead to numerical errors in real life examples?

A candidate to check would be the average cycle time in new-labview, as a lot of converted times are summed there.

This issue relates to #59 - we should know what precision guarantees are given by LabView and by the microscope, and ensure that our numerical errors are less than that.

alessandrofelder commented 4 years ago

A small experiment with synthetic data of the right order of magnitude suggests this is unlikely

> in_ms = 1000+np.random.randint(500, size=20000)
> in_s = in_ms/1e6
> np.mean(in_s)
0.0012501052000000001
>np.mean(in_ms)/1e6
0.0012501052
> np.sum(in_s)/20000
0.0012501052000000001
> np.sum(in_ms)/20000/1e6
0.0012501052
> np.mean(in_s)-np.mean(in_ms)/1e6
2.168404344971009e-19
alessandrofelder commented 4 years ago

Closing for now, as none of my manual little Python command line tests (such as the one above) resulted in any worrying differences. Comparing with MatLab results will test this again, too.