LineSegmentROI - getArrayRegion

85 views
Skip to first unread message

angust...@gmail.com

unread,
May 7, 2019, 5:45:26 AM5/7/19
to pyqtgraph
I am trying to use a LineSegment ROI to extract a 2D slice from a 3D image. 
There are three axis' in the provided dataset, 0, 1, and 2. 

A 2D image is displayed using x:2, y:1, and t:0 with a slider connected to t, allowing the user to move through the depth of the image.

A line segment ROI is imposed over this 2D image, and I am trying to extract a 2D slice from the image representing a cross section of the displayed 2D image.

The problem I am having is in the following line...

self.testroi.getArrayRegion(self.dataset1, self.imvOCTTopLeft.getImageItem(), axes=(1,2), returnMappedCoords=True)

At the moment this code is successfully producing a cross sectional image, however it is 
retrieving the axis values from the image incorrectly. Ideally, I should be able to set 
axes=(2,1), however when I try to do this I am getting the following error:


"numpy.AxisError: axis 2 is out of bounds for array of dimension 2"

If both axis 2 and 1 exist in the dataset and are accessible in the axes=(1,2) format, why should they not be
accessible in axes=(2,1) format?

Patrick

unread,
May 7, 2019, 10:21:46 PM5/7/19
to pyqtgraph
Hi,

I don't know exactly why you can't do this. The actual work happens in this helper function, but it looks at first glance like it should handle any order of axes tuple. The question is then what is array is being indexed to create that error, and if it is supposed to have three dimensions, why is one of them going missing?

As a workaround, could you transpose either the resulting slice, or the input? So something like:
self.testroi.getArrayRegion(self.dataset1.transpose((0,2,1)), self.imvOCTTopLeft.getImageItem(), axes=(1,2), returnMappedCoords=True)
or 
self.testroi.getArrayRegion(self.dataset1, self.imvOCTTopLeft.getImageItem(), axes=(1,2), returnMappedCoords=True).T

Patrick
Reply all
Reply to author
Forward
0 new messages