IBT-FMI / COSplay

Contrast Optimized Stimulation player
http://cosplay.readthedocs.io/en/latest
GNU General Public License v3.0
2 stars 3 forks source link

Floating point inaccuracies #29

Open TheChymera opened 6 years ago

TheChymera commented 6 years ago

An onset time of 810.0 s (.tsv file below)

onset   duration    frequency   pulse_width amplitude   out_channel wavelength  strength    strength_unit
160.0   20.0    15.0    0.005   1.0 1.0 488.0   30.0    mW
290.0   20.0    15.0    0.01    1.0 1.0 488.0   30.0    mW
420.0   20.0    25.0    0.005   1.0 1.0 488.0   30.0    mW
550.0   20.0    25.0    0.01    1.0 1.0 488.0   30.0    mW
680.0   20.0    15.0    0.005   1.0 1.0 488.0   30.0    mW
810.0   20.0    15.0    0.01    1.0 1.0 488.0   30.0    mW
940.0   20.0    25.0    0.005   1.0 1.0 488.0   30.0    mW
1070.0  20.0    25.0    0.01    1.0 1.0 488.0   30.0    mW
1200.0  20.0    15.0    0.005   1.0 1.0 488.0   30.0    mW
1330.0  20.0    15.0    0.01    1.0 1.0 488.0   30.0    mW
1460.0  20.0    25.0    0.005   1.0 1.0 488.0   30.0    mW
1590.0  20.0    25.0    0.01    1.0 1.0 488.0   30.0    mW

is represented by COSplay as 809.9999:

Searching port...
Connection to /dev/ttyACM1 established.

Sequences found on computer:
None
Size of sequence library: 1

Current sequence:
onset   duration        frequency       pulse_width     amplitude       out_channel     wavelength      strength        strength_unit
160.0   20.0    15.0    0.005   1.0     1.0     488.0   30.0    mW
290.0   20.0    25.0    0.005   1.0     1.0     488.0   30.0    mW
420.0   20.0    15.0    0.01    1.0     1.0     488.0   30.0    mW
550.0   20.0    25.0    0.01    1.0     1.0     488.0   30.0    mW
680.0   20.0    15.0    0.005   1.0     1.0     488.0   30.0    mW
809.9999        20.0    25.0    0.005   1.0     1.0     488.0   30.0    mW
940.0   20.0    15.0    0.01    1.0     1.0     488.0   30.0    mW
1070.0  20.0    25.0    0.01    1.0     1.0     488.0   30.0    mW
1200.0  20.0    15.0    0.005   1.0     1.0     488.0   30.0    mW
1330.0  20.0    25.0    0.005   1.0     1.0     488.0   30.0    mW
1460.0  20.0    15.0    0.01    1.0     1.0     488.0   30.0    mW
1590.0  20.0    25.0    0.01    1.0     1.0     488.0   30.0    mW

I assume this is because there is no precise 810.0 s floating point, and at any rate this is not mitigated by passing 810 time (without the decimal point). Still, to avoid errors in record keeping, ideally COSplay should record the instructions it receives and it executes. If there is no way to distinguish 809.9999 from 810.0 that means it's just as correct to record 810.0. @faymanns thoughts?