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

Fix joint fusion bugs multi modal data #1302

Merged

Conversation

hjmjohnson
Copy link
Collaborator

Two bugs were identified when using uncommon parameters for ants joint fusion.

For multiple modality images, the atlases were incorrectly
doubled.

For example, 3 atlases with T1 & T2 modalities should result in
a list of lists like

0: [A1-T1, A1-T2]
1: [A2-T1, A2-T2]
2: [A3-T1, A3-T2]

but instead resulted in

0: [A1-T1, A1-T2]
1: [A1-T1, A1-T2]
2: [A2-T1, A2-T2]
3: [A2-T1, A2-T2]
4: [A3-T1, A3-T2]
5: [A3-T1, A3-T2]

Only the first 3 elements are processed, so about 1/2
the atlases are not used.
Scaling the target, but not the atlases results in invalid
MSE minimized results when searching local regions.

TARGET[i] = [ 1, 1, 1, 1]
NORMALIZED_TARGET[i]=[ 0, 0, 0 ,0]

ATLAS[i]  = [ 1, 1, 1, 1]
ATLAS[i+1]= [ 0, 1, 1, 1]

MSE (NORMALIZED_TARGET[i], ATLAS[i])   = 4
MSE (NORMALIZED_TARGET[i], ATLAS[i+1]) = 3
@hjmjohnson hjmjohnson self-assigned this Feb 5, 2022
@ntustison
Copy link
Member

Thanks again, @hjmjohnson . This is great.

@ntustison ntustison merged commit b9a1b74 into ANTsX:master Feb 5, 2022
@ntustison
Copy link
Member

@hjmjohnson , I'm seeing the same thing on the failed Circle-CI build and on my local machine. Any suggestions?

(base) ntustison@Histograms ANTS-build % make antsJointFusion
[ 66%] Built target antsUtilities
Scanning dependencies of target l_antsJointFusion
[ 66%] Building CXX object Examples/CMakeFiles/l_antsJointFusion.dir/antsJointFusion.cxx.o
In file included from <built-in>:408:
<command line>:3:9: warning: 'vtkRenderingCore_AUTOINIT' macro redefined [-Wmacro-redefined]
#define vtkRenderingCore_AUTOINIT 3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)
        ^
<command line>:2:9: note: previous definition is here
#define vtkRenderingCore_AUTOINIT 2(vtkRenderingFreeType,vtkRenderingOpenGL2)
        ^
In file included from /Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:8:
In file included from /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:390:
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:528:80: error: expected ':' after 'case'
        case NonLocalPatchBasedImageFilterEnums::SimilarityMetric::MEAN_SQUARES):
                                                                               ^
                                                                               :
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:528:80: error: expected expression
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:533:87: error: expected ':' after 'case'
        case NonLocalPatchBasedImageFilterEnums::SimilarityMetric::PEARSON_CORRELATION):
                                                                                      ^
                                                                                      :
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:533:87: error: expected expression
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:539:11: error: use of undeclared identifier 'itkGenericException'
          itkGenericException("Invalid SimilarityMetric Chosen.");
          ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:542:10: error: expected ';' at end of declaration
        }
         ^
         ;
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:24: error: no viable conversion from '(lambda at /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:42)' to 'const itk::WeightedVotingFusionImageFilter::RealType' (aka 'const double')
        const RealType patchSimilarity = [&] () -> RealType {
                       ^                 ~~~~~~~~~~~~~~~~~~~~
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:409:11: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 2>, itk::Image<unsigned int, 2>>::ThreadedGenerateDataForWeightedAveraging' requested here
    this->ThreadedGenerateDataForWeightedAveraging( region, threadId );
          ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:316:3: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 2>, itk::Image<unsigned int, 2>>::ThreadedGenerateData' requested here
  WeightedVotingFusionImageFilter();
  ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:67:16: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 2>, itk::Image<unsigned int, 2>>::WeightedVotingFusionImageFilter' requested here
  itkNewMacro( Self );
               ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:142:71: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 2>, itk::Image<unsigned int, 2>>::New' requested here
  typename FusionFilterType::Pointer fusionFilter = FusionFilterType::New();
                                                                      ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:1013:14: note: in instantiation of function template specialization 'ants::antsJointFusion<2>' requested here
      return antsJointFusion<2>( parser );
             ^
In file included from /Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:8:
In file included from /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:390:
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:24: error: no viable conversion from '(lambda at /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:42)' to 'const itk::WeightedVotingFusionImageFilter::RealType' (aka 'const double')
        const RealType patchSimilarity = [&] () -> RealType {
                       ^                 ~~~~~~~~~~~~~~~~~~~~
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:409:11: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 3>, itk::Image<unsigned int, 3>>::ThreadedGenerateDataForWeightedAveraging' requested here
    this->ThreadedGenerateDataForWeightedAveraging( region, threadId );
          ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:316:3: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 3>, itk::Image<unsigned int, 3>>::ThreadedGenerateData' requested here
  WeightedVotingFusionImageFilter();
  ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:67:16: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 3>, itk::Image<unsigned int, 3>>::WeightedVotingFusionImageFilter' requested here
  itkNewMacro( Self );
               ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:142:71: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 3>, itk::Image<unsigned int, 3>>::New' requested here
  typename FusionFilterType::Pointer fusionFilter = FusionFilterType::New();
                                                                      ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:1018:14: note: in instantiation of function template specialization 'ants::antsJointFusion<3>' requested here
      return antsJointFusion<3>( parser );
             ^
In file included from /Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:8:
In file included from /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:390:
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:24: error: no viable conversion from '(lambda at /Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:524:42)' to 'const itk::WeightedVotingFusionImageFilter::RealType' (aka 'const double')
        const RealType patchSimilarity = [&] () -> RealType {
                       ^                 ~~~~~~~~~~~~~~~~~~~~
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx:409:11: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 4>, itk::Image<unsigned int, 4>>::ThreadedGenerateDataForWeightedAveraging' requested here
    this->ThreadedGenerateDataForWeightedAveraging( region, threadId );
          ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:316:3: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 4>, itk::Image<unsigned int, 4>>::ThreadedGenerateData' requested here
  WeightedVotingFusionImageFilter();
  ^
/Users/ntustison/Pkg/ANTs/ImageSegmentation/itkWeightedVotingFusionImageFilter.h:67:16: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 4>, itk::Image<unsigned int, 4>>::WeightedVotingFusionImageFilter' requested here
  itkNewMacro( Self );
               ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:142:71: note: in instantiation of member function 'itk::WeightedVotingFusionImageFilter<itk::Image<float, 4>, itk::Image<unsigned int, 4>>::New' requested here
  typename FusionFilterType::Pointer fusionFilter = FusionFilterType::New();
                                                                      ^
/Users/ntustison/Pkg/ANTs/Examples/antsJointFusion.cxx:1023:14: note: in instantiation of function template specialization 'ants::antsJointFusion<4>' requested here
      return antsJointFusion<4>( parser );
             ^
1 warning and 9 errors generated.
make[3]: *** [Examples/CMakeFiles/l_antsJointFusion.dir/antsJointFusion.cxx.o] Error 1
make[2]: *** [Examples/CMakeFiles/l_antsJointFusion.dir/all] Error 2
make[1]: *** [Examples/CMakeFiles/antsJointFusion.dir/rule] Error 2
make: *** [antsJointFusion] Error 2

@hjmjohnson
Copy link
Collaborator Author

@ntustison I'm looking right now. I think I may have compiled the wrong ant's directory with a different codebase for testing, and then pre-maturely pushed.

@hjmjohnson
Copy link
Collaborator Author

@ntustison I fixed the obvious syntax errors. I don't usually build with VTK, so those errors are going to take me a few minutes to build VTK and identify.

PR arriving shortly (at least for the non VTK mistakes).

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.

2 participants