Re: [Rtk-users] Does RTK support a scanner with fixed source and detector?

2022-11-28 Thread Simon Rit via Rtk-users
Hi,
The geometric parameters of AddProjection, used in rtksimulatedgeometry.cxx
,
are described in the documentation here
. The artifact indicates that
you're not using the correct parameters indeed...
Good luck,
Simon

On Mon, Nov 28, 2022 at 12:47 PM BG  wrote:

> Hello everyone!
>
> I have scanner, where source and detector are fixed, and object is
> located on a turntable. In that case, real axis of rotation is shifted,
> and it is not intersects with line, which connects source and detector.
>
> I've tried to generate some geometry with rtksimulatedgeometry.cxx and
> use the RTK to reconstruct my images, but I always get some kind of
> doubled images in reconstruction. Can you please guide my, what
> parameters should I use for rtksimulatedgeometry.cxx in order to get the
> correct result?
>
> With very best regards, Eugene.
>
> ___
> Rtk-users mailing list
> Rtk-users@public.kitware.com
> https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users
>
___
Rtk-users mailing list
Rtk-users@public.kitware.com
https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users


[Rtk-users] Does RTK support a scanner with fixed source and detector?

2022-11-28 Thread BG

Hello everyone!

I have scanner, where source and detector are fixed, and object is 
located on a turntable. In that case, real axis of rotation is shifted, 
and it is not intersects with line, which connects source and detector.


I've tried to generate some geometry with rtksimulatedgeometry.cxx and 
use the RTK to reconstruct my images, but I always get some kind of 
doubled images in reconstruction. Can you please guide my, what 
parameters should I use for rtksimulatedgeometry.cxx in order to get the 
correct result?


With very best regards, Eugene.

___
Rtk-users mailing list
Rtk-users@public.kitware.com
https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users


[Rtk-users] Ray-tracing through a binary mask image volume

2022-11-28 Thread Suranga W
Hi,

I have a CT volume and its corresponding binary mask image volume of the
liver.

I just want to ray-trace through a binary mask image volume to generate
mask-projection DRRs.

The DRRs can be sucessfully genrated from the CT volume, but when I passed
the binary mask volume, I did not get the correct result.

Could anyone please assist me in resolving this problem ?  What kind of
change should I make to generate these DRRs ?

The code, resulted DRR versions for CT and mask, CT volume and the binary
mask volume attached herewith for your further reference.

 reference_CT.nii.gz

 reference_liver_binary_mask.nii.gz

import sys
import itk
from itk import RTK as rtk
import itk
import numpy as np

def generateDRRs(input_file=None, output_file=None, sid=1000., sdd=1536., 
gantryAngle=0., 
projOffsetX=0., projOffsetY=0., outOfPlaneAngle=0., 
inPlaneAngle=0., 
sourceOffsetX=0., sourceOffsetY=0., dx=512, dy=512):

CT = itk.imread(input_file, pixel_type=itk.F)
# The CT volume is not correct orientation compatible to the RTK convention 
and point (0,0,0) mm is not in the CT image
# and this is the default centre of rotation in RTK. Therefore  change the 
origin and the direction to use 
# RTK convention to get the correct DRR as expected.
# the input of the Joseph-Filter needs to be oriented in the y-direction. 
In RTK, the rotation axis is y.
# changed the direction and the iamge origin of the image volume to have 
the volume in the xz-layer in the y-direction.
# Three rotation angles are used to define the orientation of the detector. 
# The ZXY convention of Euler angles is used for detector orientation where 
GantryAngle is the rotation around y, 
# OutOfPlaneAngle the rotation around x and InPlaneAngle the rotation 
around z.

# change the direction and origin to align with the RTK convention
CTDirection=np.zeros([3,3])
CTDirection[0,0]=1.
CTDirection[1,2]=1.
CTDirection[2,1]=1.
CT.SetDirection(itk.matrix_from_array(CTDirection))
CT.SetOrigin([CT.GetOrigin()[0],CT.GetOrigin()[2],-CT.GetOrigin()[1]])
CTarray = itk.array_view_from_image(CT)
# add 1000 to CT numbers to put air at 0
CTarray  += 1000 

