Skip to content

Commit f85e404

Browse files
blowekampjhlegarreta
authored andcommitted
STYLE: address variable nameing conventions comments
1 parent 0e41389 commit f85e404

File tree

3 files changed

+75
-76
lines changed

3 files changed

+75
-76
lines changed

Modules/IO/MINC/src/itkMINCImageIO.cxx

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -449,20 +449,20 @@ MINCImageIO::ReadImageInformation()
449449

450450
this->SetNumberOfDimensions(spatial_dimension_count);
451451

452-
int numberOfComponents = 1;
453-
int usable_dimensions = 0;
452+
int numberOfComponents = 1;
453+
unsigned int usableDimensions = 0;
454454

455455
auto dir_cos = Matrix<double, 3, 3>::GetIdentity();
456456

457-
// Conversion matrix for MINC PositiveCoordinateOrientation RAS (RightToLeft,AnteriorToPosterior,SuperiorToInferior)
458-
// to ITK PositiveCoordinateOrientation LPS (LeftToRight,PosteriorToInferior,SuperiortoInferior)
459-
auto RAS_tofrom_LPS = Matrix<double, 3, 3>::GetIdentity();
460-
RAS_tofrom_LPS(0, 0) = -1.0;
461-
RAS_tofrom_LPS(1, 1) = -1.0;
457+
// Conversion matrix for MINC PositiveCoordinateOrientation RAS (LeftToRight, PosteriorToAnterior, InferiorToSuperior)
458+
// to ITK PositiveCoordinateOrientation LPS (RightToLeft, AnteriorToPosterior, InferiorToSuperior)
459+
auto RAStofromLPS = Matrix<double, 3, 3>::GetIdentity();
460+
RAStofromLPS(0, 0) = -1.0;
461+
RAStofromLPS(1, 1) = -1.0;
462462
std::vector<double> dir_cos_temp(3);
463463

464464
Vector<double, 3> origin{};
465-
Vector<double, 3> o_origin{};
465+
Vector<double, 3> oOrigin{};
466466

467467
// minc api uses inverse order of dimensions , fastest varying are last
468468
Vector<double, 3> sep;
@@ -472,19 +472,19 @@ MINCImageIO::ReadImageInformation()
472472
{
473473
// MINC2: bad design!
474474
// micopy_dimension(hdim[m_MINCPImpl->m_DimensionIndices[i]],&apparent_dimension_order[usable_dimensions]);
475-
m_MINCPImpl->m_MincApparentDims[usable_dimensions] =
475+
m_MINCPImpl->m_MincApparentDims[usableDimensions] =
476476
m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[i]];
477477
// always use positive
478-
miset_dimension_apparent_voxel_order(m_MINCPImpl->m_MincApparentDims[usable_dimensions], MI_POSITIVE);
478+
miset_dimension_apparent_voxel_order(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_POSITIVE);
479479
misize_t _sz;
480-
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usable_dimensions], &_sz);
480+
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usableDimensions], &_sz);
481481

482482
double _sep;
483-
miget_dimension_separation(m_MINCPImpl->m_MincApparentDims[usable_dimensions], MI_ORDER_APPARENT, &_sep);
483+
miget_dimension_separation(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_ORDER_APPARENT, &_sep);
484484
std::vector<double> _dir(3);
485-
miget_dimension_cosines(m_MINCPImpl->m_MincApparentDims[usable_dimensions], &_dir[0]);
485+
miget_dimension_cosines(m_MINCPImpl->m_MincApparentDims[usableDimensions], &_dir[0]);
486486
double _start;
487-
miget_dimension_start(m_MINCPImpl->m_MincApparentDims[usable_dimensions], MI_ORDER_APPARENT, &_start);
487+
miget_dimension_start(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_ORDER_APPARENT, &_start);
488488

489489
for (int j = 0; j < 3; ++j)
490490
{
@@ -497,22 +497,22 @@ MINCImageIO::ReadImageInformation()
497497
this->SetDimensions(i - 1, static_cast<unsigned int>(_sz));
498498
this->SetSpacing(i - 1, _sep);
499499

500-
++usable_dimensions;
500+
++usableDimensions;
501501
}
502502
}
503503

504504

505505
// Transform MINC PositiveCoordinateOrientation RAS coordinates to
506506
// internal ITK PositiveCoordinateOrientation LPS Coordinates
507507
if (this->m_RAStoLPS)
508-
dir_cos = RAS_tofrom_LPS * dir_cos;
508+
dir_cos = RAStofromLPS * dir_cos;
509509

