[Insight-users] Re sampleImageFilter and ITK_USE_OPTIMIZED_REGISTRATION_METHODS
Bradley Lowekamp
blowekamp at mail.nih.gov
Thu Oct 22 16:06:14 EDT 2009
Hello,
It sounds like you are doing your own threading, and you have multiple
threads trying to execute the pipeline. ITK expects only one thread to
be executing or updating the pipeline. The pipeline is not thread safe
in the way you appear to be assuming. This would explain the sporadic
crashing.
Brad
On Oct 22, 2009, at 3:54 PM, Pete79 wrote:
>
> Luis, hi.
>
>
> Luis Ibanez wrote:
>>
>> The Resample image filter already knows how to distribute
>> its load over multiple threads. There is no benefit in you
>> trying to do that distribution manually.
>>
>
> There is a benefit in a way I'm also using a bunch of my own
> subroutines
> that perform heavy computations after affine transforms of let's say
> 2000
> regions per image are completed. Therefore, I do prefer to keep a
> local
> affine transformed image object in each thread and further feed it
> to my
> subroutines rather than process sequentially (although with
> multithreading)
> all regions, keep pointers to 2000 images and then pass them to my
> custom
> threads when launched ... if you get my drift.
>
>
>
>> You can easily verify this by running any of the many
>> examples in the directory:
>>
>
> Thanks, I am really familiar with them by now, though there is nothing
> challenging about the whole case. I know that when images are large,
> it can
> basically split the load into multiple jobs.
>
>
>
>> Please let us know what you find.
>>
>
> This may be the most startling, but it looks I've tracked down the
> bug that
> was sporadically happening - let's say once a 1000 files processed. I
> cannot vouch I'm 100% sure my code is bug-free, but I was fiddling and
> testing behaviour of the code on a large dataset to be sure that I can
> reproduce these crashes, and ...
>
> when I chucked out RegionOfInterestImageFilter and replaced it with my
> custom code, all problems disappeared finally (at least I cannot spot
> nothing wrong at the moment).
>
> The code in the custom thread subroutine used to be as follows:
>
> // <== for picking up a desired ROI
> ITKLabROIFSPT pfROIOfLabsIm=ITKLabROIFT::New();
> ITKOrigBWROIFSPT pfROIOfOrigBWIm=ITKOrigBWROIFT::New();
>
> // <== inputs of ROI filters are set up for every instance of a
> filter
> pfROIOfLabsIm->SetInput(piLabsInC);
> pfROIOfOrigBWIm->SetInput(piOrigBWC);
>
> // <== sets up ROI of a ROI filter
> pfROIOfLabsIm->SetRegionOfInterest(xRegPairOfSegs);
> pfROIOfOrigBWIm->SetRegionOfInterest(xRegPairOfSegs);
>
> pfROIOfLabsIm->SetNumberOfThreads(1);
> pfROIOfOrigBWIm->SetNumberOfThreads(1);
>
> pfROIOfLabsIm->Update();
> pfROIOfOrigBWIm->Update();
>
> I've made sure I wasn't requesting a region outside of image
> dimensions, but
> it still kept crashing once a blue moon when launched in a thread
> (even when
> it was left out solely alone in the thread code).
>
> I just replaced it with:
> // <== for picking up desired ROI
> ITKLabsInImSPT piROIOfLabsIm;
> CloneImage<ITKLabsInImT, ITKLabsInImT>(piLabsInC, xRegPairOfSegs,
> piROIOfLabsIm);
>
> ITKOrigBWImSPT piROIOfOrigBWIm;
> CloneImage<ITKOrigBWImT, ITKOrigBWImT>(piOrigBWC, xRegPairOfSegs,
> piROIOfOrigBWIm);
>
>
> And the CloneImage is defined more or less as the following:
> NewImage<ITKOutputImT>(rpiOutputImC, rxRegInputImC);
>
> ITKInputImItT itITKInputIm_i(piInputImC, rxRegInputImC);
> ITKOutputImItT itITKOutputIm_i(rpiOutputImC, rxRegInputImC);
>
> for (itITKInputIm_i.GoToBegin(), itITKOutputIm_i.GoToBegin();
> !itITKInputIm_i.IsAtEnd(); ++itITKInputIm_i, ++itITKOutputIm_i)
> itITKOutputIm_i.Set(itITKInputIm_i.Get());
>
> It allocates desired ROI image and links with a smart pointer, sets
> up a ROI
> for iterator which copies from a source to destination.
>
> From that moment on all issues have gone away.
>
> Further, I consider ROI filter is rather straightforward, cannot see
> where I
> could have made an error, if any really. What do you reckon? Any
> chance the
> whole mishandling happened inside ROI filter? If so, that'd amount
> to a bug
> ...
>
>
> Many Thanks,
> Peter
> --
> View this message in context: http://www.nabble.com/ResampleImageFilter-and-ITK_USE_OPTIMIZED_REGISTRATION_METHODS-tp25967879p26016179.html
> Sent from the ITK - Users mailing list archive at Nabble.com.
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
========================================================
Bradley Lowekamp
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091022/e5b7b727/attachment.htm>
More information about the Insight-users
mailing list