Decoding and threshold determination