[Rtk-users] the source code of non cuda version
Simon Rit
simon.rit at creatis.insa-lyon.fr
Wed Sep 29 09:23:54 EDT 2021
Hi,
CG reconstruction does not automatically perform better. Iterative
algorithms require some regularization to control the noise. No
regularization (what you do here I presume?) or too strong regularization
will give a bad result. You can try to set some regularization with
SetGamma (see
http://www.openrtk.org/Doxygen/classrtk_1_1ConjugateGradientConeBeamReconstructionFilter.html,
detailed description).
Simon
On Wed, Sep 29, 2021 at 12:24 PM Wang, Dongping <
Dongping.Wang at bakerhughes.com> wrote:
> Hi Rit and all
>
>
>
> I am trying to recon with conjugategradient with the following python
> code:
>
>
>
> From my understanding, cg recon should have a better accurate than fdk,
> however it seems not. Could you give me some suggestion what I can do to
> improve the recon with CG?
>
>
>
>
>
>
>
>
>
> #!/usr/bin/env python
>
> import sys
>
> import itk
>
> from itk import RTK as rtk
>
>
>
> if len ( sys.argv ) < 3:
>
> print( "Usage: FirstReconstruction <outputimage> <outputgeometry>" )
>
> sys.exit ( 1 )
>
> sys.argv[1]="output_image.mha"
>
> sys.argv[2]="gantry_geometry"
>
> # Defines the image type
>
> ImageType = itk.Image[itk.F,3]
>
>
>
> # Defines the RTK geometry object
>
> geometry = rtk.ThreeDCircularProjectionGeometry.New()
>
> numberOfProjections = 520
>
> firstAngle = 0.
>
> angularArc = 360
>
> sid = 200 # source to isocenter distance
>
> sdd = 400 # source to detector distance
>
> for x in range(0,numberOfProjections):
>
> angle = firstAngle + x * angularArc / numberOfProjections
>
> geometry.AddProjection(sid,sdd,angle)
>
>
>
> # Writing the geometry to disk
>
> xmlWriter = rtk.ThreeDCircularProjectionGeometryXMLFileWriter.New()
>
> xmlWriter.SetFilename ( sys.argv[2] )
>
> xmlWriter.SetObject ( geometry )
>
> xmlWriter.WriteFile()
>
>
>
> # Create a stack of empty projection images
>
> ConstantImageSourceType = rtk.ConstantImageSource[ImageType]
>
> constantImageSource = ConstantImageSourceType.New()
>
> origin = [ -127, -127, 0. ]
>
> sizeOutput = [ 128, 128, numberOfProjections ]
>
> spacing = [ 2.0, 2.0, 2.0 ]
>
> constantImageSource.SetOrigin( origin )
>
> constantImageSource.SetSpacing( spacing )
>
> constantImageSource.SetSize( sizeOutput )
>
> constantImageSource.SetConstant(0.)
>
>
>
> REIType = rtk.RayEllipsoidIntersectionImageFilter[ImageType, ImageType]
>
> rei = REIType.New()
>
> semiprincipalaxis = [ 50, 50, 50]
>
> center = [ 0, 0, 10]
>
> # Set GrayScale value, axes, center...
>
> rei.SetDensity(2)
>
> rei.SetAngle(0)
>
> rei.SetCenter(center)
>
> rei.SetAxis(semiprincipalaxis)
>
> rei.SetGeometry( geometry )
>
> rei.SetInput(constantImageSource.GetOutput())
>
>
>
> # Create reconstructed image
>
> constantImageSource2 = ConstantImageSourceType.New()
>
> sizeOutput = [ 128, 128, 128 ]
>
> origin = [ -63.5, -63.5, -63.5 ]
>
> spacing = [ 1.0, 1.0, 1.0 ]
>
> constantImageSource2.SetOrigin( origin )
>
> constantImageSource2.SetSpacing( spacing )
>
> constantImageSource2.SetSize( sizeOutput )
>
> constantImageSource2.SetConstant(0.)
>
>
>
> # Create weight image
>
> constantImageSource3 = ConstantImageSourceType.New()
>
> sizeOutput = [ 128, 128, numberOfProjections ]
>
> origin = [ -127, -127, 0 ]
>
> spacing = [ 2.0, 2.0, 2.0 ]
>
> constantImageSource3.SetOrigin( origin )
>
> constantImageSource3.SetSpacing( spacing )
>
> constantImageSource3.SetSize( sizeOutput )
>
> constantImageSource3.SetConstant(1.)
>
>
>
> # FDK reconstruction
>
> #print("Reconstructing...")
>
> #FDKCPUType = rtk.FDKConeBeamReconstructionFilter[ImageType]
>
> #feldkamp = FDKCPUType.New()
>
> #feldkamp.SetInput(0, constantImageSource2.GetOutput())
>
> #feldkamp.SetInput(1, rei.GetOutput())
>
> #feldkamp.SetGeometry(geometry)
>
> #feldkamp.GetRampFilter().SetTruncationCorrection(0.0)
>
> #feldkamp.GetRampFilter().SetHannCutFrequency(0.0)
>
>
>
>
>
> # CG reconstruction
>
> print("Reconstructing...")
>
> CGCPUType = rtk.ConjugateGradientConeBeamReconstructionFilter[ImageType]
>
> cg = CGCPUType.New()
>
> cg.SetInput(0, constantImageSource2.GetOutput())
>
> cg.SetInput(1, rei.GetOutput())
>
> cg.SetInput(2, constantImageSource3.GetOutput())
>
> cg.SetGeometry(geometry)
>
> cg.SetNumberOfIterations(500);
>
>
> #conjugategradient->SetDisableDisplacedDetectorFilter(args_info.nodisplaced_flag);
>
>
>
>
>
> #Field-of-view masking
>
> FOVFilterType = rtk.FieldOfViewImageFilter[ImageType, ImageType]
>
> fieldofview = FOVFilterType.New()
>
> fieldofview.SetInput(0, cg.GetOutput())
>
> fieldofview.SetProjectionsStack(rei.GetOutput())
>
> fieldofview.SetGeometry(geometry)
>
>
>
> # Writer
>
> print("Writing output image...")
>
> WriterType = rtk.ImageFileWriter[ImageType]
>
> writer = WriterType.New()
>
> writer.SetFileName(sys.argv[1])
>
> writer.SetInput(fieldofview.GetOutput())
>
> writer.Update()
>
> print("Done!")
>
>
>
>
>
> regards
>
>
>
> Wang Dongping
>
>
>
> *From:* Simon Rit <simon.rit at creatis.insa-lyon.fr>
> *Sent:* Friday, September 24, 2021 3:06 PM
> *To:* Wang, Dongping <Dongping.Wang at bakerhughes.com>
> *Cc:* rtk-users at openrtk.org
> *Subject:* Re: the source code of non cuda version
>
>
>
> * EXTERNAL EMAIL:* This email originated outside of our organization. Do
> not click on any links or open attachments unless you recognize the sender
> and know the content is safe.
>
>
>
> Hi,
>
> Please use the RTK mailing list (cc). The CPU code is templated to be able
> to use different types (double, float, etc.). The source code is here
> <https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSimonRit%2FRTK%2Fblob%2Fmaster%2Finclude%2FrtkFDKConeBeamReconstructionFilter.hxx&data=04%7C01%7C%7C18f35d7a617f49d3c94208d97f29d430%7Cd584a4b7b1f24714a578fd4d43c146a6%7C0%7C0%7C637680640637639107%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=US7lI3b1IR%2Bgmoo3BP0EXqhGxzO%2Fqgeuzf8Nek4GEk8%3D&reserved=0>,
> in an hxx file the include subfolder. You can check the ITK guide
> <https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.itk.org%2FItkSoftwareGuide.pdf&data=04%7C01%7C%7C18f35d7a617f49d3c94208d97f29d430%7Cd584a4b7b1f24714a578fd4d43c146a6%7C0%7C0%7C637680640637639107%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=MP2o5wm5%2BQs4x0mHlzgZy87jM%2BCo%2FtdsPDh0FxA0Zdg%3D&reserved=0>
> for more information on that, e.g. section 3.2.2.
>
> Simon
>
>
>
> On Fri, Sep 24, 2021 at 3:00 AM Wang, Dongping <
> Dongping.Wang at bakerhughes.com> wrote:
>
> Hello Simon
>
>
>
> I am learning RTK now and found we have this file in source folder
>
>
>
> rtkCudaFDKConeBeamReconstructionFilter.cxx
> <https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSimonRit%2FRTK%2Fblob%2Fmaster%2Fsrc%2FrtkCudaFDKConeBeamReconstructionFilter.cxx&data=04%7C01%7C%7C18f35d7a617f49d3c94208d97f29d430%7Cd584a4b7b1f24714a578fd4d43c146a6%7C0%7C0%7C637680640637649103%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=M27lGDY6e%2Fit4w7pmKsv5JkO8904v5KLgrW%2Bq8d90fg%3D&reserved=0>
>
> but we do not have non Cuda version in source folder for
> rtkFDKConeBeamReconstructionFilter.cxx
> <https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSimonRit%2FRTK%2Fblob%2Fmaster%2Fsrc%2FrtkCudaFDKConeBeamReconstructionFilter.cxx&data=04%7C01%7C%7C18f35d7a617f49d3c94208d97f29d430%7Cd584a4b7b1f24714a578fd4d43c146a6%7C0%7C0%7C637680640637649103%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=M27lGDY6e%2Fit4w7pmKsv5JkO8904v5KLgrW%2Bq8d90fg%3D&reserved=0>
> .
>
>
>
> could you enlighten me where this file may be or how it works together?
> Thanks in advance!
>
>
>
>
>
> *Dongping Wang*
>
>
>
> Waygate Technologies
>
> Baker Hughes
>
>
>
> C071, F4, BLD 2, GE China Technology Park (CTP)
>
> No.1 Hua Tuo Road, Shanghai, 201203, China
>
> 通用电气检测控制技术(上海)有限公司
>
> 上海市浦东新区华佗路1号2号楼4层C071(邮编:201203)
>
>
>
> dongping.wang at bakerhughes.com <Najie.jiao at bakerhughes.com>
>
>
> bakerhughes.com
> <https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbakerhughes.com%2F&data=04%7C01%7C%7C18f35d7a617f49d3c94208d97f29d430%7Cd584a4b7b1f24714a578fd4d43c146a6%7C0%7C0%7C637680640637659095%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=nELjvs%2FtcGhKD1qxxqv6M12bU0tjT5zejo05QOlyaRU%3D&reserved=0>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/rtk-users/attachments/20210929/8d9037a5/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 110281 bytes
Desc: not available
URL: <https://public.kitware.com/pipermail/rtk-users/attachments/20210929/8d9037a5/attachment-0001.jpg>
More information about the Rtk-users
mailing list