Wrong resolution in absolute terms is printed to vhdr
sappelhoff opened this issue · comments
this is a separate issue from #48
looking at the following code, we see that the "resolution" for each channel first passes through "optimize_channel_unit"
Lines 276 to 281 in 76e8bea
Yet "optimize_channel_unit" changes the resolution to account for conversion of units:
Lines 210 to 227 in 76e8bea
This is the desired behavior for scaling the data at the same time to both (1) from volts to the desired unit, and (2) to the desired resolution. HOWEVER, in the VHDR, the unit and the resolution are noted for each channel. Thus the original resolution prior to going through "optimize_channel_unit" must be written to VHDR
@tstenner do you happen to have time to look into this? 🙂
we should also add a test that does not depend on MNE.
-->
- write data to bv given a vector of different resolutions
- read the resulting vhdr file with bare python
- check that the written and original resolutions match exactly
actually, I am seeing now that we never scale the data to the desired unit. The data is only scaled to the desired resolution in VOLTS, and then written to file.
Then the "resolution" field in vhdr is "abused" to encode both the conversion from volt to the desired unit AND the back-scaling.
This works equivalently, but it's not what the BrainVision spec says. --> the resolution is supposed to be the resolution in units.
Looking at the docstr for resolution I see, that we also require that to be "in volts", instead of in "units" --> so at least we are being consistent there, and it explains why the float32 format roundtrips all pass.
I still think we should change this behavior to be more in line with the BV standard.
And I still have no solution for why the int16 tests fail. #45