[ITK-users] strange filter behavior in Progressevent callback in itkwrap

Soren Christensen <[email protected]> Sat, 5 May 2018 15:07:25 -0700
Newsgroups gmane.comp.lib.itk.user
Message-ID <CAHfsrRaa=WoeAd8AVmc7ryzJZ0jCmgoKbbygH782knQLUnTW-A@mail.gmail.com>
--===============1430945494==
Content-Type: multipart/alternative; boundary="001a114fd39635aa65056b7cabd7"

--001a114fd39635aa65056b7cabd7
Content-Type: text/plain; charset="UTF-8"

Hi,
 I am trying to monitor the progress of a levelset filter using
a Progressevent callback.
I am thresholding the level set output with a thresholding filter and this
works as expected in terms of the end results.
However,  I am trying to monitor the progress of a levelset filter using
a Progressevent callback and it is not working inside the progressevent
callback.

Here's the code:
....
Set up level and threshold filter
...
#define call back function

def myCommand():

global k

if k % 10==0:

thresholder.Update()

print(levelsetfilter.GetMTime()) #print mtime for levelset filter and then
thresholdfilter

print(thresholder.GetMTime())

print("----")

save_rgb(levelsetfilter.GetOutput(),'mont' + str(k)+ '.png')

k=k+1


k=0

levelsetfilter.AddObserver(itk.ProgressEvent(), myCommand )

levelsetfilter.Update()



The output from the print statements are:

18702 *18145* ---- 18738 *18145* ---- 18765 *18145* ---- 18792 *18145* ----
18819 *18145* ...

...

...


So the mtime for the threshold filter never gets modified when inside the
call back.


What is the reason for this? Is there something particular about the
execution pipeline when inside a callback like this?


Thanks!

Soren

--001a114fd39635aa65056b7cabd7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div>=C2=A0I am trying to monitor the progress of a lev=
elset filter using a=C2=A0Progressevent=C2=A0callback.</div><div>I am thres=
holding the level set output with a thresholding filter and this works as e=
xpected in terms of the end results.</div><div>However,=C2=A0<span style=3D=
"color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-styl=
e:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight=
:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:=
none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);=
text-decoration-style:initial;text-decoration-color:initial;float:none;disp=
lay:inline">=C2=A0I am trying to monitor the progress of a levelset filter =
using a=C2=A0Progressevent=C2=A0callback and</span>=C2=A0it is not working =
inside the progressevent callback.</div><div><br></div><div>Here&#39;s the =
code:</div><div>....</div><div>Set up level and threshold filter</div><div>=
...</div><div>#define call back function</div><div>

<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">def myCommand(=
):</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">    global k</=
p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">    if k % 10=
=3D=3D0:</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        thresh=
older.Update()</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        print(=
levelsetfilter.GetMTime())    #print mtime for levelset filter and then thr=
esholdfilter</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        print(=
thresholder.GetMTime())</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        print(=
&quot;----&quot;)</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        save_r=
gb(levelsetfilter.GetOutput(),&#39;mont&#39; + str(k)+ &#39;.png&#39;)</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">        </p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">    k=3Dk+1</p=
><br></div><div>

<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap"><br></p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">k=3D0</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">levelsetfilter=
.AddObserver(itk.ProgressEvent(), myCommand )</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap">levelsetfilter=
.Update()</p>
<p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p sty=
le=3D"margin:0px;text-indent:0px;white-space:pre-wrap"><br></p><p style=3D"=
margin:0px;text-indent:0px;white-space:pre-wrap">The output from the print =
statements are:</p><p style=3D"margin:0px;text-indent:0px"><span style=3D"w=
hite-space:pre-wrap">18702
<b>18145</b>
----
18738
<b>18145</b>
----
18765
<b>18145</b>
----
18792
<b>18145</b>
----
18819
<b>18145</b>
</span>...</p><p style=3D"margin:0px;text-indent:0px">...</p><p style=3D"ma=
rgin:0px;text-indent:0px">...</p><p style=3D"margin:0px;text-indent:0px"><b=
r></p><p style=3D"margin:0px;text-indent:0px">So the mtime for the threshol=
d filter never gets modified when inside the call back.</p><p style=3D"marg=
in:0px;text-indent:0px"><br></p><p style=3D"margin:0px;text-indent:0px">Wha=
t is the reason for this? Is there something particular about the execution=
 pipeline when inside a callback like this?</p><p style=3D"margin:0px;text-=
indent:0px"><br></p><p style=3D"margin:0px;text-indent:0px">Thanks!</p><p s=
tyle=3D"margin:0px;text-indent:0px">Soren</p><br></div><div><br></div><div>=
<br></div></div>

--001a114fd39635aa65056b7cabd7--

--===============1430945494==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users

--===============1430945494==--