NXmx has no field for the depth of the stored image - only bit_depth_readout, "how many bits the electronics record per pixel". The two diverge exactly when summation is used: the readout keeps the detector's native width while the summed image must be wider to hold the sum. Every NXmx reader nonetheless takes bit_depth_readout as the width of the stored pixel. dxtbx ignores the non-standard bit_depth_image entirely for a generic NXmx file, derives its masking markers from bit_depth_readout, and raises "Unsupported integer dtype uint32" for a 32-bit image when the field is absent. Reporting the electronic value there would mislead precisely where it differs. So report the image depth in both fields, and drop the machinery that existed to carry the electronic one for a DECTRIS detector: the SIMPLON read, the DetectorSetup setter, and the receiver-side propagation of a key that the DECTRIS stream2 protocol does not even define. JUNGFRAU and PSI EIGER keep their readout depth, which the FPGA acquisition genuinely needs. Also write NXmx underload_value, the lowest valid value. Without it a reader takes the trusted minimum to be -0x7FFFFFFF, so the error-pixel marker sits inside the trusted range and is consumed as an intensity. Measured with DIALS 3.27 on a written file: trusted_range goes from (-2147483647, 32766) to (-32767, 32766), so the INT16_MIN gap pixels are now masked. Third fix in the same area: JFJochReceiverLite::Configure took the image width from the incoming stream but not the sign, while the image itself is forwarded byte-for-byte. A detector sending int32 was re-declared uint32, and the VDS master was typed unsigned over signed data files. Take pixel_signed from the stream too - it and the width are both carried by the one image_dtype key. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
69 lines
2.8 KiB
C++
69 lines
2.8 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "../common/print_license.h"
|
|
#include "../common/Logger.h"
|
|
#include "../detector_control/DectrisSimplonClient.h"
|
|
#include "../preview/JFJochTIFF.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
print_license("jfjoch_simplon_test");
|
|
|
|
Logger logger("jfjoch_simplon_test");
|
|
logger.Verbose(true);
|
|
|
|
if ((argc != 2) && (argc != 3)) {
|
|
std::cout << "Usage: ./jfjoch_simplon_test <DECTRIS Simplon hostname/IP> {<port>}" << std::endl;
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
uint16_t port = 80;
|
|
if (argc == 3)
|
|
port = atoi(argv[2]);
|
|
|
|
DetectorSetup setup = DetDECTRIS(1,1,"Detector1", argv[1]);
|
|
DectrisSimplonClient cli(argv[1], port);
|
|
DiffractionExperiment experiment(setup);
|
|
try {
|
|
cli.ReadDetectorConfig(setup);
|
|
} catch (const JFJochException &e) {
|
|
logger.ErrorException(e);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
logger.Info("State {}", to_string(cli.GetState()));
|
|
logger.Info("Serial number {}", setup.GetSerialNumber() );
|
|
logger.Info("Width {:8d} pxl", setup.GetGeometry().GetWidth(true));
|
|
logger.Info("Height {:8d} pxl", setup.GetGeometry().GetHeight(true));
|
|
logger.Info("Sensor material {}", setup.GetSensorMaterial() );
|
|
logger.Info("Sensor thickness {:8.1f} um", setup.GetSensorThickness_um());
|
|
logger.Info("Pixel size {:8.1f} um", setup.GetPixelSize_mm() * 1e3f);
|
|
logger.Info("Readout time {:8d} ", setup.GetReadOutTime().count());
|
|
logger.Info("Min count time {:8d}", setup.GetMinCountTime().count());
|
|
logger.Info("Min frame time {:8d}", setup.GetMinFrameTime().count());
|
|
logger.Info("Min threshold {:8.2f} keV", setup.GetMinThreshold_keV());
|
|
|
|
auto mask = cli.GetPixelMask();
|
|
logger.Info("Pixel mask size {:8d}", mask.size());
|
|
|
|
CompressedImage image(mask, setup.GetGeometry().GetWidth(true),
|
|
setup.GetGeometry().GetHeight(true));
|
|
WriteTIFFToFile("det_mask.tiff", image);
|
|
|
|
if (setup.GetBitDepthImage())
|
|
logger.Info("Bit depth image {:8d}", setup.GetBitDepthImage().value());
|
|
|
|
experiment.FrameTime(std::chrono::milliseconds(100), std::chrono::milliseconds(10))
|
|
.IncidentEnergy_keV(8.0)
|
|
.NumTriggers(5).ImagesPerTrigger(2).BeamX_pxl(234).BeamY_pxl(345).DetectorDistance_mm(100.0);
|
|
experiment.ImportDetectorSettings(experiment.GetDetectorSettings().EigerThreshold_keV(3.2));
|
|
|
|
try {
|
|
cli.ConfigureDetector(experiment);
|
|
} catch (const JFJochException &e) {
|
|
logger.ErrorException(e);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
exit(EXIT_SUCCESS);
|
|
}
|