# Defines the image type
Dimension_CT = 3
PixelType = itk.F
ImageType = itk.Image[PixelType, Dimension_CT]

# Create a stack of empty projection images
ConstantImageSourceType = rtk.ConstantImageSource[ImageType]
constantImageSource = ConstantImageSourceType.New()
# Set origin and spacing based on the Elekta configuration
constantImageSource.SetOrigin([-204.4,-204.4,0])
constantImageSource.SetSpacing([0.8,0.8,0.8])
constantImageSource.SetSize([dx, dy, 1])
constantImageSource.SetConstant(0.)

# Defines the RTK geometry object
geometry = rtk.ThreeDCircularProjectionGeometry.New()

geometry.AddProjection(sid, sdd, gantryAngle, -projOffsetX, -projOffsetY, 
outOfPlaneAngle, inPlaneAngle, sourceOffsetX, sourceOffsetY)

REIType = rtk.JosephForwardProjectionImageFilter[ImageType, ImageType]
rei = REIType.New()

rei.SetGeometry(geometry)
rei.SetInput(0, constantImageSource.GetOutput())
rei.SetInput(1, CT)
rei.Update()

Dimension = 3
OutputPixelType = itk.UC
OutputImageType = itk.Image[OutputPixelType, Dimension]

RescaleType = itk.RescaleIntensityImageFilter[ImageType, OutputImageType]
rescaler = RescaleType.New()
rescaler.SetOutputMinimum(0)
rescaler.SetOutputMaximum(255)
rescaler.SetInput(rei.GetOutput())
rescaler.Update()

# Out of some reason, the computed projection is upsided-down.
# Here we use a FilpImageFilter to flip the images in y direction.
FlipFilterType = itk.FlipImageFilter[OutputImageType]
flipFilter = FlipFilterType.New()

FlipAxesArray = itk.FixedArray[itk.D, 3]()
FlipAxesArray[0] = 0
FlipAxesArray[1] = 1
FlipAxesArray[2] = 0

flipFilter.SetFlipAxes(FlipAxesArray)
flipFilter.SetInput(rescaler.GetOutput())
flipFilter.Update()

WriteType = itk.ImageFileWriter[OutputImageType]
writer = WriteType.New()
writer.SetFileName(output_file)
writer.SetInput(flipFilter.GetOutput())
writer.Update()


ct_file = './reference_CT.nii.gz'
binary_mask_file = './reference_liver_binary_mask.nii.gz'

out_ct_drr_file = './ct_drr_324.png'
out_mask_drr_file = './mask_drr_324.png'

offset_X = 117.085998535
offset_Y = 3.948999882

# generate DRRs fro CT volume
generateDRRs(input_file=ct_file, output_file=out_ct_drr_file, 
projOffsetX=offset_X, projOffsetY=offset_Y, gantryAngle=324)

# generate DRRs from binary mask volume
generateDRRs(input_file=binary_mask_file, output_file=out_mask_drr_file, 
projOffsetX=offset_X, projOffsetY=offset_Y, 

Re: [Rtk-users] Rtk-users Digest, Vol 119, Issue 11

2022-11-28 Thread gameboy514
Dear,

It really helps.
Now I fully understand what you and Simon said.
Thank you for the solution, and I will try as you recommended.

Best regards,
Chang

-Original Message-
From: Rtk-users  On Behalf Of
rtk-users-requ...@public.kitware.com
Sent: Monday, November 28, 2022 4:18 PM
To: rtk-users@public.kitware.com
Subject: Rtk-users Digest, Vol 119, Issue 11

Send Rtk-users mailing list submissions to
rtk-users@public.kitware.com

To subscribe or unsubscribe via the World Wide Web, visit
https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users
or, via email, send a message with subject or body 'help' to
rtk-users-requ...@public.kitware.com

You can reach the person managing the list at
rtk-users-ow...@public.kitware.com

When replying, please edit your Subject line so it is more specific than
"Re: Contents of Rtk-users digest..."


Today's Topics:

   1. Re: Simulating geometric error on detector (Vincent Libertiaux)


--

Message: 1
Date: Mon, 28 Nov 2022 07:40:15 +0100
From: Vincent Libertiaux 
To: rtk-users@public.kitware.com
Subject: Re: [Rtk-users] Simulating geometric error on detector
Message-ID: <88dc932a-49ee-66f7-1127-fa614c639...@xris.eu>
Content-Type: text/plain; charset="utf-8"; Format="flowed"

Hi Chang,

I was faced with the same problem not long ago. Here is the solution that
worked for me:

If we call this extra angle "c", the following modifications have to be made
in rtksimulatedgeometry:

- first angle = c

- sdd = sdd_0 * cos(c)

- sid = sid_0 * cos(c)

- source_x = source_x0 - sid*sin(c)

- proj_iso_x = proj_iso_x0 + (sdd-sid)*sin(c)

Hope it helps !

Best regards,

Vincent

On 27.11.22 22:44, gameboy...@gmail.com wrote:
>
> Dear,
>
> Thank you for your reply, but I still have a question.
>
> I am trying to use Rtksimulatedgeometry which employs Addprojection. 
> It supports in_angle and out_angle, which is clear.
>
> There is also a parameter for gantry angle, but it does not seem that 
> simulation of slant can be done by simply changing the gantry angle.
>
> Left side of the figure is the schematic of simulation that I want 
> which only slants the detector.
>
> But if I perform the simulation as you suggest, the result that I will 
> get would be like the right side of the figure.
>
> To my understanding, the results of these two are not the same. (Slant 
> degree itself is same, but in the perspective of distance reaching to 
> side of the detector, it would be different.)
>
> It would be appreciated to help me to simulate only the slant of the 
> detector.
>
> Regards,
>
> Chang.
>
> *From:*Simon Rit 
> *Sent:* Friday, November 25, 2022 7:49 PM
> *To:* ???
> *Cc:* rtk-users@public.kitware.com
> *Subject:* Re: [Rtk-users] Simulating geometric error on detector
>
> Hi,
>
> There are three rotations to chose the orientation of the detector: 
> GantryAngle, InPlaneAngle and OutOfPlane. Any orientation can be set. 
> If you want a slant around the detector center, then a change in the 
> GantryAngle will imply a change in SourceToIsocenter, SourceToDetector 
> (both measured in the direction orthogonal to the detector) and 
> SourceOffsetX / ProjectionOffsetX. The geometry documentation should help:
>
> http://www.openrtk.org/Doxygen/DocGeo3D.html
>
> If you mind find it to set one detector position by setting the source 
> position, detector origin position and the u and v axes. See all the 
> different versions of AddProjection in the doxygen 
>
<http://www.openrtk.org/Doxygen/classrtk_1_1ThreeDCircularProjectionGeometry
.html>.
>
> Best regards,
>
> Simon
>
> On Fri, Nov 25, 2022 at 10:21 AM ??? wrote:
>
> Dear all,
>
> I am now generating the simulation data with geometric distortions
> on the detector, by using RTK.
>
> Translation can be easily implemented by adjusting the parameters
> (proj_iso_x and proj_iso_y).
>
> However, for the rotation, it seems that there are only two
> parameters I can manage. (in_angle and out_angle).
>
> Thus, at this moment, tilt and skew are available to implement,
> but for the slant, it seems that there is no such way.
>
> Please let me know if there is any way to implement rotation about
> one other axis.
>
> (Image from Wang, Zhao, et al. "Improvements in micro-CT method
> for characterizing x-ray monocapillary optics." /Optics
> Communications/?504 (2022): 127474.)
>
> ___
> Rtk-users mailing list
> Rtk-users@public.kitware.com
> https://public.kitware.com/cgi-bin/mailman/listinfo/rtk-users
>
>
> __