Closed graeme-winter closed 1 year ago
Obvious candidates - DLS I23 Pilatus 12M detector, CS-PAD - former is straightforward since we effectively acquire the data as a 2D array so trivial to repack as such. For CS-PAD the detectors do not share a common attitude so more complex.
Not expecting sub-pixel accuracy here - this is just for producing e.g. jpeg or png views of plots etc. in a convenient way
The panel object can/does store the raw_image_offest, i.e. "the offset of the panel into the raw image array", which may be helpful here:
import os
import libtbx.load_env
from dxtbx import datablock
img = libtbx.env.find_in_repositories('dials_regression/image_examples/DLS_I23/germ_13KeV_0001.cbf', test=os.path.isfile)
imgset = datablock.DataBlockFilenameImporter([img]).datablocks[0].extract_imagesets()[0]
detector = imgset.get_detector()
for p in detector:
print(p.get_raw_image_offset())
(0, 0)
(0, 212)
(0, 424)
(0, 636)
(0, 848)
(0, 1060)
(0, 1272)
(0, 1484)
(0, 1696)
(0, 1908)
(0, 2120)
(0, 2332)
(0, 2544)
(0, 2756)
(0, 2968)
(0, 3180)
(0, 3392)
(0, 3604)
(0, 3816)
(0, 4028)
(0, 4240)
(0, 4452)
(0, 4664)
(0, 4876)
E.g. getting a giant 2D pixel array with everything in the right position directly from the image? Presumably the image viewer does this somewhere?
Do not know who best to pick this up.
I have code from another project that does a fast plane fit to points. Using that I could provide a method in Format
that produces 2D fast, slow directions and correctly projected x, y pixel sizes for display of detectors that are mostly coplanar. Cases like I23 would have to do something different, of course. I can add this method if that sounds useful. It has a dependency on numpy.linalg.svd
for the plane fit.
The current image viewer does do something like this already, but I think it is rather image-viewer specific, whereas this would be something that lives in Format
classes
Actually we wouldn't explicitly need the projected pixel sizes if the function just reports the non-unit length 2D fast, slow vectors, and the 2D origin vector for each panel.
As I pointed out above, we can use panel.get_raw_image_offset()
to get the position of the panels in the underlying raw image array. This would work for the curved DLS I23 detector and for all Dectris Pilatus and Eiger detectors (i.e. most of the multi-panel detectors we are likely to care about here at DLS), and result in images that are consistent with what the user would expect to see. This would be a lot simpler than attempting to rediscover this mapping from the 3D panel positions/orientations. I realise that detectors such as the CSPAD would need handling as special cases, as the orientation of panels does not necessarily correspond to their location and orientation within the underlying raw image array.
FWIW with Jungfrau detectors the panels are also written out in a non-obvious order
That has to be set by the format class using set_raw_image_offset
and as far as I can tell it doesn't account for gaps between modules that are not part of the array though. So, it works for DLS, true, but is not a general solution.
I'm browsing old issues, and think this one can be closed as #224 provides the solution.
i.e. if you want to show a picture, show results plotted as x, y or whatever for detectors which are made up from a collection of 2D panels, provide a mechanism to plot these on some larger 2D array.
See https://github.com/dials/dials/issues/575 for background