510510
// Transform origin coordinates
511-
o_origin = dir_cos * origin;
511+
oOrigin = dir_cos * origin;
512512

513513
for (int i = 0; i < spatial_dimension_count; ++i)
514514
{
515-
this->SetOrigin(i, o_origin[i]);
515+
this->SetOrigin(i, oOrigin[i]);
516516
for (unsigned int j = 0; j < 3; j++)
517517
{
518518
dir_cos_temp[j] = dir_cos[j][i];
@@ -523,31 +523,29 @@ MINCImageIO::ReadImageInformation()
523523
if (m_MINCPImpl->m_DimensionIndices[0] != -1) // have vector dimension
524524
{
525525
// micopy_dimension(m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[0]],&apparent_dimension_order[usable_dimensions]);
526-
m_MINCPImpl->m_MincApparentDims[usable_dimensions] =
527-
m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[0]];
526+
m_MINCPImpl->m_MincApparentDims[usableDimensions] = m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[0]];
528527
// always use positive, vector dimension does not supposed to have notion of positive step size, so leaving as is
529528
// miset_dimension_apparent_voxel_order(m_MINCPImpl->m_MincApparentDims[usable_dimensions],MI_POSITIVE);
530529
misize_t _sz;
531-
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usable_dimensions], &_sz);
530+
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usableDimensions], &_sz);
532531
numberOfComponents = _sz;
533-
++usable_dimensions;
532+
++usableDimensions;
534533
}
535534

536535
if (m_MINCPImpl->m_DimensionIndices[4] != -1) // have time dimension
537536
{
538537
// micopy_dimension(hdim[m_MINCPImpl->m_DimensionIndices[4]],&apparent_dimension_order[usable_dimensions]);
539-
m_MINCPImpl->m_MincApparentDims[usable_dimensions] =
540-
m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[4]];
538+
m_MINCPImpl->m_MincApparentDims[usableDimensions] = m_MINCPImpl->m_MincFileDims[m_MINCPImpl->m_DimensionIndices[4]];
541539
// always use positive
542-
miset_dimension_apparent_voxel_order(m_MINCPImpl->m_MincApparentDims[usable_dimensions], MI_POSITIVE);
540+
miset_dimension_apparent_voxel_order(m_MINCPImpl->m_MincApparentDims[usableDimensions], MI_POSITIVE);
543541
misize_t _sz;
544-
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usable_dimensions], &_sz);
542+
miget_dimension_size(m_MINCPImpl->m_MincApparentDims[usableDimensions], &_sz);
545543
numberOfComponents = _sz;
546-
++usable_dimensions;
544+
++usableDimensions;
547545
}
548546

549547
// Set apparent dimension order to the MINC2 api
550-
if (miset_apparent_dimension_order(m_MINCPImpl->m_Volume, usable_dimensions, m_MINCPImpl->m_MincApparentDims) < 0)
548+
if (miset_apparent_dimension_order(m_MINCPImpl->m_Volume, usableDimensions, m_MINCPImpl->m_MincApparentDims) < 0)
551549
{
552550
itkExceptionMacro(" Can't set apparent dimension order!");
553551
}
@@ -967,8 +965,8 @@ MINCImageIO::WriteImageInformation()
967965
}
968966

969967
// allocating dimensions
970-
vnl_matrix<double> dircosmatrix(nDims, nDims);
971-
dircosmatrix.set_identity();
968+
vnl_matrix<double> directionCosineMatrix(nDims, nDims);
969+
directionCosineMatrix.set_identity();
972970
vnl_vector<double> origin(nDims);
973971

974972
// MINC stores direction cosines in PositiveCoordinateOrientation RAS
@@ -982,18 +980,18 @@ MINCImageIO::WriteImageInformation()
982980
{
983981
for (unsigned int j = 0; j < nDims; ++j)
984982
{
985-
dircosmatrix[i][j] = this->GetDirection(i)[j];
983+
directionCosineMatrix[i][j] = this->GetDirection(i)[j];
986984
}
987985
origin[i] = this->GetOrigin(i);
988986
}
989987

990-
const vnl_matrix<double> inverseDirectionCosines{ vnl_matrix_inverse<double>(dircosmatrix).as_matrix() };
988+
const vnl_matrix<double> inverseDirectionCosines{ vnl_matrix_inverse<double>(directionCosineMatrix).as_matrix() };
991989
origin *= inverseDirectionCosines; // transform to minc convention
992990

