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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Soren Christensen-2
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





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
Reply | Threaded
Open this post in threaded view
|

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

Dženan Zukić
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ženan

On Sat, May 5, 2018 at 6:08 PM Soren Christensen <[hidden email]> 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==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




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

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
Reply | Threaded
Open this post in threaded view
|

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

Soren Christensen-2
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ženan Zukić <[hidden email]> 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ženan

On Sat, May 5, 2018 at 6:08 PM Soren Christensen <[hidden email]> 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==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




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

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