[Rtk-users] rotating the detector around itself

Simon Rit simon.rit at creatis.insa-lyon.fr
Tue Jul 23 21:08:37 CEST 2024


If that helps, this piece of Python code produces exactly the same
geometries on my computer. I did not see the problem in your code, doesn't
it produce the same geometries?

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

eu = itk.Euler3DTransform.New()
degreesToRadians = np.pi/180.
eu = itk.Euler3DTransform.New()
eu.SetRotation(20 * degreesToRadians, 0, 0);
locSourcePosition = eu.TransformPoint([0,0,1000]);
locDetectorPosition = eu.TransformPoint([0,0,-500]);
locDetectorRowDirection = eu.TransformVector([1,0,0]);
locDetectorColumnDirection = eu.TransformVector([0,1,0]);
geometry = rtk.ThreeDCircularProjectionGeometry.New()
geometry.AddProjection(locSourcePosition, locDetectorPosition,
locDetectorRowDirection, locDetectorColumnDirection)
geometry2 = rtk.ThreeDCircularProjectionGeometry.New()
geometry2.AddProjection(1000.,1500.,0.,0.,0.,20.)
xmlWriter = rtk.ThreeDCircularProjectionGeometryXMLFileWriter.New()
xmlWriter.SetFilename ( 'g' )
xmlWriter.SetObject ( geometry )
xmlWriter.WriteFile()
xmlWriter.SetFilename ( 'g2' )
xmlWriter.SetObject ( geometry2 )
xmlWriter.WriteFile()



On Tue, Jul 23, 2024 at 4:32 PM Nikolay Filatov <filatovna83 at gmail.com>
wrote:

