Aharoni-Lab / miniscope-io

Data formatting, reading, and writing from miniscopes
https://miniscope-io.readthedocs.io
GNU Affero General Public License v3.0
6 stars 2 forks source link

[bugfix] vertical banding in wireless daq from double-reversed bit ordering #16

Closed sneakers-the-rat closed 4 months ago

sneakers-the-rat commented 9 months ago

we were getting images like this, where each of the vertical bands is flipped horizontally.

0552

Each of those bands is 4px wide, so there had to be some 32-bit buffer being inverted horizontally.

The problem is here: https://github.com/Aharoni-Lab/miniscope-io/blob/dcb88a3ca2bae75a4689caba8a8a18608d9e3edd/miniscope_io/stream_daq.py#L375-L383

where it correctly inverts each group of four pixels, but doesn't reverse the indexing across groups of four pixels.

The fix is to reverse the range iterator:

if self.LSB:
    pixel_vector = Array(
        "uint:32",
        [
            pixel_vector[i : i + 32][::-1].uint
            for i in reversed(range(0, len(pixel_vector), 32))
        ],
    )

following with PR