<div dir="ltr">Hi Simon,<div><br></div><div>Thank you for the quick response.</div><div><br></div><div>We already tried that conversion. Here is the updated snippet:</div><div>size_x = 1024</div><div>size_y = 1024</div><div>numberOfProjections = 512<br></div><div>rawio = itk.RawImageIO.New()<br>rawio.SetNumberOfDimensions(2)<br>rawio.SetPixelType(itk.CommonEnums.IOPixel_SCALAR)<br>rawio.SetComponentType(itk.CommonEnums.IOComponent_FLOAT)<br>rawio.SetDimensions(0, size_x)<br>rawio.SetDimensions(1, size_y)<br>rawio.SetSpacing(0, 1)<br>rawio.SetSpacing(1, 1)<br>rawio.SetByteOrderToLittleEndian()<br><br># List of filenames<br>fileNames = []<br>for i in range(numberOfProjections-1):<br>    fileNames.append(f'/subvolume00/{i:04d}.raw')<br>   <br>pixelSpacing = 0.420002<br>projOrigin = [ -pixelSpacing*(size_x-1)/2, 0, -pixelSpacing*(size_y-1)/2 ] #input images are size_x x size_y pixels with a 0.42mm pixel size<br>projSpacing = [ pixelSpacing, 1, pixelSpacing ]<br># Read projections<br>CPUImageType = itk.Image[itk.F,3]<br>proj = rtk.projections_reader(ttype=CPUImageType, file_names=fileNames,ImageIO=rawio, Origin=projOrigin, Spacing=projSpacing)<br></div><div><br></div><div>Then it is throwing below error:</div><div><span style="color:rgb(52,53,65);font-family:Söhne,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,Cantarell,"Noto Sans",sans-serif,"Helvetica Neue",Arial,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:16px"><i>ITK ERROR: RawImageIO(0000027078EE8D00): File seek failed</i></span><br></div><div><span style="color:rgb(52,53,65);font-family:Söhne,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Ubuntu,Cantarell,"Noto Sans",sans-serif,"Helvetica Neue",Arial,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:16px"><br></span></div><div>Then tried setting header as below </div><div>rawio.SetHeaderSize(rawio.GetImageSizeInPixels() * 0)<br></div><div><br></div><div>and got another error saying </div><div><i>ITK ERROR: RawImageIO(000001A2C02FAB20): Read failed: Wanted 4194304 bytes, but read 2097152 bytes.</i><br></div><div><br></div><div>To read appropriate number of bytes from each file, we need to use an unsigned int (16 bit) type:</div><div>rawio.SetComponentType(itk.CommonEnums.IOComponent_INT)<br></div><div># Read projections<br>CPUImageType = itk.Image[itk.US,3]<br>proj = rtk.projections_reader(ttype=CPUImageType, file_names=fileNames,ImageIO=rawio, Origin=projOrigin, Spacing=projSpacing)<br></div><div><br></div><div>the above changes throws error saying template not found.</div><div><br></div><div><i>No suitable template parameter can be found.<br><br>Please specify an input via the first argument, the 'ttype' keyword parameter,<br>or via one of the following keyword arguments: Input, InputImage, Input1</i><br></div><div><i><br></i></div><div>Regards,</div><div>Akshara</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 12 Jul 2023 at 22:22, Simon Rit <<a href="mailto:simon.rit@creatis.insa-lyon.fr">simon.rit@creatis.insa-lyon.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Check this archive on the mailing list:</div><div><a href="https://www.creatis.insa-lyon.fr/pipermail/rtk-users/2023-January/001921.html" target="_blank">https://www.creatis.insa-lyon.fr/pipermail/rtk-users/2023-January/001921.html</a></div><div>ProjectionsReader supports any input raw but converts it to the required output, i.e., float or double.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 12, 2023 at 2:06 PM Akshara P K <<a href="mailto:akshara@advitech.in" target="_blank">akshara@advitech.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Simon,<br>Thank you for pointing that out. We made some corrections in the gantry angle. <br>There was a bug in assuming the axis setting of ProjectionsReader origin too. All those are corrected and reconstruction works perfectly fine now.<div><br>Currently we are reading projections as .tif images but ultimately we need to read .raw images and apply reconstruction on them.<br>We have 512 unsigned short projections in .raw format each of with 1024x1024 dimensions.<br>It seems unsigned short is not supported by ProjectionsReader.<div>  <br>Two possible methods that we can think of:<br>1. Read projections with ImageSeriesReader which supports unsigned short, converts data to float and feeds to ProjectionsReader.<br>   If so, is there a method to set manipulated input to ProjectionsReader? From the literature, only SetFileNames is possible.<br>2. Is there any alternative method to convert projections to line integral without using ProjectionsReader.<br><br>Looking forward to your suggestions.<br><br>Regards,<br>Akshara<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 11 Jul 2023 at 02:09, Simon Rit <<a href="mailto:simon.rit@creatis.insa-lyon.fr" target="_blank">simon.rit@creatis.insa-lyon.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>The folder does not contain the angle.bin file. I looked at the projections. Maybe it's because the teeth are far from the central slice, where data are missing? This is known to cause problems, in particular for short scans.</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 10, 2023 at 9:14 PM Akshara P K <<a href="mailto:akshara@advitech.in" target="_blank">akshara@advitech.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Simon,<br><br>Cuda PSSF is working fine with the wheel file you shared. But it looks like something I missed from the reconstruction process and the result is not up to mark as I expected.<br>The result looks like as below:<div><img src="cid:ii_ljwthfeb0" alt="image.png" width="541" height="526"><br><img src="cid:ii_ljwtig8i1" alt="image.png" width="271" height="215"><br>and the expected is more or less something like below:</div><div><br></div><div><img src="cid:ii_ljwtj2up2" alt="image.png" width="541" height="485"><br><br><br>The input projections and the parameter file (Which I used to fill the input parameters) are available here:<br><a href="https://drive.google.com/drive/folders/13EC2Lusyrx3HvkKJL80aSBHfled0FduT?usp=sharing" target="_blank">https://drive.google.com/drive/folders/13EC2Lusyrx3HvkKJL80aSBHfled0FduT?usp=sharing</a><br><br>Can you please check and provide your valuable suggestions on how I can improve the result.<br><br>Here is the updated code:<br><br># Defines the image type<br>ImageType = itk.Image[itk.F,3]<br>GPUImageType = itk.CudaImage[itk.F,3]<br><br># Defines the RTK geometry object<br>geometry = rtk.ThreeDCircularProjectionGeometry.New()<br>numberOfProjections = 512<br>firstAngle = -0.54853<br>angularArc = 270.66079712<br>sid = 537.09972 # source to isocenter distance<br>sdd = 908.00674 # source to detector distance<br>size_x = 1024<br>size_y = 1024<br>projOffsetX = -2.06667995<br>projOffsetY = -0.19235000<br>outOfPlaneAngle = 0<br>inPlaneAngle = 0<br>sourceOffsetX = 0<br>sourceOffsetY = 0<br><br>angle_path = os.path.join("/skull/","angle.bin")<br>angles2 = []<br>with open(angle_path, 'rb') as file:<br>    while True:<br>        data = file.read(4)  # Read 4 bytes (32 bits) at a time<br>        if not data:<br>            break  # Reached end of file<br>        value = struct.unpack('f', data)[0]  # Unpack binary data as a float<br>        angles2.append(value)<br>print("Read angles from bin completed")<br>        <br>for x in angles2:<br>    geometry.AddProjection(sid,sdd,x,projOffsetX, projOffsetY, outOfPlaneAngle, inPlaneAngle, sourceOffsetX, sourceOffsetY)<br><br>tiffio = itk.TIFFImageIO.New()<br><br>extension = ".tif"<br>fileNameFormat = "/binary/raw" + "%04d" + extension<br>fnames = itk.NumericSeriesFileNames.New()<br>fnames.SetStartIndex(0)<br>fnames.SetEndIndex(numberOfProjections-1)<br>fnames.SetIncrementIndex(1)<br>fnames.SetSeriesFormat(fileNameFormat)<br><br>ProjectionsReaderType = rtk.ProjectionsReader[ImageType]<br>projectionsSource = ProjectionsReaderType.New()<br>projectionsSource.SetImageIO(tiffio)<br>projectionsSource.SetFileNames(fnames.GetFileNames())<br>projOrigin = [ -0.42*(size_x-1)/2, 0, -0.42*(size_y-1)/2 ] #input images are size_x x size_y pixels with a 0.42mm pixel size<br>projSpacing = [ 0.42, 1, 0.42 ]<br>projectionsSource.SetOrigin( projOrigin )<br>projectionsSource.SetSpacing( projSpacing )<br><br># Graft the projections to an itk::CudaImage<br>projections = GPUImageType.New()<br>projectionsSource.Update()<br>projections.SetPixelContainer(projectionsSource.GetOutput().GetPixelContainer())<br>projections.CopyInformation(projectionsSource.GetOutput())<br>projections.SetBufferedRegion(projectionsSource.GetOutput().GetBufferedRegion())<br>projections.SetRequestedRegion(projectionsSource.GetOutput().GetRequestedRegion())<br><br>ParkerShortScanImageFilterType = rtk.CudaParkerShortScanImageFilter<br>ParkerFilter = ParkerShortScanImageFilterType.New()<br>ParkerFilter.SetInput(projections)<br>ParkerFilter.SetGeometry(geometry)<br>ParkerFilter.InPlaceOff()<br><br>ConstantImageSourceType = rtk.ConstantImageSource[GPUImageType]<br># Create reconstructed image<br>constantImageSource2 = ConstantImageSourceType.New()<br>render_x = 512<br>render_y = 512<br>sizeOutput = [ render_x, render_y, numberOfProjections ]<br>origin = [ -(render_x/2.0), 0 , -(render_y/2.0) ]<br>spacing = [ 1.0, 0.5, 1.0 ]<br>constantImageSource2.SetOrigin( origin )<br>constantImageSource2.SetSpacing( spacing )<br>constantImageSource2.SetSize( sizeOutput )<br>constantImageSource2.SetConstant(0.)<br><br>#Displaced detector weighting<br>ddf = rtk.CudaDisplacedDetectorImageFilter.New()<br>ddf.SetInput(ParkerFilter.GetOutput())<br>ddf.SetGeometry(geometry)<br><br># FDK reconstruction<br>print("Reconstructing...")<br>FDKGPUType = rtk.CudaFDKConeBeamReconstructionFilter<br>feldkamp = FDKGPUType.New()<br>feldkamp.SetInput(0, constantImageSource2.GetOutput()) <br>feldkamp.SetInput(1, ddf.GetOutput()) <br>feldkamp.SetGeometry(geometry)<br>feldkamp.GetRampFilter().SetTruncationCorrection(0.0)<br>feldkamp.GetRampFilter().SetHannCutFrequency(0.0)<br><br># Field-of-view masking<br>FOVFilterType = rtk.FieldOfViewImageFilter[ImageType, ImageType]<br>fieldofview = FOVFilterType.New()<br>fieldofview.SetInput(0, feldkamp.GetOutput())<br>fieldofview.SetProjectionsStack(feldkamp.GetOutput())<br>fieldofview.SetGeometry(geometry)<br><br># Writer<br>print("Writing output image...")<br>WriterType = rtk.ImageFileWriter[ImageType]<br>writer = WriterType.New()<br>writer.SetFileName("image_output_skull00_ver1.3.tiff")<br>writer.SetInput(fieldofview.GetOutput())<br>writer.Update()<br></div><div><br></div><div>Regards,</div><div>Akshara</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 6 Jul 2023 at 18:23, Akshara P K <<a href="mailto:akshara@advitech.in" target="_blank">akshara@advitech.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Simon,<div><br></div><div>Thank you for the quick response.</div><div>It works perfectly fine except some warnings as you mentioned.</div><div>Thank you again for the support.</div><div><br></div><div>Regards,</div><div>Akshara</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 5 Jul 2023 at 18:36, Simon Rit <<a href="mailto:simon.rit@creatis.insa-lyon.fr" target="_blank">simon.rit@creatis.insa-lyon.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div>Following a recent similar request (see <a href="https://www.creatis.insa-lyon.fr/pipermail/rtk-users/2023-June/001979.html" target="_blank">here</a>), I have added CudaParkerShortScanImageFilter with this <a href="https://www.creatis.insa-lyon.fr/pipermail/rtk-users/2023-June/001979.html" target="_blank">PR</a>. New Python packages are available as artifacts of the CI <a href="https://github.com/RTKConsortium/RTK/actions/runs/5448263998" target="_blank">here</a>. I haven't tested them, let me know whether they work... In any case, I have noticed new warnings when using these wheels which must be fixed (see issue <a href="https://github.com/RTKConsortium/RTK/issues/553" target="_blank">#553</a>).</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 5, 2023 at 2:20 PM Akshara P K <<a href="mailto:akshara@advitech.in" target="_blank">akshara@advitech.in</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<br><br>I was trying to use FirstCudaReconstruction.py to reconstruct a set of tiff projections images using the python binary of itk-rtk. Since the angle coverage is around 268 degrees, I had to implement a ParkerShortScanImageFilter between the output of the ProjectionsReader and the FDK reconstruction and it is working fine with the CPU version of API. However, the use of CudaParkerShortScanImageFilter causes an error saying module 'RTK' has no attribute 'CudaParkerShortScanImageFilter' even though CudaParkerShortScanImageFilter is added and implemented in the cpp version. Can anyone provide an insight on how to solve this issue?<br><br>Regards,<br>Akshara<br></div>
_______________________________________________<br>
Rtk-users mailing list<br>
<a href="mailto:rtk-users@openrtk.org" target="_blank">rtk-users@openrtk.org</a><br>
<a href="https://www.creatis.insa-lyon.fr/mailman/listinfo/rtk-users" rel="noreferrer" target="_blank">https://www.creatis.insa-lyon.fr/mailman/listinfo/rtk-users</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>