<div dir="ltr"><div dir="ltr"><div>Hi,</div><div>Thanks for sharing your experience. I tried to use your code to reproduce your problem but I couldn't. Enclosed is the code that I run with</div><div><br></div><div>import daye<br>simulator = daye.simulator()<br>simulator.runCBCT('proj.mha', 0, 0)<br>simulator.buildVolumeFromFile('proj.mha','recon.mha',simulator)<br><br></div><div> Does it work for you? If yes, can you send your full example?</div><div>Simon<br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 18, 2019 at 7:51 AM Pierre Daye <<a href="mailto:Pierre.Daye@iba-group.com" target="_blank">Pierre.Daye@iba-group.com</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 lang="EN-US">
<div class="gmail-m_-2115275164378002690gmail-m_-8127665210758800703WordSection1">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hello,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">First of all congrats for the update of RTK and the new Python integration. This is really great for Python users who don’t want the whole<u></u><u></u></p>
<p class="MsoNormal">C++ armada to test a small reconstruction principle!<u></u><u></u></p>
<p class="MsoNormal">I could easily run the first reconstruction and it worked perfectly! However, I tried then to first save the images using these method within<u></u><u></u></p>
<p class="MsoNormal">a simulator python class:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">    def buildGeometry(self, offsetZ, offsetY):<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        geometry = rtk.ThreeDCircularProjectionGeometry.New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        for x in range(0, self.param['numberOfProjections']):<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">            angle = self.param['firstAngle'] + x * self.param['angularArc'] / self.param['numberOfProjections']<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">            geometry.AddProjection(self.param['sid'] + offsetZ,
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">                self.param['sdd'], angle, self.param['isox'],
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">                self.param['isoy'], self.param['outOfPlaneAngle'],
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">                self.param['inPlaneAngle'], self.param['sourceOffsetX'], offsetY)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        return geometry<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">    def runCBCT(self, filename, offsetZ, offsetY):<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        geometry = self.buildGeometry(offsetZ, offsetY)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource = rtk.ConstantImageSource[self.param['TImageType']].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource.SetOrigin( self.param['origin'] )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource.SetSpacing( self.param['spacing'] )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource.SetSize( self.param['sizeOutput'] )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        <span lang="FR-BE">constantImageSource.SetConstant(0.0)<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span lang="FR-BE">        source = constantImageSource.GetOutput()<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span lang="FR-BE"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36pt"><span lang="FR-BE">        </span>
self.rei.SetGeometry(geometry)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        self.rei.SetInput(source)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        <u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        projections = self.rei.GetOutput()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer = itk.ImageFileWriter[self.param['TImageType']].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.SetFileName(filename)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.SetInput(projections)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.Update()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal">This parts works perfectly and the generated images are OK (checked with IMageJ).<u></u><u></u></p>
<p class="MsoNormal">The problems start when I want to reconstruct the volume.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">def buildVolumeFromFile(self, file, fileOUT, CBCT):<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        geometry = CBCT.buildGeometry(0, 0)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        print("Performing reconstruction")<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        TImageType = self.param['TImageType']<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        reader = itk.ImageFileReader[TImageType].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        reader.SetFileName(file)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        reiImage = reader.GetOutput()       
<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">    <u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        # Create reconstructed image<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource2 = rtk.ConstantImageSource[TImageType].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        origin = [ -63.5, -63.5, -63.5 ]<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        sizeOutput = [ 128, 128, 128 ]<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource2.SetOrigin( origin )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource2.SetSpacing( [1, 1, 1] )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource2.SetSize( sizeOutput )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        constantImageSource2.SetConstant(0.0)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        source2 = constantImageSource2.GetOutput()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        print("Performing reconstruction")<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        feldkamp = rtk.FDKConeBeamReconstructionFilter[TImageType].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        feldkamp.SetGeometry( geometry )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        feldkamp.SetInput(0, source2)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        feldkamp.SetInput(1, reiImage)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        image = feldkamp.GetOutput()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        print("Masking field-of-view")<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        fov = rtk.FieldOfViewImageFilter[TImageType, TImageType].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        fov.SetGeometry(geometry)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        fov.SetProjectionsStack(reiImage)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        fov.SetInput(image)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        image = fov.GetOutput()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer = itk.ImageFileWriter[TImageType].New()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.SetFileName ( fileOUT )<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.SetInput(image)<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt">        writer.Update()<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:36pt"><u></u> <u></u></p>
<p class="MsoNormal">I cannot run this script. It generates a criptic segfault… What am I doing wrong here?<u></u><u></u></p>
<p class="MsoNormal">If one of you RTK gurus  could help me, I would greatly appreciate it!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Pierre<u></u><u></u></p>
</div>
 <br>
<div style="background-color:rgb(227,228,228);padding:0.8em"><span style="font-size:10pt;font-family:"Arial",serif;color:rgb(0,0,0)"><a href="https://iba-worldwide.com/disclaimer" target="_blank">Disclaimer | Use of IBA e-communication</a></span><br>
<p style="font-size:8pt;line-height:10pt;font-family:"Arial",serif">The contents of this e-mail message and any attachments are intended solely for the recipient (s) named above. This communication is intended to be and to remain confidential and may be
 protected by intellectual property rights. Any use of the information contained herein (including but not limited to, total or partial reproduction, communication or distribution of any form) by persons other than the designated recipient(s) is prohibited.
 Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free. Ion Beam Applications does not accept liability for any
 such errors. Thank you for your cooperation. </p>
</div>
</div>

_______________________________________________<br>
Rtk-users mailing list<br>
<a href="mailto:Rtk-users@public.kitware.com" target="_blank">Rtk-users@public.kitware.com</a><br>
<a href="https://public.kitware.com/mailman/listinfo/rtk-users" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/rtk-users</a><br>
</blockquote></div>