PolyLineROI data is not updating correctly when changing (moving/adding) handles

84 views
Skip to first unread message

Michael Graupner

unread,
Sep 7, 2018, 3:42:54 PM9/7/18
to pyqtgraph
Hello, 

I have been working on the ImageView class since I wanted to be able to add multiple PolyLineROIs to the view and display the roiCurves alltogether in the view below. These two features work well. 

However, when I change the handles of an individual roi, or add an handle, the roiCurve does diplay false values. Something must be in the getArrayRegion function or around. I am not quite sure where to start looking and would appreciate any hint. 

The behavior can be tested by running  roiAnalysis.py here : 

Thanks a lot in advance.

Cheers,
Michael 

Luke Campagnola

unread,
Sep 9, 2018, 10:51:37 AM9/9/18
to pyqt...@googlegroups.com
Hi Michael!
I think I understand the problem, but let's make sure we are talking about the same behavior. This is what I did:

1. run roiAnalysis.py from your develop branch
2. `imv.addROI([0, 0])` from command line
3. Drag a handle; values in ROI plot change even if the average value within the ROI should have been unchanged

The reason for this behavior is that getArrayRegion returns an array of the _rectangular_ region around the ROI, with anything outside the ROI set to 0. If you take the mean over this array, then all those 0s get mixed into the mean. A really simple option here is to add the ability to specify a default value other than 0. You could then call getArrayRegion with default=nan and use np.nanmean to get the correct value.


Luke

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/b388af57-42b8-4cad-87de-12e218b6dfea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Graupner

unread,
Sep 10, 2018, 11:15:04 AM9/10/18
to pyqt...@googlegroups.com
Hi Luke,

thanks a lot for your help. You were exactly right. It was the '0' averaging which screwed up the roi plot. Implementing a change of the zero's in the mask in ROI.py to nan and using nanmean fixed the problem. 

Thanks.

Cheers,
Michael

Reply all
Reply to author
Forward
0 new messages