Re: [ITK-users] strange filter behavior in Progressevent callback in itkwrap
Soren Christensen <[email protected]> Mon, 07 May 2018 02:45:08 +0000
| Newsgroups | gmane.comp.lib.itk.user |
|---|---|
| Message-ID | <CAHfsrRb=cajyDuVQ6jtEWDKb=5BuOsbzOZzZf3uprJWEP7dWLQ@mail.gmail.com> |
--===============1599727879== Content-Type: multipart/alternative; boundary="089e0825047c0d1151056b94a95f" --089e0825047c0d1151056b94a95f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Dzenan, Thanks! It does seem that the level sets filter mtime is changing though (top number)? I managed to get it working by initializing the threshold filter inside the progress callback. The output now changes with each callback. Thanks! Soren On Sun, May 6, 2018, 08:52 D=C5=BEenan Zuki=C4=87 <[email protected]> wrote= : > 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 >> 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=3D=3D0: >> >> 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=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 th= e >> 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 >> > --089e0825047c0d1151056b94a95f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div>Hi Dzenan,</div><div dir=3D"auto">=C2=A0Thanks!</div= ><div dir=3D"auto">It does seem that the level sets filter mtime is changin= g though (top number)?</div><div dir=3D"auto">I managed to get it working b= y initializing the threshold filter inside the progress callback. The outpu= t now changes with each callback.</div><div dir=3D"auto"><br><br>Thanks!</d= iv><div dir=3D"auto">Soren<br><br><br><div class=3D"gmail_quote" dir=3D"aut= o"><div dir=3D"ltr">On Sun, May 6, 2018, 08:52 D=C5=BEenan Zuki=C4=87 <<= a href=3D"mailto:[email protected]" target=3D"_blank" rel=3D"noreferrer">dz= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail_quote" s= tyle=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" 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:small">pr= ogress events do no modify the filter, hence the MTime does not change. MTi= me changes when filter's parameters are changed - and only the ones whi= ch require re-computation of the output.</div><div class=3D"gmail_default" = style=3D"font-family:verdana,sans-serif;font-size:small"><br></div><div cla= ss=3D"gmail_default" style=3D"font-family:verdana,sans-serif;font-size:smal= l">Regards,</div><div class=3D"gmail_default" style=3D"font-family:verdana,= sans-serif;font-size:small">D=C5=BEenan</div></div><br><div class=3D"gmail_= quote"><div dir=3D"ltr">On Sat, May 5, 2018 at 6:08 PM Soren Christensen &l= t;<a href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer" target= =3D"_blank">[email protected]</a>> wrote:<br></div><blockquote class=3D"= gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-= left:1ex"><div dir=3D"ltr">Hi,<div>=C2=A0I am trying to monitor the progres= s of a levelset filter using a=C2=A0Progressevent=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<spa= n style=3D"color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small= ;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;f= ont-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;display:inline">=C2=A0I am trying to monitor the progress of a levels= et filter using a=C2=A0Progressevent=C2=A0callback and</span>=C2=A0it is no= t 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(= "----")</p> <p style=3D"margin:0px;text-indent:0px;white-space:pre-wrap"> save_r= gb(levelsetfilter.GetOutput(),'mont' + str(k)+ '.png')</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 noreferrer noreferrer" target=3D"_= blank">discourse.itk.org</a>. Please join us there!<br> ________________________________<br> Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer noreferrer = 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 noreferrer noreferrer" target=3D"_blank">http://www.kitware.com/openso= urce/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 noreferrer noreferrer" target=3D"_blank">http://www.kitware.com/products= /protraining.php</a><br> <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 noreferrer no= referrer" target=3D"_blank">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 noreferrer noreferrer" target=3D"_blank">https://itk.org/mailman/listinfo= /insight-users</a><br> </blockquote></div> </blockquote></div></div></div> --089e0825047c0d1151056b94a95f-- --===============1599727879== 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 --===============1599727879==--