<div dir="ltr">Hi Simon,<div><br>Many thanks.

I'm in need of some assistance once more please.<br><br>First, I reoreinted the CT volume and used the field of view origin in the corresponding real kV dicom file (i.e. with projection angle zero) to adjust the correct field of view for projection angle zero (FOV origin [116.368270874, 3.837730408]). I simply replace the default values of projOffsetX and projOffsetY with the values shown below.<br>projOffsetY = -3.837730408<br><br>I simply rotated around the x-axis by setting the outOfPlaneAngle parameter to 90 degrees.<br><br>However, If I project through a 324 (degrees) projection angle (with FOV origin [117.085998535, 3.948999882]), it will rotate in the worng axis.<br>For this step, I simply replace the gantryAngle parameter with 324 and set the new projOffsetX and projOffsetY.<br><br>I've attached the updated code, the reoriented CT volume, the correct DRR at projection angle zero, and the incorrect DRR at projection angle 324.<br><br>Can you assist me in resolving that error ?<br></div><div><br></div><div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1qOoMQ6jvOSY-7KivjmcLuAoIIMhBafmE/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" aria-label="drr_0.png"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom">drr_0.png</span></a><img src="//ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="display:none; opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; "></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1RjT6_hGF2vkog3YNUfv-03RAmTClrSbK/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" aria-label="drr_324.png"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom">drr_324.png</span></a><img src="//ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="display:none; opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; "></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1BntJvZ7JRF9kTxQsycB5JoipWVFESNQ_/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" aria-label="ref_CT_updated.nii.gz"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:none">ref_CT_updated.nii.gz</span></a><img src="//ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; display: none;"></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1mEaIbj9NjuU5BZB4NKlmv0S9CUN0FME3/view?usp=drive_web" target="_blank" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:none" aria-label="rtk_drr_projection_code.txt"><img style="vertical-align: bottom; border: none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom;text-decoration:none">rtk_drr_projection_code.txt</span></a><img src="//ssl.gstatic.com/ui/v1/icons/common/x_8px.png" style="opacity: 0.55; cursor: pointer; float: right; position: relative; top: -1px; display: none;"></div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 9, 2022 at 2:26 PM 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>Hi,</div><div>The first input of JosephForwardProjectionImageFilter is the image in which you'll calculate the DRR, typically an empty projection (filled with zeros). In your code, this is computed with constantImageSource but you're setting the volume origin, spacing size which is probably wrong. For an Elekta projection (you showed an Elekta drawing), this would be <br></div><div><span style="font-family:monospace">constantImageSource.SetOrigin( [-204.4,-204.4,0] )<br>constantImageSource.SetSpacing( [0.8,0.8,0.8] )<br>constantImageSource.SetSize( [512, 512,1]  )</span></div><div>Besides, for the CT volume you sent, point (0,0,0) mm is not in the image and this is the default center of rotation in RTK (see <a href="http://www.openrtk.org/Doxygen/DocGeo3D.html" target="_blank">doc</a>). Moreover the orientation is wrong. So either you change the origin and the direction to use RTK convention or you build your geometry differently, e.g. by setting source center, detector origin position and detector u v coordinates:</div><div><span style="font-family:monospace">geometry.AddProjection([-57.,20.<span style="font-family:monospace">+sid</span>,25.],[-57<span style="font-family:monospace">+115.<span style="font-family:monospace"></span></span>,20.<span style="font-family:monospace">+sid-sdd</span>,25.],[1.,1.,0.],[0.,0.,1.])</span></div><div>where the coordinates (-57,28,25) are those of a point somewhere in the center of the patient. This will give you line integrals, I don't know what is the content of your png file but you might have to take the exponential to have something close to real data. you also have to add 1000 to yourCT numbers to put air at 0.</div><div>In short, read the geometry doc and don't expect us to be able to match exactly the DRR you sent... This will require some work on your side<br></div><div>Cheers,</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 9, 2022 at 11:32 AM Isuru Suranga Wijesinghe <<a href="mailto:isurusuranga.wijesinghe@gmail.com" target="_blank">isurusuranga.wijesinghe@gmail.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 dir="ltr">Can I ask any possible solution to my issue please (I just want to get the DRR with the limited FOV based on the machine parameters attached above) ???<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 8, 2022 at 2:12 PM Isuru Suranga Wijesinghe <<a href="mailto:isurusuranga.wijesinghe@gmail.com" target="_blank">isurusuranga.wijesinghe@gmail.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 dir="ltr">In addition to that I want to generate DRRs with a limited field of view as attached in the sample real kV Xray image.<br>I've included a sample CT volume that I'm currently using to generate such DRR images using the machine parameters.  Please assist in resolving this matter. Thank you in advance for your consideration and time.<br><div><br></div><div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1PilfGAhqWe-NFD4Up1CYwSHqDXns04CV/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:medium none" aria-label="ref_CT_volume.nii.gz" target="_blank"><img style="vertical-align: bottom; border: medium none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom">ref_CT_volume.nii.gz</span></a><img style="display: none; opacity: 0.55; float: right;"></div><div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;font-family:arial;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1zX2HUEEL4-lGxS4daDrhXuhTy1uFBY89/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration-line:none;padding:1px 0px;border:medium none" aria-label="sample_real_kv_xray.png" target="_blank"><img style="vertical-align: bottom; border: medium none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="vertical-align:bottom">sample_real_kv_xray.png</span></a><img style="display: none; opacity: 0.55; float: right;"></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 8, 2022 at 11:23 AM Isuru Suranga Wijesinghe <<a href="mailto:isurusuranga.wijesinghe@gmail.com" target="_blank">isurusuranga.wijesinghe@gmail.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 dir="ltr"><div>Hi,</div><div><br></div>I have a 3D-CT volume and want to obtain the DRR projection by adjusting the machine parameters as shown in the image below.<div><br>Here's my code, and I didn't get the expected DRRs with the limited FOV. Is there anything missing from the parameter setup?</div><div><br>Could you please assist me in resolving this issue? Any code level assistance or advice would be greatly appreciated.<br></div><div><br></div><div><span style="background-color:rgb(159,197,232)"># Loading 3D CT image<br>CT = itk.imread("./ct.nii.gz", pixel_type=itk.F)<br><br># Defines the image type<br>Dimension_CT = 3<br>PixelType = itk.F<br>ImageType = itk.Image[PixelType, Dimension_CT]<br><br>origin_x, origin_y, origin_z = CT.GetOrigin()<br>space_x, space_y, space_z = CT.GetSpacing()<br><br># Define origin, sizeOutput and spacing (still need to change these)<br>origin = [origin_x, origin_y, origin_z]<br>spacing = [space_x, space_y, space_z]<br><br>sizeOutput = [ 512, 512, 1]<br><br># Create a stack of empty projection images<br>ConstantImageSourceType = rtk.ConstantImageSource[ImageType]<br>constantImageSource = ConstantImageSourceType.New()<br><br>constantImageSource.SetOrigin( origin )<br>constantImageSource.SetSpacing( spacing )<br>constantImageSource.SetSize( sizeOutput )<br>constantImageSource.SetConstant(0.)<br><br># Defines the RTK geometry object<br>geometry = rtk.ThreeDCircularProjectionGeometry.New()<br>firstAngle = 0.<br>angularArc = 360.<br>sid = 1000 # source to isocenter distance<br>sdd = 1536 # source to detector distance<br>gantryAngle = 0. # rot around y-axis<br>projOffsetX = 0.<br>projOffsetY = 0.<br>outOfPlaneAngle = 90. # rot around x-axis<br>inPlaneAngle = 0. # rot around z-axis<br>sourceOffsetX = 0.<br>sourceOffsetY = 0.<br>geometry.AddProjection(sid, sdd, gantryAngle)<br>    <br>REIType = rtk.JosephForwardProjectionImageFilter[ImageType, ImageType]<br>rei = REIType.New()<br><br>rei.SetGeometry( geometry )<br>rei.SetInput(0, constantImageSource.GetOutput())<br>rei.SetInput(1, CT)<br>rei.Update()<br><br>Dimension = 3<br>OutputPixelType = itk.UC<br>OutputImageType = itk.Image[OutputPixelType, Dimension]<br><br>RescaleType = itk.RescaleIntensityImageFilter[ImageType, OutputImageType]<br>rescaler = RescaleType.New()<br>rescaler.SetOutputMinimum(0)<br>rescaler.SetOutputMaximum(255)<br>rescaler.SetInput(rei.GetOutput())<br>rescaler.Update()<br><br>WriteType = itk.ImageFileWriter[OutputImageType]<br>writer = WriteType.New()<br>writer.SetFileName('./drr_0.png')<br>writer.SetInput(rescaler.GetOutput())<br>writer.Update()</span><br></div><div><span style="background-color:rgb(159,197,232)"><br></span></div><div><span style="background-color:rgb(159,197,232)"><br></span></div></div>
</blockquote></div>
</blockquote></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/cgi-bin/mailman/listinfo/rtk-users" rel="noreferrer" target="_blank">https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users</a><br>
</blockquote></div>
</blockquote></div>