SCIInstitute / Seg3D

Seg3D is a free volume segmentation and processing tool developed by the NIH Center for Integrative Biomedical Computing at the University of Utah Scientific Computing and Imaging (SCI) Institute.
108 stars 47 forks source link

ITK 5.2 upgrade #378

Closed allywarner closed 3 years ago

allywarner commented 3 years ago

Updating Seg3D to ITK 5.1.0 to fix bugs.

dzenanz commented 3 years ago

A WIP is in my fork: https://github.com/dzenanz/Seg3D/tree/itk5migration. I will continue working on this tomorrow. I have some unrelated link errors for boost, such as 13>LINK : fatal error LNK1104: cannot open file 'M:\Dev\Seg3D-vs17sb\Externals\Source\Boost_external\lib\libboost_atomic-mt-gyd.lib' [M:\Dev\Seg3D-vs17sb\Seg3D\Core\Action\Tests\Core_Action_Tests.vcxproj]. Is building in Debug mode supposed to work?

dzenanz commented 3 years ago

I am stuck at this possible bug in ITK. The boost link errors are gone in RelWithDebInfo build. The only other build error I have is related to HDF5:

M:\Dev\Seg3D-vs17sb\Externals\Install\ITK_external\include\ITK-5.1\itk_H5Cpp.h(27): fatal error C1083: Cannot open include file: 'itkhdf5/cpp/H5Cpp.h': No such file or directory (compiling source file M:\Dev\Seg3D\src\Application\LayerIO\Matlab73LayerImporter.cc) [M:\Dev\Seg3D-vs17sb\Seg3D\Application\LayerIO\Application_LayerIO.vcxproj]

Pointing to ITK's build directory instead of install might help with that. @allywarner do you get the same errors?

allywarner commented 3 years ago

@dzenanz Debug mode is supposed to work!I haven't seen that error before. Were you able to fix it?

The other build error in reference to HDF5 is the error I'm gettting trying to build with ITK5. We can also look at my or your build together if you like!

Leengit commented 3 years ago

Incorporating the changes from @dzenanz (who incorporated changes from @allywarner), I have a WIP at Leengit/Seg3D branch itk5migration. There I was able to address a number of build-stopping errors (using gcc-8 on Ubuntu 20.04):

  1. Missing typename directives in declarations.
  2. Confusion between long and long long
  3. Use of itkMutexLock instead of std::mutex.
  4. Failure to include <itkMacro.h>
  5. Use of ComposeRGBImageFilter instead of ComposeImageFilter
  6. Use of NULL instead of nullptr
  7. Use of vcl_sqrt instead of std::sqrt, etc.
  8. itk::MultiThreader --> itk::MultiThreaderBase
  9. Removal of inappropriate Seg3D:: explicit qualification

Outstanding is only the HDF5 error reported above. I believe that the include directory tree includes the path

Seg3D-build/Externals/Install/ITK_external/include/ITK-5.1/

... in a situation where it should be looking to

Seg3D-build/Externals/Source/ITK_external/Modules/ThirdParty/HDF5/src/

... but I haven't yet figured out how to fix that.

dzenanz commented 3 years ago

There are some more errors on Visual Studio. Log from current WIP:

1>------ Build started: Project: Application_LayerIO, Configuration: RelWithDebInfo x64 ------
2>------ Build started: Project: Application_Tools, Configuration: RelWithDebInfo x64 ------
3>------ Skipped Build: Project: NightlyMemoryCheck, Configuration: RelWithDebInfo x64 ------
3>Project not selected to build for this solution configuration 
4>------ Skipped Build: Project: RUN_TESTS, Configuration: RelWithDebInfo x64 ------
4>Project not selected to build for this solution configuration 
5>------ Skipped Build: Project: Experimental, Configuration: RelWithDebInfo x64 ------
5>Project not selected to build for this solution configuration 
6>------ Skipped Build: Project: Continuous, Configuration: RelWithDebInfo x64 ------
6>Project not selected to build for this solution configuration 
7>------ Skipped Build: Project: Nightly, Configuration: RelWithDebInfo x64 ------
7>Project not selected to build for this solution configuration 
1>Matlab73LayerImporter.cc
1>M:\Dev\Seg3D\src\Application\LayerIO\Matlab73LayerImporter.cc(32,10): fatal error C1083: Cannot open include file: 'itkhdf5/H5LTpublic.h': No such file or directory
2>ActionSpeedline.cc
1>Done building project "Application_LayerIO.vcxproj" -- FAILED.
8>------ Build started: Project: Application_LayerIO_Tests, Configuration: RelWithDebInfo x64 ------
8>LINK : fatal error LNK1104: cannot open file '..\..\RelWithDebInfo\Application_LayerIO.lib'
8>Done building project "Application_LayerIO_Tests.vcxproj" -- FAILED.
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(94,14): error C2664: 'itk::Index<2>::Index(itk::Index<2> &&)': cannot convert argument 1 from 'int' to 'const itk::Index<2> &'
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(97,1): message : Reason: cannot convert from 'int' to 'const itk::Index<2>'
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(97,1): message : No constructor could take the source type, or constructor overload resolution was ambiguous
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkIndex.h(490,1): message : see declaration of 'itk::Index<2>::Index'
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(94): message : while compiling class template member function 'itk::MinPriorityQueueElementWrapper<itk::Index<2>,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::RealType,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::ElementIdentifier>::MinPriorityQueueElementWrapper(void)'
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(272): message : see reference to function template instantiation 'itk::MinPriorityQueueElementWrapper<itk::Index<2>,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::RealType,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::ElementIdentifier>::MinPriorityQueueElementWrapper(void)' being compiled
2>M:\Dev\Seg3D-vs19sb\Externals\Install\ITK_external\include\ITK-5.2\itkPriorityQueueContainer.hxx(105): message : while compiling class template member function 'itk::MinPriorityQueueElementWrapper<itk::Index<2>,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::RealType,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::ElementIdentifier>::MinPriorityQueueElementWrapper(itk::Index<2>,float)'
2>M:\Dev\Seg3D\src\Core\ITKLiveWire\itkLiveWireImageFunction.hxx(218): message : see reference to function template instantiation 'itk::MinPriorityQueueElementWrapper<itk::Index<2>,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::RealType,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::ElementIdentifier>::MinPriorityQueueElementWrapper(itk::Index<2>,float)' being compiled
2>M:\Dev\Seg3D\src\Core\ITKLiveWire\itkLiveWireImageFunction.hxx(218): message : see reference to class template instantiation 'itk::MinPriorityQueueElementWrapper<itk::Index<2>,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::RealType,itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::ElementIdentifier>' being compiled
2>M:\Dev\Seg3D\src\Core\ITKLiveWire\itkLiveWireImageFunction.hxx(130): message : while compiling class template member function 'void itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::GeneratePathDirectionImage(void)'
2>M:\Dev\Seg3D\src\Core\ITKLiveWire\itkLiveWireImageFunction.h(168): message : see reference to function template instantiation 'void itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>::GeneratePathDirectionImage(void)' being compiled
2>M:\Dev\Seg3D\src\Application\Tools\Actions\ActionSpeedline.cc(195): message : see reference to class template instantiation 'itk::LiveWireImageFunction<TYPED_IMAGE_TYPE_2D>' being compiled
2>M:\Dev\Seg3D\src\Application\Tools\Actions\ActionSpeedline.cc(171): message : see reference to function template instantiation 'void Seg3D::ActionSpeedlineAlgo::typed_run_filter<signed char>(void)' being compiled
2>Done building project "Application_Tools.vcxproj" -- FAILED.
9>------ Build started: Project: CreateLargeVolume, Configuration: RelWithDebInfo x64 ------
10>------ Build started: Project: Seg3D2, Configuration: RelWithDebInfo x64 ------
9>LINK : fatal error LNK1104: cannot open file '..\Application\Tools\RelWithDebInfo\Application_Tools.lib'
9>Done building project "CreateLargeVolume.vcxproj" -- FAILED.
10>LINK : fatal error LNK1181: cannot open input file '..\Application\Tools\RelWithDebInfo\Application_Tools.lib'
10>Done building project "Seg3D2.vcxproj" -- FAILED.
11>------ Skipped Build: Project: PACKAGE, Configuration: RelWithDebInfo x64 ------
11>Project not selected to build for this solution configuration 
12>------ Skipped Build: Project: INSTALL, Configuration: RelWithDebInfo x64 ------
12>Project not selected to build for this solution configuration 
========== Build: 0 succeeded, 5 failed, 57 up-to-date, 7 skipped ==========
allywarner commented 3 years ago

@dzenanz It's common to have many errors when upgrading Seg3D to a new ITK version. The error I'm most concerned about at the moment is the HDF5 error.

Leengit commented 3 years ago

I have added commits to Leengit/Seg3D branch itk5migration to address more ITK upgrade issues. @dzenanz is making changes to ITK (via the enableH5HL branch) to address the H5HL problems.

Leengit commented 3 years ago

I would like to contribute the commits on my Leengit/Seg3D branch itk5migration. Given this pull request already in progress and several branches owned by different parties, I don'tk now how to do that. Please advise.

dzenanz commented 3 years ago

@Leengit When we get somebody's fork building, it is easy to have that person make a PR. For now, we can just cherry-pick each other's commits as we have done so far.

With my fork, I get past #include hdf5 error. Improvements come from changes done in enableH5HL branch in ITK. Here is my build log:

1>------ Build started: Project: Seg3D2, Configuration: RelWithDebInfo x64 ------
2>------ Skipped Build: Project: NightlyMemoryCheck, Configuration: RelWithDebInfo x64 ------
2>Project not selected to build for this solution configuration 
3>------ Skipped Build: Project: RUN_TESTS, Configuration: RelWithDebInfo x64 ------
3>Project not selected to build for this solution configuration 
4>------ Skipped Build: Project: Experimental, Configuration: RelWithDebInfo x64 ------
4>Project not selected to build for this solution configuration 
5>------ Skipped Build: Project: Continuous, Configuration: RelWithDebInfo x64 ------
5>Project not selected to build for this solution configuration 
6>------ Skipped Build: Project: Nightly, Configuration: RelWithDebInfo x64 ------
6>Project not selected to build for this solution configuration 
1>Application_Tools.lib(ActionSpeedline.obj) : error LNK2001: unresolved external symbol "public: static struct itk::Index<2> const itk::NumericTraits<struct itk::Index<2> >::Zero" (?Zero@?$NumericTraits@U?$Index@$01@itk@@@itk@@2U?$Index@$01@2@B)
1>Application_LayerIO.lib(Matlab73LayerImporter.obj) : error LNK2019: unresolved external symbol H5LTget_dataset_ndims referenced in function "public: bool __cdecl Seg3D::Matlab73LayerImporterPrivate::scan_mat_array(__int64,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?scan_mat_array@Matlab73LayerImporterPrivate@Seg3D@@QEAA_N_JPEBDAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Application_LayerIO.lib(Matlab73LayerImporter.obj) : error LNK2019: unresolved external symbol H5LTget_dataset_info referenced in function "public: bool __cdecl Seg3D::Matlab73LayerImporterPrivate::scan_mat_array(__int64,char const *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?scan_mat_array@Matlab73LayerImporterPrivate@Seg3D@@QEAA_N_JPEBDAEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>Application_LayerIO.lib(Matlab73LayerImporter.obj) : error LNK2019: unresolved external symbol H5LTget_attribute_string referenced in function "public: bool __cdecl Seg3D::Matlab73LayerImporterPrivate::scan_mat_object(__int64,enum H5O_type_t,class H5::Group &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &)" (?scan_mat_object@Matlab73LayerImporterPrivate@Seg3D@@QEAA_N_JW4H5O_type_t@@AEAVGroup@H5@@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>M:\Dev\Seg3D-vs19sb\Seg3D\RelWithDebInfo\Seg3D2.exe : fatal error LNK1120: 4 unresolved externals
1>Done building project "Seg3D2.vcxproj" -- FAILED.
7>------ Skipped Build: Project: PACKAGE, Configuration: RelWithDebInfo x64 ------
7>Project not selected to build for this solution configuration 
8>------ Skipped Build: Project: INSTALL, Configuration: RelWithDebInfo x64 ------
8>Project not selected to build for this solution configuration 
========== Build: 0 succeeded, 1 failed, 61 up-to-date, 7 skipped ==========
Leengit commented 3 years ago

@dzenanz, the error you are seeing means that my fix to use m_Element(NumericTraits<TElement>::ZeroValue()) instead of m_Element(0) in ITK/Modules/Core/Common/include/itkPriorityQueueContainer.hxx is not working for all configurations when TElement is itk::Index<2>.

dzenanz commented 3 years ago

My fork now build successfully. But speedline tool does not seem to work (it works in 2.2.1 I downloaded from the website). It looks like it was refactored since, but I cannot get it to work. Maybe I don't know how to use it? Or it was broken by fixes to priority queue in ITK?

allywarner commented 3 years ago

@dzenanz @jessdtate What happens when you try to use speedline?

Leengit commented 3 years ago

The fix to itk::Modules/Core/Common/include/itkPriorityQueueContainer.hxx (draft pull request https://github.com/InsightSoftwareConsortium/ITK/pull/2048) is intended to fix a problem uncovered when I build Seg3D. The fix works on my configuration, but if you are seeing problems then we've still got problems.

dzenanz commented 3 years ago

@Leengit it builds for me too.

@allywarner when I click "Fill", there is no segmentation appearing. Also when I place control points, the line does not appear.

allywarner commented 3 years ago

@dzenanz I'll build your fork and test it out.

allywarner commented 3 years ago

@dzenanz I've done some testing on OSX 10.14.6 and I was able to get control points, but not able to get a segmentation. I'm going to take a look into it this week!

dzenanz commented 3 years ago

Any updates @allywarner?

dzenanz commented 3 years ago

@allywarner, feedback?

allywarner commented 3 years ago

@allywarner, feedback?

@dzenanz, The ExtractImageFilter needed SetDirectionCollapseToStrategy() to be able to move forward! There was a lousy try catch in Seg3D that wasn't throwing any exception at all. So I've set that and so far it has the same behavior as the release version. For me, the release version of Speedline doesn't work on my machine (Windows and OSX 10.14.6). @jessdtate says that it works for him on OSX 10.12. Speedline is using Livewire segmentation and it claims that the anchor is outside of the region therefore it's not calculating any paths between the selected points.

allywarner commented 3 years ago

@dzenanz It does work! Wahoo! I do have some SQL errors though so I'm going to look through those.

allywarner commented 3 years ago

@dzenanz this PR should build and not have errors as far as I know. Will the H5HL branch be merged into master?