[Insight-users] Problem with itkN3MRIBiasFieldCorrectionImageFilter
ntustison at gmail.com
ntustison at gmail.com
Wed Oct 14 20:44:04 EDT 2009
Well, that's good. Let me know what you find out.
On Oct 14, 2009 8:17pm, Ricardo Ferrari <ricardo.jose.ferrari at gmail.com>
wrote:
> Hi Nick,
> The most funny thing!!! The error I was getting was when using my
> PC-workstation at University. Now, I am at home and I have just checked
> out the code from my svn repository (the same one I was testing at Univ)
> and I am not getting the error anymore.
> I believe it is something related to the ITK lib. I have re-compiled the
> svn ITK in my home machine last night.
> Tomorrow, I am going to compare the ITK configurations to see if there is
> any difference.
> I will keep you update on this.
> Thanks again,
> Ricardo
> On Wed, Oct 14, 2009 at 9:01 PM, Nicholas Tustison ntustison at gmail.com>
> wrote:
> Hi Ricardo,
> Okay, now I understand. In that case, I have two other suggestions:
> 1) In the output of your code below
> cout GetOrigin() cout GetSpacing()
> cout GetLargestPossibleRegion().GetSize() cout GetDirection() cout
> m_NumberOfFittingLevels
> cout m_SplineOrder cout m_NumberOfControlPoints
> can you also add
> cout GetNumberOfPoints()
> 2) Also, could you see what happens if you convert your minc file to
> nifti or some other format?
> Nick
> On Oct 14, 2009, at 7:55 PM, Ricardo Ferrari wrote:
> Hi Nick,
> Thanks for your e-mail.
> Actually, I am not submitting a mask of all zeros because I am saving and
> checking the resulting mask image obtained from the Otsu threshold.
> What I´ve meant by "m_maskImage is purposely equal to zero" in the source
> code is that I have set the pointer to 0 (NULL) so that the mask could be
> computed by using the Otsu thresh. As I said, the mask seems to be okay -
> I have visually checked it.
> The funny thing is if I do not downsample the image (and the mask, of
> course) I have no problems. I have also checked both the downsampled
> image & mask, and apparentely (by visually checking) everything is fine.
> I will keep trying to figure out the problem!!! Any suggestion is
> welcome !!
> Thanks,
> Ricardo
> On Wed, Oct 14, 2009 at 7:29 PM, Nicholas Tustison ntustison at gmail.com>
> wrote:
> Hi Ricardo,
> If you're submitting a mask of all zeros, that would explain the error
> message you're getting. Instead of submitting a mask of all zeros, just
> type a non-existent filename and the otsu mask will be calculated. Let me
> know if that works out.
> Nick
> On Oct 14, 2009, at 5:10 PM, Ricardo Ferrari wrote:
> Dear itk users,
> I am trying to run the itk N3 algorithm implemented by Nicholas J.
> Tustison and James C. Gee and I am getting a "segmentation fault" error.
> Above I am sending the main part of my code and the error I am getting.
> -------------------------------------
> /// m_inputImage is a minc image - you can download it from the following
> site: http://www.4shared.com/file/140891877/c11d6f0c/20090808_0_DUAL.html
> int m_shrinkFactor = 2;
> /// m_maskImage is purposely equal to zero so that it can be computed
> using Otsu threshold
> ///
> /// Use Otsu threshold to compute a simple mask, if one is not provided
> ///
> if( ! m_maskImage )
> {
> typedef itk::OtsuThresholdImageFilter ThresholderType;
> typename ThresholderType::Pointer otsu = ThresholderType::New();
> otsu->SetInput( m_inputImage );
> otsu->SetNumberOfHistogramBins( 200 );
> otsu->SetInsideValue( 0 );
> otsu->SetOutsideValue( 1 );
> otsu->Update();
> m_maskImage = otsu->GetOutput();
> }
> ///
> /// DownSampling the input image to reduce computation time
> ///
> typedef itk::ShrinkImageFilter ShrinkerImageType;
> typename ShrinkerImageType::Pointer shrinker1 = ShrinkerImageType::New();
> shrinker1->SetInput( m_inputImage );
> shrinker1->SetShrinkFactors( 1 );
> typedef itk::ShrinkImageFilter ShrinkerMaskType;
> typename ShrinkerMaskType::Pointer shrinker2 = ShrinkerMaskType::New();
> shrinker2->SetInput( m_maskImage );
> shrinker2->SetShrinkFactors( 1 );
> if( m_shrinkFactor > 1 )
> {
> shrinker1->SetShrinkFactors( m_shrinkFactor );
> shrinker2->SetShrinkFactors( m_shrinkFactor );
> shrinker1->Update();
> shrinker2->Update();
> }
> typename TRealImageType::Pointer realInputImage = shrinker1->GetOutput();
> typename TMaskImageType::Pointer maskShrinked = shrinker2->GetOutput();
> ///
> /// Run bias field correction
> ///
> typedef itk::N3MRIBiasFieldCorrectionImageFilter CorrectorType;
> typename CorrectorType::Pointer corrector = CorrectorType::New();
> corrector->SetInput( realInputImage );
> corrector->SetMaskImage( maskShrinked );
> corrector->SetMaskLabel( NumericTraits::One );
> corrector->SetMaximumNumberOfIterations( m_maxNumIter );
> corrector->SetNumberOfFittingLevels( m_numFittingLevels );
> try
> {
> corrector->Update();
> }
> catch ( itk::ExceptionObject & err )
> {
> std::cout
> std::cout throw err;
> }
> catch (... )
> {
> std::cout
> throw;
> }
> OUTPUT
> --------------------------
> Starting
> [-116.98, -103.715, -34.2648]
> [0.857143, 0.857143, 6]
> [280, 280, 25]
> 0.999208 -0.00996255 -0.0385217
> 0.0108005 0.999708 0.0216062
> 0.0382952 -0.0220051 0.999024
> [3, 3, 3]
> 3
> [4, 4, 4]
> Segmentation fault
> --------------------------
> After spending some time looking for the problem I found out that the it
> is happening in the following part of the
> itkN3MRIBiasFieldCorrectionImageFilter.txx file. The problem does not
> occur if I use the original image without downsampling it.
> I really appreciate any help on this !!!
> Thanks,
> Ricardo
> cout
> cout GetOrigin() cout GetSpacing()
> cout GetLargestPossibleRegion().GetSize() cout GetDirection() cout
> m_NumberOfFittingLevels
> cout m_SplineOrder cout m_NumberOfControlPoints
> typename BSplineFilterType::Pointer bspliner = BSplineFilterType::New();
> bspliner->SetOrigin( fieldEstimate->GetOrigin() );
> bspliner->SetSpacing( fieldEstimate->GetSpacing() );
> bspliner->SetSize( fieldEstimate->GetLargestPossibleRegion().GetSize() );
> bspliner->SetDirection( fieldEstimate->GetDirection() );
> bspliner->SetGenerateOutputImage( true );
> bspliner->SetNumberOfLevels( this->m_NumberOfFittingLevels );
> bspliner->SetSplineOrder( this->m_SplineOrder );
> bspliner->SetNumberOfControlPoints( this->m_NumberOfControlPoints );
> bspliner->SetInput( fieldPoints );
> bspliner->Update();
> cout
> _____________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091015/8e48e77c/attachment-0001.htm>
More information about the Insight-users
mailing list