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

Dženan Zukić <[email protected]> Sun, 06 May 2018 15:52:26 +0000
Newsgroups gmane.comp.lib.itk.user
Message-ID <CAPf2UMRM3kFCOKeehLZ_XVVwJXgouMwyfEmj5-BKUctx41QjSQ@mail.gmail.com>
--===============0623564876==
Content-Type: multipart/alternative; boundary="000000000000cfb0d7056b8b8a2e"

--000000000000cfb0d7056b8b8a2e
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Soren,

progress events do no modify the filter, hence the MTime does not change.
MTime changes when filter's parameters are changed - and only the ones
which require re-computation of the output.

Regards,
D=C5=BEenan

On Sat, May 5, 2018 at 6:08 PM Soren Christensen <[email protected]> wrote:

> 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 thi=
s
> 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=3D=3D0:
>
> thresholder.Update()
>
> print(levelsetfilter.GetMTime()) #print mtime for levelset filter and the=
n
> thresholdfilter
>
> print(thresholder.GetMTime())
>
> print("----")
>
> save_rgb(levelsetfilter.GetOutput(),'mont' + str(k)+ '.png')
>
> k=3Dk+1
>
>
> k=3D0
>
> 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
>
>
>
> 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
>

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

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:verdana,=
sans-serif;font-size:small">Hi Soren,</div><div class=3D"gmail_default" sty=
le=3D"font-family:verdana,sans-serif;font-size:small"><br></div><div class=
=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:small"=
>progress events do no modify the filter, hence the MTime does not change. =
MTime changes when filter&#39;s parameters are changed - and only the ones =
which require re-computation of the output.</div><div class=3D"gmail_defaul=
t" style=3D"font-family:verdana,sans-serif;font-size:small"><br></div><div =
class=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:s=
mall">Regards,</div><div class=3D"gmail_default" style=3D"font-family:verda=
na,sans-serif;font-size:small">D=C5=BEenan</div></div><br><div class=3D"gma=
il_quote"><div dir=3D"ltr">On Sat, May 5, 2018 at 6:08 PM Soren Christensen=
 &lt;<a href=3D"mailto:[email protected]">[email protected]</a>&gt; wrote:<=
br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hi,<div>=C2=A0I am=
 trying to monitor the progress of a levelset filter using a=C2=A0Progresse=
vent=C2=A0callback.</div><div>I am thresholding the level set output with a=
 thresholding filter and this works as expected in terms of the end results=
.</div><div>However,=C2=A0<span style=3D"color:rgb(34,34,34);font-family:ar=
ial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:nor=
mal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-ali=
gn:start;text-indent:0px;text-transform:none;white-space:normal;word-spacin=
g:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-=
decoration-color:initial;float:none;display:inline">=C2=A0I am trying to mo=
nitor the progress of a levelset filter using a=C2=A0Progressevent=C2=A0cal=
lback 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 fun=
ction</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>
The ITK community is transitioning from this mailing list to <a href=3D"htt=
p://discourse.itk.org" rel=3D"noreferrer" target=3D"_blank">discourse.itk.o=
rg</a>. Please join us there!<br>
________________________________<br>
Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer" target=3D"=
_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href=3D"http://www.kitware.com/opensource/opensource.html" rel=3D"norefe=
rrer" target=3D"_blank">http://www.kitware.com/opensource/opensource.html</=
a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href=3D"http://www.kitware.com/products/protraining.php" rel=3D"noreferr=
er" target=3D"_blank">http://www.kitware.com/products/protraining.php</a><b=
r>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href=3D"http://www.itk.org/Wiki/ITK_FAQ" rel=3D"noreferrer" target=3D"_b=
lank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href=3D"https://itk.org/mailman/listinfo/insight-users" rel=3D"noreferre=
r" target=3D"_blank">https://itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div>

--000000000000cfb0d7056b8b8a2e--

--===============0623564876==
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

--===============0623564876==--