993991

994992
// Convert ITK direction cosines from PositiveCoordinateOrientation LPS to PositiveCoordinateOrientation RAS
995993
if (this->m_RAStoLPS)
996-
dircosmatrix *= RAS_tofrom_LPS;
994+
directionCosineMatrix *= RAS_tofrom_LPS;
997995

998996
for (unsigned int i = 0; i < nDims; ++i)
999997
{
@@ -1003,7 +1001,7 @@ MINCImageIO::WriteImageInformation()
10031001
{
10041002
if (k < nDims)
10051003
{
1006-
dir_cos[k] = dircosmatrix[i][k];
1004+
dir_cos[k] = directionCosineMatrix[i][k];
10071005
}
10081006
else
10091007
{

Modules/IO/MINC/test/itkMINCImageIOTest4.cxx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ test_image_moments(const char * input_image,
3737
double my,
3838
double mz,
3939
double epsilon,
40-
bool ras_to_lps)
40+
bool RAStofromLPS)
4141
{
42-
if (ras_to_lps)
42+
if (RAStofromLPS)
4343
{ // need to flip expected moments to match flipped coordinate system
4444
mx = -mx;
4545
my = -my;
4646
}
4747

4848
itk::MINCImageIO::Pointer mincIO1 = itk::MINCImageIO::New();
49-
mincIO1->SetRAStoLPS(ras_to_lps);
49+
mincIO1->SetRAStoLPS(RAStofromLPS);
5050

5151
using ReaderType = itk::ImageFileReader<ImageType>;
5252

@@ -100,7 +100,7 @@ test_image_moments(const char * input_image,
100100
auto writer = WriterType::New();
101101
writer->SetFileName(output_image);
102102
// writer should use default RAS to LPS flag, to satisfy comparison after
103-
mincIO1->SetRAStoLPS(ras_to_lps);
103+
mincIO1->SetRAStoLPS(RAStofromLPS);
104104
if (itksys::SystemTools::StringEndsWith(output_image, ".mnc")) // HACK to enable use .mhd files
105105
writer->SetImageIO(mincIO1);
106106

@@ -129,8 +129,8 @@ itkMINCImageIOTest4(int argc, char * argv[])
129129

130130
const char * input = argv[1];
131131
const char * output = argv[2];
132-
int ras_to_lps_test = atoi(argv[3]);
133-
bool ras_to_lps = ras_to_lps_test < 0 ? false : ras_to_lps_test == 1;
132+
int RAStofromLPSTest = atoi(argv[3]);
133+
bool RAStofromLPS = RAStofromLPSTest < 0 ? false : RAStofromLPSTest == 1;
134134

135135
double total = 0.0;
136136
double mx = 0.0;
@@ -164,13 +164,14 @@ itkMINCImageIOTest4(int argc, char * argv[])
164164
int ret = EXIT_SUCCESS;
165165

166166
std::cout.precision(10);
167-
if (test_image_moments<itk::Image<double, 3>>(input, nullptr, total, mx, my, mz, epsilon, ras_to_lps) !=
167+
if (test_image_moments<itk::Image<double, 3>>(input, nullptr, total, mx, my, mz, epsilon, RAStofromLPS) !=
168168
EXIT_SUCCESS)
169169
{
170170
ret = EXIT_FAILURE;
171171
}
172172
// write out only float image
173-
if (test_image_moments<itk::Image<float, 3>>(input, output, total, mx, my, mz, epsilon, ras_to_lps) != EXIT_SUCCESS)
173+
if (test_image_moments<itk::Image<float, 3>>(input, output, total, mx, my, mz, epsilon, RAStofromLPS) !=
174+
EXIT_SUCCESS)
174175
{
175176
ret = EXIT_FAILURE;
176177
}

Modules/IO/TransformMINC/src/itkMINCTransformIO.cxx

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -97,37 +97,37 @@ MINCTransformIOTemplate<TParametersValueType>::ReadOneTransform(VIO_General_tran
9797
parameterArray.SetSize(12);
9898

9999

100-
Matrix<double, 4, 4> _affine_transform;
100+
Matrix<double, 4, 4> affineMatrix;
101101

102-
_affine_transform.SetIdentity();
102+
affineMatrix.SetIdentity();
103103

104104
// MINC stores transforms in PositiveCoordinateOrientation RAS
105105
// need to convert to PositiveCoordinateOrientation LPS for ITK
106-
Matrix<double, 4, 4> RAS_tofrom_LPS;
107-
RAS_tofrom_LPS.SetIdentity();
108-
RAS_tofrom_LPS(0, 0) = -1.0;
109-
RAS_tofrom_LPS(1, 1) = -1.0;
106+
Matrix<double, 4, 4> RAStofromLPS;
107+
RAStofromLPS.SetIdentity();
108+
RAStofromLPS(0, 0) = -1.0;
109+
RAStofromLPS(1, 1) = -1.0;
110110

111111
for (int j = 0; j < 3; ++j)
112112
{
113113
for (int i = 0; i < 3; ++i)
114114
{
115-
_affine_transform(i, j) = Transform_elem(*lin, j, i);
115+
affineMatrix(i, j) = Transform_elem(*lin, j, i);
116116
}
117117
// shifts
118-
_affine_transform(3, j) = Transform_elem(*lin, j, 3);
118+
affineMatrix(3, j) = Transform_elem(*lin, j, 3);
119119
}
120120

121121
if (this->m_RAStoLPS) // flip RAS PositiveCoordinateOrientation to LPS PositiveCoordinateOrientation
122-
_affine_transform = RAS_tofrom_LPS * _affine_transform * RAS_tofrom_LPS;
122+
affineMatrix = RAStofromLPS * affineMatrix * RAStofromLPS;
123123

124124
for (int j = 0; j < 3; ++j)
125125
{
126126
for (int i = 0; i < 3; ++i)
127127
{
128-
parameterArray.SetElement(i + j * 3, _affine_transform(i, j));
128+
parameterArray.SetElement(i + j * 3, affineMatrix(i, j));
129129
}
130-
parameterArray.SetElement(j + 9, _affine_transform(3, j));
130+
parameterArray.SetElement(j + 9, affineMatrix(3, j));
131131
}
132132

133133
if (xfm->inverse_flag)
@@ -167,7 +167,7 @@ MINCTransformIOTemplate<TParametersValueType>::ReadOneTransform(VIO_General_tran
167167
using GridImageType = typename DisplacementFieldTransformType::DisplacementFieldType;
168168
using MincReaderType = ImageFileReader<GridImageType>;
169169
using OutputPixelType = vnl_vector_fixed<TParametersValueType, 3>;
170-
const OutputPixelType RAS_tofrom_LPS_vector = { -1, -1, 1 };
170+
const OutputPixelType RAStofromLPSVector = { -1, -1, 1 };
171171

172172
auto mincIO = MINCImageIO::New();
173173
mincIO->SetRAStoLPS(this->m_RAStoLPS);
@@ -188,13 +188,13 @@ MINCTransformIOTemplate<TParametersValueType>::ReadOneTransform(VIO_General_tran
188188
itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New();
189189
mt->ParallelizeImageRegion<3>(
190190
grid->GetBufferedRegion(),
191-
[grid, LPSgrid, RAS_tofrom_LPS_vector](const typename GridImageType::RegionType & region) {
191+
[grid, LPSgrid, RAStofromLPSVector](const typename GridImageType::RegionType & region) {
192192
itk::Vector<TParametersValueType, 3> p;
193193
itk::ImageRegionConstIterator<GridImageType> iIt(grid, region);
194194
itk::ImageRegionIterator<GridImageType> oIt(LPSgrid, region);
195195
for (; !iIt.IsAtEnd(); ++iIt, ++oIt)
196196
{
197-
p.SetVnlVector(element_product(iIt.Get().GetVnlVector(), RAS_tofrom_LPS_vector));
197+
p.SetVnlVector(element_product(iIt.Get().GetVnlVector(), RAStofromLPSVector));
198198
oIt.Set(p);
199199
}
200200
},
@@ -286,34 +286,34 @@ MINCTransformIOTemplate<TParametersValueType>::WriteOneTransform(const int
286286

287287
// MINC stores everything in PositiveCoordinateOrientation RAS
288288
// need to convert from PositiveCoordinateOrientation LPS
289-
Matrix<double, 4, 4> RAS_tofrom_LPS;
290-
Matrix<double, 4, 4> _affine_transform;
289+
Matrix<double, 4, 4> RAStofromLPS;
290+
Matrix<double, 4, 4> affineMatrix;
291291

292-
RAS_tofrom_LPS.SetIdentity();
293-
RAS_tofrom_LPS(0, 0) = -1.0;
294-
RAS_tofrom_LPS(1, 1) = -1.0;
295-
_affine_transform.SetIdentity();
292+
RAStofromLPS.SetIdentity();
293+
RAStofromLPS(0, 0) = -1.0;
294+
RAStofromLPS(1, 1) = -1.0;
295+
affineMatrix.SetIdentity();
296296

297297

298298
for (int j = 0; j < 3; ++j)
299299
{
300300
for (int i = 0; i < 3; ++i)
301301
{
302-
_affine_transform(j, i) = matrix(j, i);
302+
affineMatrix(j, i) = matrix(j, i);
303303
}
304-
_affine_transform(3, j) = offset[j];
304+
affineMatrix(3, j) = offset[j];
305305
}
306306

307307
if (this->m_RAStoLPS)
308-
_affine_transform = RAS_tofrom_LPS * _affine_transform * RAS_tofrom_LPS;
308+
affineMatrix = RAStofromLPS * affineMatrix * RAStofromLPS;
309309

310310
for (int j = 0; j < 3; ++j)
311311
{
312312
for (int i = 0; i < 3; ++i)
313313
{
314-
Transform_elem(lin, j, i) = _affine_transform(j, i);
314+
Transform_elem(lin, j, i) = affineMatrix(j, i);
315315
}
316-
Transform_elem(lin, j, 3) = _affine_transform(3, j);
316+
Transform_elem(lin, j, 3) = affineMatrix(3, j);
317317
}
318318
// add 4th normalization row (not stored)
319319
Transform_elem(lin, 3, 3) = 1.0;
@@ -330,7 +330,7 @@ MINCTransformIOTemplate<TParametersValueType>::WriteOneTransform(const int
330330
using MincWriterType = ImageFileWriter<GridImageType>;
331331
typename GridImageType::Pointer grid = GridImageType::New();
332332
using OutputPixelType = vnl_vector_fixed<TParametersValueType, 3>;
333-
const OutputPixelType RAS_tofrom_LPS_vector = { -1, -1, 1 };
333+
const OutputPixelType RAStofromLPSVector = { -1, -1, 1 };
334334
auto * _grid_transform = static_cast<DisplacementFieldTransformType *>(const_cast<TransformType *>(curTransform));
335335
char tmp[1024];
336336
snprintf(tmp, sizeof(tmp), "%s_grid_%d.mnc", xfm_file_base, serial);
@@ -361,27 +361,27 @@ MINCTransformIOTemplate<TParametersValueType>::WriteOneTransform(const int
361361

362362
if (this->m_RAStoLPS)
363363
{
364-
typename GridImageType::Pointer ras_grid = GridImageType::New(); // flipped grid for RAS->LPS conversion
365-
ras_grid->CopyInformation(grid);
366-
ras_grid->SetRegions(grid->GetBufferedRegion());
367-
ras_grid->Allocate(true);
364+
typename GridImageType::Pointer rasGrid = GridImageType::New(); // flipped grid for RAS->LPS conversion
365+
rasGrid->CopyInformation(grid);
366+
rasGrid->SetRegions(grid->GetBufferedRegion());
367+
rasGrid->Allocate(true);
368368

369369
itk::MultiThreaderBase::Pointer mt = itk::MultiThreaderBase::New();
370370
mt->ParallelizeImageRegion<3>(
371371
grid->GetBufferedRegion(),
372-
[grid, ras_grid, RAS_tofrom_LPS_vector](const typename GridImageType::RegionType & region) {
372+
[grid, rasGrid, RAStofromLPSVector](const typename GridImageType::RegionType & region) {
373373
itk::Vector<TParametersValueType, 3> p;
374374
itk::ImageRegionConstIterator<GridImageType> iIt(grid, region);
375-
itk::ImageRegionIterator<GridImageType> oIt(ras_grid, region);
375+
itk::ImageRegionIterator<GridImageType> oIt(rasGrid, region);
376376
for (; !iIt.IsAtEnd(); ++iIt, ++oIt)
377377
{
378-
p.SetVnlVector(element_product(iIt.Get().GetVnlVector(), RAS_tofrom_LPS_vector));
378+
p.SetVnlVector(element_product(iIt.Get().GetVnlVector(), RAStofromLPSVector));
379379
oIt.Set(p);
380380
}
381381
},
382382
nullptr);
383383

384-
writer->SetInput(ras_grid);
384+
writer->SetInput(rasGrid);
385385
}
386386
else
387387
{

0 commit comments

Comments
 (0)