slaclab / pydm

Python Display Manager
http://slaclab.github.io/pydm/
Other
111 stars 76 forks source link

Strange Behavior with PyDMImageView and PVA Image #1082

Closed slactjohnson closed 6 days ago

slactjohnson commented 1 month ago

Describe the bug Images accessed using PVA appear to get transposed somehow as compared to CA images. See below with our older CA image viewer on the right, and a small test panel, with the image in question on the right hand side.

I was unable to set the width manually, and setting the readingOrder appeared to have no effect.

More details are in the Slack thread: https://slac.slack.com/archives/C6B8GRCPQ/p1716918965522069

image

Expected behavior Ideally the PVA and CA images would be identical, with the widget picking up the necessary metadata from the PVA image directly

My Platform rhel7-x86_64 pcds-envs 5.8.4

nstelter-slac commented 3 weeks ago

Hi,

So it seems like Pydm is interpreting the image dims in a different order then the request expects.

We are creating the image based on this incoming data (output below is from pvget)

    dimension_t[] dimension
        dimension_t 
            int size 640
            int offset 8
            int fullSize 640
            int binning 2
            boolean reverse false
        dimension_t 
            int size 480
            int offset 3
            int fullSize 480
            int binning 2
            boolean reverse false

We do this by making a numpy shape array 'shape = [dimension[0], dimension[1]]', and then this ordering gets interpreted in numpy as the image having 'height = shape[0], width = shape[1]' (https://github.com/slaclab/pydm/blob/master/pydm/data_plugins/epics_plugins/pva_codec.py)

This is why doing a 'img = img.reshape(480, 640)' on the image-data in Pydm displays the correct image.

Question is: in these requests will first element of dimension_t[] always be 'width' and the second 'height'? (can't find any reference for this in the docs here: https://github.com/epics-base/normativeTypesCPP/wiki/Normative+Types+Specification#ntndarray) If so this can be fixed on Pydm's side.

slactjohnson commented 3 weeks ago

@nstelter-slac and I discussed this on Slack, but wanted to document it here that we think the way to proceed is to make the dimension ordering a configurable parameter so that the widget can be adapted to accommodate either case.