> Yes, it's original drawing, and I  have solved it. Thx. Just another
> little question to clarify my understanding.
> Here is the desired rotation https://imgur.com/a/OjVloNX.
>
> Am I right that if I specify outOfPlaneAngle by the following code (got
> from rtkTestReg23ProjectionGeometry.cpp) I can get the desired rotation,
> i.e. rotation in object coordinate system.
>
> eu->SetRotation(outOfPlaneAngle * degreesToRadians, gantryAngle * degreesToRadians, inPlaneAngle * degreesToRadians);
>
> locSourcePosition = eu->TransformPoint(sourcePosition);
>
> locDetectorPosition = eu->TransformPoint(detectorPosition);
>
> locDetectorRowDirection = eu->TransformVector(detectorRowDirection);
>
> locDetectorColumnDirection = eu->TransformVector(detectorColumnDirection);
>
> geometry_->AddProjection(locSourcePosition, locDetectorPosition, locDetectorRowDirection, locDetectorColumnDirection);
>
>
> While in this call
>     geometry->AddProjection(args_info.sid_arg,
>                             args_info.sdd_arg,
>                             angle,
>                             args_info.proj_iso_x_arg,
>                             args_info.proj_iso_y_arg,
>                             args_info.out_angle_arg,
>                             args_info.in_angle_arg,
>                             args_info.source_x_arg,
>                             args_info.source_y_arg);
> args_info.out_angle_arg performs rotation in detector coordinate system ?
>
>
>
>
>>>         eu->SetRotation(outOfPlaneAngle * degreesToRadians, gantryAngle * degreesToRadians, inPlaneAngle * degreesToRadians);
>>>
>>>         locSourcePosition = eu->TransformPoint(sourcePosition);
>>>
>>>         locDetectorPosition = eu->TransformPoint(detectorPosition);
>>>
>>>         locDetectorRowDirection = eu->TransformVector(detectorRowDirection);
>>>
>>>         locDetectorColumnDirection = eu->TransformVector(detectorColumnDirection);
>>>
>>>
>>>         geometry_->AddReg23Projection(locSourcePosition, locDetectorPosition, locDetectorRowDirection, locDetectorColumnDirection);
>>>
>>>  doesn't the outOfPlaneAngle variable correspond to
>>> args_info.out_angle_arg in the following call :
>>>     geometry->AddProjection(args_info.sid_arg,
>>>                             args_info.sdd_arg,
>>>                             angle,
>>>                             args_info.proj_iso_x_arg,
>>>                             args_info.proj_iso_y_arg,
>>>                             args_info.out_angle_arg,
>>>                             args_info.in_angle_arg,
>>>                             args_info.source_x_arg,
>>>                             args_info.source_y_arg);
>>> ?
>>>
>>> If these are the same,for some reason they work differently. If not,
>>> sorry that I haven't figured it out yet)
>>>
>>> Best regards
>>>
>>>
>>> вт, 23 июл. 2024 г. в 13:20, Simon Rit <simon.rit at creatis.insa-lyon.fr>:
>>>
>>>> Hi,
>>>> I don't follow what you're trying to achieve. outOfPlaneAnle and
>>>> inPlaneAngle are angles in the detector coordinate system. In your example,
>>>> you apply these rotations in the object coordinate systems so they can't be
>>>> an in-plane angle and an out-of-plane angle.
>>>> If I look at your original drawing, you should just set source and
>>>> detector offsets in the X direction.
>>>> Simon
>>>>
>>>> On Tue, Jul 23, 2024 at 9:17 AM Nikolay Filatov <filatovna83 at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi. Yea, thx a lot, new method AddReg23Projection almost does what I
>>>>> need. Tried all offsets and detector's orientations.
>>>>> The only problem with new geometry method is that I can't setup outOfPlaneAngle
>>>>> or inPlaneAngle properly.
>>>>> Here http://90.188.95.4:8080/index.php/s/oADGdyyzRUHfEO8 are two
>>>>> videos where I setup default geometry with arc=360 and outOfPlaneAngle=20
>>>>> for both AddProjection and AddReg23Projection  methods. AddProjection
>>>>> is ok, while AddReg23Projection looks strange to me. I expect the
>>>>> same result, as with gantryAngle.
>>>>>
>>>>> Here is the simple code to generate geometry file with
>>>>> AddReg23Projection.
>>>>>     sourcePosition[0] = 0;
>>>>>     sourcePosition[1] = 0.;
>>>>>     sourcePosition[2] = 1000.;
>>>>>     detectorPosition[0] = 0;
>>>>>     detectorPosition[1] = 0;
>>>>>     detectorPosition[2] = -536.;
>>>>>     detectorRowDirection[0] = 1;
>>>>>     detectorRowDirection[1] = 0;
>>>>>     detectorRowDirection[2] = 0;
>>>>>     detectorColumnDirection[0] = 0;
>>>>>     detectorColumnDirection[1] = 1;
>>>>>     detectorColumnDirection[2] = 0;
>>>>>
>>>>>     const double degreesToRadians = atan(1.0) / 45.;
>>>>>     double outOfPlaneAngle = 20;
>>>>>     double inPlaneAngle = 0;
>>>>>     double gantryAngle = 0;
>>>>>
>>>>>     for (int noProj = 0; noProj < 180; noProj++)
>>>>>     {
>>>>>         double angle = noProj * 360. / 180;
>>>>>         gantryAngle = angle;
>>>>>
>>>>>         eu->SetRotation(outOfPlaneAngle * degreesToRadians,
>>>>> gantryAngle * degreesToRadians, inPlaneAngle * degreesToRadians);
>>>>>         locSourcePosition = eu->TransformPoint(sourcePosition);
>>>>>         locDetectorPosition = eu->TransformPoint(detectorPosition);
>>>>>         locDetectorRowDirection =
>>>>> eu->TransformVector(detectorRowDirection);
>>>>>         locDetectorColumnDirection =
>>>>> eu->TransformVector(detectorColumnDirection);
>>>>>
>>>>>         if (!geometry->AddReg23Projection(locSourcePosition,
>>>>> locDetectorPosition, locDetectorRowDirection, locDetectorColumnDirection))
>>>>>
>>>>>        {
>>>>>           lok = false;
>>>>>         }
>>>>>     }
>>>>>
>>>>>     // Write
>>>>>
>>>>>     rtk::WriteGeometry(geometry, "geometry.xml");
>>>>>
>>>>>
>>>>> Also I executed rtkTestReg23ProjectionGeometry with geometry
>>>>> specified above, and all tests passed..
>>>>> If I missed something, let me know please..
>>>>>
>>>>> Best regards
>>>>>
>>>>>
>>>>> ср, 10 июл. 2024 г. в 12:28, Simon Rit <simon.rit at creatis.insa-lyon.fr
>>>>> >:
>>>>>
>>>>>> Hi,
>>>>>> With 9 degrees of freedom, you can define any position and
>>>>>> orientation of the source / detector with the current parametrization. What
>>>>>> you are showing is a different GantryAngle with a SourceOffset. It's not
>>>>>> always obvious how these should be set but there is a simpler solution:
>>>>>> provide the source position, detector position and coordinates of the two
>>>>>> axes of the detector:
>>>>>>
>>>>>> http://www.openrtk.org/Doxygen/classrtk_1_1ThreeDCircularProjectionGeometry.html#a0fb1475ed76a28cde24fac85eae18e1e
>>>>>> I hope it helps,
>>>>>> Simon
>>>>>>
>>>>>>
>>>>>> On Wed, Jul 10, 2024 at 8:13 AM Nikolay Filatov <
>>>>>> filatovna83 at gmail.com> wrote:
>>>>>>
>>>>>>> Hello RTK users. I've got a question about geometry. I want to
>>>>>>> rotate the detector for all orientations around itself and InPlaneAngle,
>>>>>>> OutOfPlaneAngle perform two rotations, but GantryAngle is not exactly what
>>>>>>> I need (https://imgur.com/a/kDpfk5G)
>>>>>>> Thanks to geometry invariant I can specify this angle through
>>>>>>> source_x, detector_x offset, but source_x affects InPlaneAngle and
>>>>>>> OutOfPlaneAngle. IMHO one of the possible solutions is to change RTK
>>>>>>> geometry final matrix - swap Mrotation and Mtranslation, so source_x
>>>>>>> shouldn't affect InPlaneAngle and OutOfPlaneAngle.
>>>>>>>
>>>>>>> Here
>>>>>>> rtkThreeDCircularProjectionGeometry.cxx
>>>>>>> void
>>>>>>> rtk::ThreeDCircularProjectionGeometry::AddProjectionInRadians(...)
>>>>>>> {
>>>>>>> ...
>>>>>>>   matrix =
>>>>>>> this->GetProjectionTranslationMatrices().back().GetVnlMatrix() *
>>>>>>>            this->GetMagnificationMatrices().back().GetVnlMatrix() *
>>>>>>>
>>>>>>>  this->GetSourceTranslationMatrices().back().GetVnlMatrix();
>>>>>>>            this->GetRotationMatrices().back().GetVnlMatrix();
>>>>>>> --->
>>>>>>>   matrix =
>>>>>>> this->GetProjectionTranslationMatrices().back().GetVnlMatrix() *
>>>>>>>            this->GetMagnificationMatrices().back().GetVnlMatrix() *
>>>>>>>            this->GetRotationMatrices().back().GetVnlMatrix();
>>>>>>>
>>>>>>>  this->GetSourceTranslationMatrices().back().GetVnlMatrix();
>>>>>>> ...
>>>>>>> }
>>>>>>> didn't give desired result.
>>>>>>>
>>>>>>> So, is it somehow possible to specify this angle along with
>>>>>>> InPlaneAngle, OutOfPlaneAngle ?
>>>>>>> _______________________________________________
>>>>>>> Rtk-users mailing list
>>>>>>> rtk-users at openrtk.org
>>>>>>> https://www.creatis.insa-lyon.fr/mailman/listinfo/rtk-users
>>>>>>>
>>>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/rtk-users/attachments/20240723/990539bc/attachment-0001.htm>


More information about the Rtk-users mailing list