From kjwjj627 at gmail.com Wed Oct 3 11:30:04 2018 From: kjwjj627 at gmail.com (wonnybro) Date: Wed, 3 Oct 2018 08:30:04 -0700 (MST) Subject: [ITK-users] DVFs interpolation by BSpline Message-ID: <1538580604795-0.post@n7.nabble.com> Hi, ITK users I really really need your help, please help me... I am trying to do BSpline interpolation of DVFs obtained by image registrations of 10 images. I'm trying to modify the BSplineScatteredDataPointSetToImageFilter from the Insight Journal. However, I am having trouble to find the correct parameter in order to make the filter work. I'll have scattered 3-D points of several DVFs over time and I want to fit these DVFs by a 4-D Bspline. Afterwards I want to evaluate output DVF to one time step. Here you can find the code, unfortunately it crashes. Please help me...please. Thanks in advance. #include "itkBSplineScatteredDataPointSetToImageFilter.h" #include "itkPointSet.h" #include "itkImage.h" #include "itkVectorImage.h" #include "itkImageFileReader.h" #include "itkImageFileWriter.h" int main (int argc, char* argv[]) { const unsigned int ImageDimension = 3; using VectorType = itk::Vector; using InputImageType = itk::Image; using InputPointType = InputImageType::PointType; using OutputImageType = itk::Image; using PointSetType = itk::PointSet; using OutputPointType = PointSetType::PointType; using ReaderType = itk::ImageFileReader; using WriterType = itk::ImageFileWriter; PointSetType::Pointer pointSet = PointSetType::New(); unsigned long pointId = 0; InputImageType::PointType origin; InputImageType::SpacingType spacing; InputImageType::SizeType size; for (int i = 1; i < argc; ++i) { ReaderType::Pointer reader = ReaderType::New(); std::cout << "Reading file " << argv[i] << std::endl; reader->SetFileName(argv[i]); try { reader->Update(); } catch (itk::ExceptionObject & err) { std::cout << "ExceptionObject caught !" << std::endl; std::cout << err << std::endl; return EXIT_FAILURE; } using IteratorType = itk::ImageRegionConstIterator; const InputImageType * image = reader->GetOutput(); IteratorType it(image, image->GetBufferedRegion()); it.GoToBegin(); InputPointType inPoint; OutputPointType outPoint; int iCount = 0; while (!it.IsAtEnd()) { inPoint = image->GetPixel(it.GetIndex()); for (int j = 0; j < ImageDimension; ++j) outPoint[j] = inPoint[i]; outPoint[ImageDimension] = i - 1; pointSet->SetPoint(pointId, outPoint); // Transfer the pixel data to the value associated with the point. pointSet->SetPointData(pointId, it.Get()); ++it; ++pointId; ++iCount; } std::cout << "Number of points in " << argv[i] << " = " << iCount << std::endl; std::cout << "Total number of points = " << pointSet->GetNumberOfPoints() << std::endl; origin = image->GetOrigin(); spacing = image->GetSpacing(); size = image->GetLargestPossibleRegion().GetSize(); } typedef itk::BSplineScatteredDataPointSetToImageFilter < PointSetType, OutputImageType > SplineFilterType; SplineFilterType::Pointer splineFilter = SplineFilterType::New(); int splineorder=3; // complexity of the spline SplineFilterType::ArrayType ncontrol; ncontrol[0]=splineorder + 1; SplineFilterType::ArrayType closedim; closedim[0]= 0; OutputImageType::PointType parametricDomainOrigin; OutputImageType::SpacingType parametricDomainSpacing; OutputImageType::SizeType parametricDomainSize; for (int i = 0; i < ImageDimension; ++i) { parametricDomainOrigin[i] = origin[i]; parametricDomainSpacing[i] = spacing[i]; parametricDomainSize[i] = size[i]; } parametricDomainOrigin[ImageDimension] = 0; parametricDomainSize[ImageDimension] = argc - 2; parametricDomainSpacing[ImageDimension] = 10.0; splineFilter->SetGenerateOutputImage( true ); // the only reason to turn this off is if one only wants to use the control point lattice for further processing splineFilter->SetInput ( pointSet ); splineFilter->SetSplineOrder ( splineorder ); splineFilter->SetNumberOfControlPoints ( ncontrol ); splineFilter->SetNumberOfLevels( 3 ); splineFilter->SetCloseDimension ( closedim ); splineFilter->SetSize( parametricDomainSize ); splineFilter->SetSpacing( parametricDomainSpacing ); splineFilter->SetOrigin( parametricDomainOrigin ); std::cout << "Before update spline filter" << std::endl; splineFilter->Update(); std::cout << "After update spline filter" << std::endl; WriterType::Pointer writer = WriterType::New(); writer->SetInput(splineFilter->GetOutput()); writer->SetFileName("Output.mhd"); writer->Update(); std::cout << "After write image filter" << std::endl; return EXIT_SUCCESS; }; -- Sent from: http://itk-users.7.n7.nabble.com/ From dzenanz at gmail.com Wed Oct 3 14:10:44 2018 From: dzenanz at gmail.com (=?UTF-8?B?RMW+ZW5hbiBadWtpxIc=?=) Date: Wed, 3 Oct 2018 14:10:44 -0400 Subject: [ITK-users] DVFs interpolation by BSpline In-Reply-To: <1538580604795-0.post@n7.nabble.com> References: <1538580604795-0.post@n7.nabble.com> Message-ID: Hi JongWon, welcome to ITK! To reproduce your problem we will need the input file too. If it crashes with different input files, please provide the smallest one. Also, we have migrated to the forum , so please post the updated question there. Regards, D?enan On Wed, Oct 3, 2018 at 11:30 AM wonnybro wrote: > Hi, ITK users > > I really really need your help, please help me... > I am trying to do BSpline interpolation of DVFs obtained by image > registrations of 10 images. > I'm trying to modify the BSplineScatteredDataPointSetToImageFilter from the > Insight Journal. However, > I am having trouble to find the correct parameter in order to make the > filter work. > I'll have scattered 3-D points of several DVFs over time and I want to fit > these DVFs by a 4-D Bspline. Afterwards I want to evaluate output DVF to > one > time step. > > Here you can find the code, unfortunately it crashes. > > Please help me...please. > > Thanks in advance. > > #include "itkBSplineScatteredDataPointSetToImageFilter.h" > #include "itkPointSet.h" > #include "itkImage.h" > #include "itkVectorImage.h" > #include "itkImageFileReader.h" > #include "itkImageFileWriter.h" > > int main (int argc, char* argv[]) > { > const unsigned int ImageDimension = 3; > > using VectorType = itk::Vector; > using InputImageType = itk::Image; > using InputPointType = InputImageType::PointType; > using OutputImageType = itk::Image; > using PointSetType = itk::PointSet; > using OutputPointType = PointSetType::PointType; > using ReaderType = itk::ImageFileReader; > using WriterType = itk::ImageFileWriter; > > PointSetType::Pointer pointSet = PointSetType::New(); > unsigned long pointId = 0; > InputImageType::PointType origin; > InputImageType::SpacingType spacing; > InputImageType::SizeType size; > for (int i = 1; i < argc; ++i) > { > ReaderType::Pointer reader = ReaderType::New(); > std::cout << "Reading file " << argv[i] << std::endl; > reader->SetFileName(argv[i]); > try > { > reader->Update(); > } > catch (itk::ExceptionObject & err) > { > std::cout << "ExceptionObject caught !" << std::endl; > std::cout << err << std::endl; > return EXIT_FAILURE; > } > using IteratorType = itk::ImageRegionConstIterator; > const InputImageType * image = reader->GetOutput(); > IteratorType it(image, image->GetBufferedRegion()); > it.GoToBegin(); > InputPointType inPoint; > OutputPointType outPoint; > int iCount = 0; > while (!it.IsAtEnd()) > { > inPoint = image->GetPixel(it.GetIndex()); > for (int j = 0; j < ImageDimension; ++j) > outPoint[j] = inPoint[i]; > outPoint[ImageDimension] = i - 1; > pointSet->SetPoint(pointId, outPoint); > // Transfer the pixel data to the value associated with the point. > pointSet->SetPointData(pointId, it.Get()); > ++it; > ++pointId; > ++iCount; > } > std::cout << "Number of points in " << argv[i] << " = " << iCount << > std::endl; > std::cout << "Total number of points = " << > pointSet->GetNumberOfPoints() << std::endl; > origin = image->GetOrigin(); > spacing = image->GetSpacing(); > size = image->GetLargestPossibleRegion().GetSize(); > } > > typedef itk::BSplineScatteredDataPointSetToImageFilter < PointSetType, > OutputImageType > SplineFilterType; > SplineFilterType::Pointer splineFilter = SplineFilterType::New(); > > int splineorder=3; // complexity of the spline > > SplineFilterType::ArrayType ncontrol; > ncontrol[0]=splineorder + 1; > SplineFilterType::ArrayType closedim; > closedim[0]= 0; > > OutputImageType::PointType parametricDomainOrigin; > OutputImageType::SpacingType parametricDomainSpacing; > OutputImageType::SizeType parametricDomainSize; > for (int i = 0; i < ImageDimension; ++i) > { > parametricDomainOrigin[i] = origin[i]; > parametricDomainSpacing[i] = spacing[i]; > parametricDomainSize[i] = size[i]; > } > parametricDomainOrigin[ImageDimension] = 0; > parametricDomainSize[ImageDimension] = argc - 2; > parametricDomainSpacing[ImageDimension] = 10.0; > > splineFilter->SetGenerateOutputImage( true ); // the only reason to > turn > this off is if one only wants to use the control point lattice for further > processing > splineFilter->SetInput ( pointSet ); > splineFilter->SetSplineOrder ( splineorder ); > splineFilter->SetNumberOfControlPoints ( ncontrol ); > splineFilter->SetNumberOfLevels( 3 ); > splineFilter->SetCloseDimension ( closedim ); > splineFilter->SetSize( parametricDomainSize ); > splineFilter->SetSpacing( parametricDomainSpacing ); > splineFilter->SetOrigin( parametricDomainOrigin ); > std::cout << "Before update spline filter" << std::endl; > splineFilter->Update(); > std::cout << "After update spline filter" << std::endl; > > WriterType::Pointer writer = WriterType::New(); > writer->SetInput(splineFilter->GetOutput()); > writer->SetFileName("Output.mhd"); > writer->Update(); > std::cout << "After write image filter" << std::endl; > > return EXIT_SUCCESS; > }; > > > > -- > Sent from: http://itk-users.7.n7.nabble.com/ > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vrnova at gmail.com Thu Oct 4 09:33:33 2018 From: vrnova at gmail.com (Yanling Liu) Date: Thu, 4 Oct 2018 09:33:33 -0400 Subject: [ITK-users] Imaging analysis PostDoc position (NCI/FNLCR) Message-ID: Dear ITK users, The Advanced Biomedical and Computational Science group at the NCI Frederick National Laboratory for Cancer Research (FNLCR) seeks a post doc fellow with image analysis background to work on tissue toxicity study from radiation treatment. The post doc will support the collaboration between FNLCR and University of Maryland School of Medicine. To apply: https://careers.leidos.com/jobs/3071866-postdoctoral-fellow-nci/apply Thank you Yanling -------------- next part -------------- An HTML attachment was scrubbed... URL: