Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove itkv3compat dependency fix warnings and errors fix extension package #45

Conversation

jcfr
Copy link
Contributor

@jcfr jcfr commented Sep 4, 2017

@juanprietob @styner While testing the recent updates associated with Slicer build system, I ended updating your extension.

I also realized that the extension was building its own copy of BRAINSTools, ITK and SlicerExecutionModel because it was depending on a version of ITK built with ITKV3_COMPATIBILTY.

Since this wasn't a strategic use of build time we provide on the Slicer build machine, I spent some time improving the extension.

Where possible, I updated the code to use ITKv4 constructs and where it wasn't doable quickly I ended up copying the ITK classes adding the Niral prefix to the file and moving the class in a itk::niral:: namespace instead of the usual itk:: one.

Commit message have been made to as informative as possible:

  • reference to specific commit will indicate at which revision an ITK file has been copied
  • link to documentation are added to help future developer
  • snippet of the error/warning fixed by a commit are included to give context

These should facilitate review.

All of that said, please, consider reviewing and testing this set of changes.

Similarly, I contributed changes to the following repository:

If you prefer, I can update this branch after your are done reviewing and updating the other projects.

As a side note, the extension still require some work to work with Qt5.

Let us know with you have any questions. The Slicer discussion forum is a good outlet for questions.

As a side note, the migration guide associated with VTK6, VTK7, VTK8, Qt5 and Slicer are now all linked of https://www.slicer.org/wiki/Documentation/Nightly/Developers/Tutorials/MigrationGuide

Cc: @fedorov @lassoan @pieper @bpaniagua @fbudin69500

This commit updates the required version to 3.5
This commit fixes the following warning:

```
CMake Warning (dev) at DTIPrepTools.cmake:195:
  Syntax Warning in cmake code at column 50

  Argument not separated from preceding token by whitespace.
Call Stack (most recent call first):
  CMakeLists.txt:31 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
```
…mpatibility

This commit updates code to directly use KernelFunctionBase instead of
KernelFunction.
This commit fixes warnings like the following:

```
/tmp/DTIPrep/src/itkDWIQCSliceChecker.hxx: In member function ‘void itk::DWIQCSliceChecker<TImageType>::calculateCorrelations(bool)’:
/tmp/DTIPrep/src/itkDWIQCSliceChecker.hxx:347:71: warning: declaration of ‘FilterType’ shadows a previous local [-Wshadow]
                                                  ShortSliceImageType> FilterType;
                                                                       ^
/tmp/DTIPrep/src/itkDWIQCSliceChecker.hxx:286:71: note: shadowed declaration is here
                                                    GradientImageType> FilterType;
                                                                       ^
```
This commit explicitly links against the libraries as it would be done
using SEMMacroBuildCLI macro.

It fixes the following error:

```
[ 22%] Linking CXX executable /tmp/DTIPrep-build/bin/DTIPrepLauncher
CMakeFiles/DTIPrepLauncher.dir/Launcher.cxx.o: In function `main':
Launcher.cxx:(.text.startup+0x7dd): undefined reference to `Json::Value::Value(Json::ValueType)'
Launcher.cxx:(.text.startup+0x7ec): undefined reference to `Json::Reader::Reader()'

[...]
```
…ed "GetRotationMatrix"

This commit fixes the build errors like the following when building against
ITK without ITKV3Compatibility module:

```
/tmp/DTIPrep/src/itkLinearHeadEddy3DCorrection.hxx: In member function ‘const RotationMatrixType& itk::LinearHeadEddy3DCorrection<TScalarType, NInputDimensions, NOutputDimensions>::GetHeadMotionRotationMatrix() const’:
/tmp/DTIPrep/src/itkLinearHeadEddy3DCorrection.hxx:174:35: error: ‘itk::SmartPointer<itk::VersorRigid3DTransform<double> >::ObjectType {aka struct itk::VersorRigid3DTransform<double>}’ has no member named ‘GetRotationMatrix’
   return m_head_motion_transform->GetRotationMatrix();
                                   ^
```
…cal-typedefs]

This commit fixes warnings like the following:

```
/tmp/DTIPrep/src/itkDWIQCGradientChecker.hxx: In member function ‘void itk::DWIQCGradientChecker<TImageType>::rigidRegistration(itk::Image<short unsigned int, 3u>::Pointer, itk::Image<short unsigned int, 3u>::Pointer, unsigned int, double, bool, itk::DWIQCGradientChecker<TImageType>::GradientResult&)’:
/tmp/DTIPrep/src/itkDWIQCGradientChecker.hxx:123:3: warning: typedef ‘SpacingType’ locally defined but not used [-Wunused-local-typedefs]
   SpacingType;
   ^
/tmp/DTIPrep/src/itkDWIQCGradientChecker.hxx:125:3: warning: typedef ‘OriginType’ locally defined but not used [-Wunused-local-typedefs]
   OriginType;
   ^
/tmp/DTIPrep/src/itkDWIQCGradientChecker.hxx:127:3: warning: typedef ‘RegionType’ locally defined but not used [-Wunused-local-typedefs]
   RegionType;
   ^
/tmp/DTIPrep/src/itkDWIQCGradientChecker.hxx:129:3: warning: typedef ‘SizeType’ locally defined but not used [-Wunused-local-typedefs]
   SizeType;
   ^
```
…ble]

This commit fixes warnings like the following:

```
/tmp/DTIPrep/src/itkDWIEddyCurrentHeadMotionCorrector.hxx:240:7: warning: variable ‘DWICount’ set but not used [-Wunused-but-set-variable]
   int DWICount, BaselineCount;
       ^
/tmp/DTIPrep/src/itkDWIEddyCurrentHeadMotionCorrector.hxx:240:17: warning: variable ‘BaselineCount’ set but not used [-Wunused-but-set-variable]
   int DWICount, BaselineCount;
                 ^
