Discussion:
[pyqtgraph] PolyLineROI data is not updating correctly when changing (moving/adding) handles
Michael Graupner
2018-09-07 19:42:54 UTC
Permalink
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 :
https://github.com/mgraupe/pyqtgraph

Thanks a lot in advance.

Cheers,
Michael
--
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.
Luke Campagnola
2018-09-09 14:51:08 UTC
Permalink
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
Post by Michael Graupner
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.
https://github.com/mgraupe/pyqtgraph
Thanks a lot in advance.
Cheers,
Michael
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/b388af57-42b8-4cad-87de-12e218b6dfea%40googlegroups.com
<https://groups.google.com/d/msgid/pyqtgraph/b388af57-42b8-4cad-87de-12e218b6dfea%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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/CACZXET9AK89vrr8mbO14O%3D7uXtL5_SBVm4sPBDwP36Ry__e17Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Michael Graupner
2018-09-10 15:14:51 UTC
Permalink
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
Post by Luke Campagnola
Hi Michael!
I think I understand the problem, but let's make sure we are talking about
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
On Fri, Sep 7, 2018 at 12:42 PM Michael Graupner <
Post by Michael Graupner
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.
https://github.com/mgraupe/pyqtgraph
Thanks a lot in advance.
Cheers,
Michael
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/b388af57-42b8-4cad-87de-12e218b6dfea%40googlegroups.com
<https://groups.google.com/d/msgid/pyqtgraph/b388af57-42b8-4cad-87de-12e218b6dfea%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/CACZXET9AK89vrr8mbO14O%3D7uXtL5_SBVm4sPBDwP36Ry__e17Q%40mail.gmail.com
<https://groups.google.com/d/msgid/pyqtgraph/CACZXET9AK89vrr8mbO14O%3D7uXtL5_SBVm4sPBDwP36Ry__e17Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
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/CAFVjdWLXPCKNor2Qum7_QtijQAEymH542VVWejQaPOHhG3aQSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...