108 cout <<
"-- Rigid transformation algorithm based on trilinear interpolation --" << endl;
109 cout <<
"Each transformation requires 3 translation (x,y,z) and 3 rotation parameters, provided by command-line option or in a text file" << endl;
110 cout <<
"The transformation parameters can be either defined between: " << endl;
111 cout <<
"- A position n and the following position n+1 " << endl;
112 cout <<
"- A reference position and the actual position n (default) " << endl;
113 cout <<
" (Check the 'Transformation mode' keyword below for more information) " << endl;
115 cout <<
"--------------------------------------------------------" << endl;
116 cout <<
"Command-line options:" <<endl;
117 cout <<
"Parameters for each transformation must be provided sequentially and separated by commas" << endl;
118 cout <<
"Example for a dataset containing 3 transformations:" << endl;
119 cout <<
"-rm deformationRigid:trX1,trY1,trZ1,rotX1,rotY1,rotZ1,trX2,trY2,trZ2,rotX2,rotY2,rotZ2,trX3,trY3,trZ3,rotX3,rotY3,rotZ3" << endl;
120 cout <<
"--------------------------------------------------------" << endl;
121 cout <<
"Text file:" <<endl;
122 cout <<
"Parameters for each transformation must be provided after a 'Transformation parameters' key, on a separate line, and separated by commas" << endl;
123 cout <<
"Translations must be provided in mm, for each axis." << endl;
124 cout <<
"Rotations must be provided in degree. Use the Rotation convention optional parameter in order to set up the rotation orientation." << endl;
125 cout <<
"Example for a dataset containing 3 transformations:" << endl;
126 cout <<
"Transformation_parameters:" << endl;
127 cout <<
"trX1,trY1,trZ1,rotA1,rotB1,rotC1" << endl;
128 cout <<
"trX2,trY2,trZ2,rotA2,rotB2,rotC2" << endl;
129 cout <<
"trX3,trY3,trZ3,rotA3,rotB3,rotC3" << endl;
130 cout <<
"etc..." << endl;
132 cout <<
"--------------------------------------------------------" << endl;
133 cout <<
"Optional parameters (configuration file only):" << endl;
135 cout <<
"Rotation_convention: Any combinations of 'x', 'y', and 'z'" << endl;
136 cout <<
"Define the axe on which the rotation will be performed using rotA, rotB and rotC angle in 1 (default): XYZ" << endl;
138 cout <<
"Transformation_mode: (1 or 0)" << endl;
139 cout <<
"0 (default): Transformation between the reference position to the n position." << endl;
140 cout <<
"1 : Transformation between the n-1 position to the n position." << endl;
141 cout <<
" They will be recomputed to represent transformations from a reference position to i as required by CASToR" << endl;
165 Cerr(
"***** iDeformationRigid::ReadAndCheckConfigurationFile() -> Number of transformations in the deformation has not been initialized !" << endl);
170 ifstream in_file(a_fileOptions.c_str(), ios::in);
180 Cerr(
"***** iDeformationRigid::ReadAndCheckConfigurationFile -> A problem occurred while trying to recover transformation parameters from file !" << endl);
187 Cerr(
"***** iDeformationRigid::ReadAndCheckConfigurationFile -> A problem occurred while trying to read 'compute_transformations' flag (must be 1 (true) or 0 (false))!" << endl);
194 Cerr(
"***** iDeformationRigid::ReadAndCheckConfigurationFile -> A problem occurred while trying to read rotation convention (string) !" << endl);
209 mp_tX[t] = p_coeffs[t*6];
210 mp_tY[t] = p_coeffs[t*6+1];
211 mp_tZ[t] = p_coeffs[t*6+2];
212 mp_rA[t] = p_coeffs[t*6+3];
213 mp_rB[t] = p_coeffs[t*6+4];
214 mp_rC[t] = p_coeffs[t*6+5];
219 Cerr(
"***** iDeformationRigid::ReadAndCheckOptionsList() -> An error occurred while building Transformation matrices !" << endl);
228 Cerr(
"***** iDeformationRigid::ReadAndCheckConfigurationFile -> Error while trying to read configuration file : " << a_fileOptions << endl);
253 Cerr(
"***** iDeformationRigid::ReadAndCheckOptionsList() -> Number of transformations in the deformation has not been initialized !" << endl);
264 "Rigid deformation configuration"))
266 Cerr(
"***** iDeformationRigid::ReadAndCheckOptionsList() -> Failed to correctly read the list of parameters in command-line options !" << endl);
267 Cerr(
"***** "<<
m_nbTransformations*6<<
" parameters were expected (6 parameters for each transformation)" << endl);
283 mp_tX[t] = p_coeffs[t*6];
284 mp_tY[t] = p_coeffs[t*6+1];
285 mp_tZ[t] = p_coeffs[t*6+2];
286 mp_rA[t] = p_coeffs[t*6+3];
287 mp_rB[t] = p_coeffs[t*6+4];
288 mp_rC[t] = p_coeffs[t*6+5];
293 Cerr(
"***** iDeformationRigid::ReadAndCheckOptionsList() -> An error occurred while building Transformation matrices !" << endl);
321 Cerr(
"***** iDeformationRigid::ComputeTransformationMatrices() -> Parameters not initialized !" << endl);
349 for(
int d=0 ; d<2 ; d++)
356 x_rad = -
mp_rA[t] * M_PI/180.;
357 y_rad = -
mp_rB[t] * M_PI/180.;
358 z_rad = -
mp_rC[t] * M_PI/180.;
382 Cerr(
"***** iDeformationRigid::ComputeTransformationMatrices() -> Error occurred when initializing rotation matrices !" << endl);
399 for(
int l=0 ; l<4 ; l++)
400 for(
int c=0 ; c<4 ; c++)
406 for(
int l=0 ; l<4 ; l++)
407 for(
int c=0 ; c<4 ; c++)
444 Cerr(
"***** iDeformationRigid::CheckSpecificParameters() -> Transformation parameters not initialized !" << endl);
470 Cerr(
"***** iDeformationRigid::Initialize() -> Parameters should be checked before Initialize() !" << endl);
505 Cerr(
"***** iDeformationRigid::ApplyDeformations() -> Called while not initialized !" << endl);
511 << (
string)((a_direction==
FORWARD_DEFORMATION)?
"forward":
"backward") <<
"), with parameters " 512 <<
mp_tX[a_defIdx] <<
";" <<
mp_tY[a_defIdx] <<
";" <<
mp_tZ[a_defIdx] <<
";" 513 <<
mp_rA[a_defIdx] <<
";" <<
mp_rB[a_defIdx] <<
";" <<
mp_rC[a_defIdx] <<
";" << endl);
554 #ifdef CASTOR_VERBOSE 593 Cerr(
"*****iDeformationRigid::ApplyDeformationToForwardImage()->Error, unknown direction type( must be 'forward' or 'backward' # " << endl);
601 uint32_t iv = ivZ*dXY + ivY*dX + ivX;
605 dvZ = (oVect->
GetMatriceElt(2,0) - (ivZ*sZ - dZ*sZ/2 + sZ*0.5) ) / sZ;
606 dvY = (oVect->
GetMatriceElt(1,0) - (ivY*sY - dY*sY/2 + sY*0.5) ) / sY;
607 dvX = (oVect->
GetMatriceElt(0,0) - (ivX*sX - dX*sX/2 + sX*0.5) ) / sX;
618 Tlerp(ap_inputImage, ap_outputImage, v, iv, dvX, dvY, dvZ);
651 string a = a_cvt.substr(0, 1);
652 string b = a_cvt.substr(1, 1);
653 string c = a_cvt.substr(2, 1);
656 if (a ==
"X" || a ==
"x")
658 else if(a ==
"Y" || a ==
"y")
660 else if(a ==
"Z" || a ==
"z")
664 Cerr(
"*****iDeformationRigid::SetRotationMatrix()-> Symbol'"<< a <<
"' unknown for rotation convention! " << endl);
669 if (b ==
"X" || b ==
"x")
671 else if(b ==
"Y" || b ==
"y")
673 else if(b ==
"Z" || b ==
"z")
677 Cerr(
"*****iDeformationRigid::SetRotationMatrix()-> Symbol'"<< b <<
"' unknown for rotation convention! " << endl);
682 if (c ==
"X" || c ==
"x")
684 else if(c ==
"Y" || c ==
"y")
686 else if(c ==
"Z" || c ==
"z")
690 Cerr(
"*****iDeformationRigid::SetRotationMatrix()-> Symbol'"<< c <<
"' unknown for rotation convention! " << endl);
FLTNB GetVoxSizeX()
Get the voxel's size along the X axis, in mm.
FLTNB GetVoxSizeZ()
Get the voxel's size along the Z axis, in mm.
FLTNB GetVoxSizeY()
Get the voxel's size along the Y axis, in mm.
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
INTNB GetNbVoxXY()
Get the number of voxels in a slice.
HPFLTNB GetMatriceElt(uint16_t l, uint16_t c)
#define KEYWORD_MANDATORY
INTNB GetNbVoxXYZ()
Get the total number of voxels.
Structure designed for basic matrices operations.
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
int SetXRotMtx(HPFLTNB ang)
Set a (3,3) X-axis rotation matrix using the provided angle.
INTNB GetNbVoxZ()
Get the number of voxels along the Z axis.
int Multiplication(oMatrix *ap_Mtx, oMatrix *ap_MtxResult)
Multiply the member matrix with the matrix provided in 1st parameter Return the result in the matric ...
int SetMatriceElt(uint16_t l, uint16_t c, HPFLTNB a_val)
Set the matrix element corresponding to the argument indices with the provided value.
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
int SetZRotMtx(HPFLTNB ang)
Set a (3,3) Z-axis rotation matrix using the provided angle.
int SetYRotMtx(HPFLTNB ang)
Set a (3,3) Y-axis rotation matrix using the provided angle.
INTNB GetNbVoxY()
Get the number of voxels along the Y axis.
#define KEYWORD_OPTIONAL_ERROR