This snippet of code:
seems to imply that dat files with name *U16_1024x1024.dat have 600 red and 600 green channels, and 600 values. This seems very different from the interpretation of *U16_1024x512.dat which is understood to have 1024/2=512 red and 1024/2=512 green channels, and 1024 values (this is the logic that has been implemented in wbi).