schote / nexus-console

MRI console application based on spectrum-instrumentation measurement cards and pulse sequences from pypulseq. Read more in the docs!
https://schote.github.io/nexus-console/
GNU General Public License v3.0
11 stars 3 forks source link

BUG: When unrolling TSE sequence unblanking signal is incorrect #10

Closed schote closed 1 year ago

schote commented 1 year ago

34e6cfc7-8972-493a-8c4c-21ea59aeba0f

schote commented 1 year ago

Potential reasoning:

schote commented 1 year ago

Minimal example to reproduce the root of the problem:

data = np.int16(6000) >> 1 | (0 << 15)
print(f"A: {np.int16(data << 1)}; D: {np.int16(data >> 15)}")
data = np.int16(6000) >> 1 | (1 << 15)
print(f"A: {np.int16(data << 1)}; D: {np.int16(data >> 15)}")
data = np.int16(-6000) >> 1 | (0 << 15)
print(f"A: {np.int16(data << 1)}; D: {np.int16(data >> 15)}")
data = np.int16(-6000) >> 1 | (1 << 15)
print(f"A: {np.int16(data << 1)}; D: {np.int16(data >> 15)}")

Output:

A: 6000; D: 0
A: 6000; D: 1
A: -6000; D: -1
A: -6000; D: -1
schote commented 1 year ago

Use the following workaround: np.uint16(value) >> 1 | digital Transform the int16 value to uint16 before shifting. Since the manipulate the bitorder anyway (by using 15th bit as digital and 14th bit as new MSB of analog value) the value is not a true int16 value anymore