```
…logic issue

Based on the operator precedence [1], adding parenthesis around
"!qcResult.Get_result()" would be the right things to do address
the warning, that said this is incorrect since the value returned
by "Get_result()" always evaluates to 1 or 0.

[1] http://en.cppreference.com/w/c/language/operator_precedence

See NIRALUser#44

This commit improves readability introducing intermediate variables
and move the logical not operator outside the bitwise test.

This commit fixes the following warning:

```
tmp/DTIPrep/src/IntensityMotionCheckPanel.cxx: In member function ‘void IntensityMotionCheckPanel::ResultUpdate()’:
/tmp/DTIPrep/src/IntensityMotionCheckPanel.cxx:3978:33: warning: suggest parentheses around operand of ‘!’ or change ‘&’ to ‘&&’ or ‘!’ to ‘~’ [-Wparentheses]
   if( ( ( (!qcResult.Get_result()  & InterlaceWiseCheckBit) == InterlaceWiseCheckBit ) ||
                                 ^
```
…tImage"

The function "GetCoefficientImage" is not available when building with
ITKV3_COMPATIBILITY disabled.
…ializer

See "B-spline Registration Refactoring" migration guide
available at https://itk.org/migrationv4/index.php?action=artikel&cat=3&id=82&artlang=en
and also documentation associated with itk::BSplineTransform::SetFixedParameters()
at https://itk.org/Insight/Doxygen/html/classitk_1_1BSplineTransform.html#aff697faefc33b586c4560114226bc499

Note that call to "GetGridRegion()" was replaced with call
to "GetTransformDomainMeshSize()".


This commit fixes build errors like the following when building against
ITK without ITKV3Compatibility module:

```
/tmp/DTIPrep/src/itkMultiImageRegistrationFilter.h:242:11: error: ‘BSplineDeformableTransformInitializer’ does not name a type
   typedef BSplineDeformableTransformInitializer<BSplineTransformType, ImageType> BSplineInitializerType;
           ^
/tmp/DTIPrep/src/itkMultiImageRegistrationFilter.h:330:15: error: ‘BSplineInitializerType’ was not declared in this scope
   std::vector<BSplineInitializerType::Pointer> m_BsplineInitializerArray;
               ^
/tmp/DTIPrep/src/itkMultiImageRegistrationFilter.h:330:46: error: template argument 1 is invalid
   std::vector<BSplineInitializerType::Pointer> m_BsplineInitializerArray;
                                              ^
/tmp/DTIPrep/src/itkMultiImageRegistrationFilter.h:330:46: error: template argument 2 is invalid
In file included from /tmp/DTIPrep/src/GMainWindow.h:6:0,
                 from /tmp/DTIPrep/src/main.cxx:11:

```
…formInitializer"

This reverts commit c08f230a0cb00204b352ae8820ec19a1c6dbb606.

It turns out that updating the code to use BSplingTransform is not
trivial. Indeed, there is no direct replacement for the SetBulkTransform,
function.
Since updating the code to use BSplineTransform (instead of the deprecated
BSplineDeformableTransform) is not trivial (see 86c8966 where we reverted
our attempt), this commit introduces copy of BSplineDeformableTransform and
BSplineDeformableTransformInitializer specific to this project.

These new files are prefixed with "Niral" and uses the namespace "itk::niral::"
instead of "itk::".
This will allow to more easily understand while options are added or
removed in the future.
Testing for the value of DTIPrep_BUILD_SLICER_EXTENSION allows to
implement the same logic.
…ension

Now that "niral_utilities", "UnivariateEntropyMultiImageMetric" and "DTIPrep"
can all be built using a regular build of ITKv4 without requiring the option
ITKV3_COMPATIBILITY to be enabled, this commit updates the requirement
of DTIPrep Slicer extension so that the build trees provided by Slicer
can be reused.

Additionally, the build time of the Slicer extension will also be
reduced.
This commit fixes a regression introduced in 2ea5e5b (ENH: Update
SuperBuild process and package extension for SLICER) and ensures
niral tools are packaged.
…ype of its field

This commit fixes warnings like the following:

```
In file included from /tmp/DTIPrep/src/GMainWindow.h:6:0,
                 from /tmp/DTIPrep/src/main.cxx:11:
/tmp/DTIPrep/src/IntensityMotionCheckPanel.h:21:7: warning: ‘IntensityMotionCheckPanel’ declared with greater visibility than the type of its field ‘IntensityMotionCheckPanel::QCedDwiReader’ [-Wattributes]
 class IntensityMotionCheckPanel : public QDockWidget,
       ^
In file included from /tmp/DTIPrep/src/main.cxx:11:0:
/tmp/DTIPrep/src/GMainWindow.h:57:7: warning: ‘GMainWindow’ declared with greater visibility than the type of its field ‘GMainWindow::DwiReader’ [-Wattributes]
 class GMainWindow : public QMainWindow, private Ui_MainWindow
       ^
/tmp/DTIPrep/src/GMainWindow.h:57:7: warning: ‘GMainWindow’ declared with greater visibility than the type of its field ‘GMainWindow::QCedDwiReader’ [-Wattributes]
In file included from /tmp/DTIPrep/src/GMainWindow.h:6:0,
                 from /tmp/DTIPrep/src/GMainWindow.cxx:3:
/tmp/DTIPrep/src/IntensityMotionCheckPanel.h:21:7: warning: ‘IntensityMotionCheckPanel’ declared with greater visibility than the type of its field ‘IntensityMotionCheckPanel::QCedDwiReader’ [-Wattributes]
 class IntensityMotionCheckPanel : public QDockWidget,
       ^
```
@juanprietob juanprietob merged commit 5dd0a4d into NIRALUser:master Sep 6, 2017
@jcfr jcfr deleted the remove-itkv3compat-dependency-fix-warnings-and-errors-fix-extension-package branch September 6, 2017 19:55
@jcfr
Copy link
Contributor Author

jcfr commented Sep 6, 2017

Thanks for reviewing and integrating.

As a side note, now change have also been integrated in niral_utilities, it would be nice to update this code:

set( ${proj}_REPOSITORY ${git_protocol}://github.com/jcfr/niral_utilities.git )
set( ${proj}_GIT_TAG a8635a0a37d29536d3281180a9b39936307419f7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants