<div dir="ltr"><div>Hi Timothy,</div><div>The contrast and the spatial resolution mostly depends on the spatial resolution of the CT image you are projecting. I don't think you can do better with Joseph's projector.</div><div>Regarding contrast, you might want to apply the Beer Lambert law (opposite then exponential) to have something more similar to a kV projection (up to a multiplicative constant probably).</div><div>I have BCCed Andy Shieh (first author of your reference) in case he has something else to suggest.<br></div><div>I hope it helps,</div><div>Simon<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 10, 2024 at 6:12 PM Timothy Wang Bok Yau <<a href="mailto:tyau5@uwo.ca">tyau5@uwo.ca</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 class="msg-8012654196877404173">




<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi everyone, </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I recently started using rtk to generate DRRs and was hoping to receive some insight on how to improve the quality of a DRR generated from a patient CT. I am hoping that the DRR would be able to approximate the quality of a kV projection from a cone beam CT.
 Currently I am setting the projection parameters to match the kV acquisition parameters on our linear accelerators, but am finding that the DRRs I produce are very blurry with low contrast. I was able to find some studies in the literature using rtk to generate
 DRRs and have found that their image quality is significantly better than what I am currently achieving (see Fig. 1 from the following paper
<a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4833659/" id="m_-8012654196877404173LPlnk587602" target="_blank">
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4833659/</a>). I've copied my code for generating the DRRs. Any insight would be greatly appreciated.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Read CT in from DICOM files</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
dirName = r"C:\Users\yaut\CT"</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
namesGenerator = itk.GDCMSeriesFileNames.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
namesGenerator.SetUseSeriesDetails(True)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
namesGenerator.AddSeriesRestriction("0008|0021")</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
namesGenerator.SetGlobalWarningDisplay(False)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
namesGenerator.SetDirectory(dirName)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
uid = namesGenerator.GetSeriesUIDs()[0]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
fileNames = namesGenerator.GetFileNames(uid)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Setup the  image series reader using GDCMImageIO</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
ImageType = itk.Image[itk.F,3]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader = itk.ImageSeriesReader[ImageType].New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
dicomIO = itk.GDCMImageIO.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader.SetImageIO(dicomIO)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader.SetFileNames(fileNames)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader.ForceOrthogonalDirectionOff()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Read DICOM</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader.Update()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
CT = reader.GetOutput()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# change the direction and origin to align with the RTK convention</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
CTDirection = np.array([[0.,1.,0.],[0.,0.,1.],[-1.,0.,0.]])</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
CT.SetDirection(itk.matrix_from_array(CTDirection))<br>
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Center the image around 0 which is the default center of rotation</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
CT.SetOrigin([-0.5*(CT.GetLargestPossibleRegion().GetSize()[1]-1)*CT.GetSpacing()[1],</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
                   -0.5*(CT.GetLargestPossibleRegion().GetSize()[2]-1)*CT.GetSpacing()[2],</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
                    0.5*(CT.GetLargestPossibleRegion().GetSize()[0]-1)*CT.GetSpacing()[0]])</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Set forward projection geometry</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
geometry = rtk.ThreeDCircularProjectionGeometry.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Image type</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
ImageType = itk.Image[itk.F,3]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Image geometry</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
geometry = rtk.ThreeDCircularProjectionGeometry.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
numberOfProjections = 360</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
firstAngle = 0</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
angularArc = 2*np.pi</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Source to isocentre distance in mm</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
sid = 1000</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Source to detector distance in mm</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
sdd = 1500</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
for x in range(0,numberOfProjections):</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
    angle = firstAngle + x*angularArc/numberOfProjections</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
    geometry.AddProjectionInRadians(sid,sdd,angle,inPlaneAngle=np.pi)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Create a stack of empty projection images</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Spacing and output size are set based on kV acquisition parameters on our Linacs</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
ConstantImageSourceType = rtk.ConstantImageSource[ImageType]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
constantImageSource = ConstantImageSourceType.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
origin = CT.GetOrigin()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
sizeOutput = [1024, 1024,  numberOfProjections ]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
spacing = [0.388, 0.388, 0.5] #mm</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
constantImageSource.SetOrigin( origin )</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
constantImageSource.SetSpacing( spacing )</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
constantImageSource.SetSize( sizeOutput )</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
constantImageSource.SetConstant(0.)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
# Generate DRRs</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
JosephType = rtk.JosephForwardProjectionImageFilter[ImageType, ImageType]</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
joseph = JosephType.New()</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
joseph.SetGeometry(geometry)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
joseph.SetInput(constantImageSource.GetOutput())</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
joseph.SetInput(1, CT)</div>
<div style="line-height:19px;white-space:pre-wrap;font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
</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>
</div></blockquote></div>