Skip to content

Commit

Permalink
Merge pull request #1302 from BRAINSia/fix-joint-fusion-bugs-multi-mo…
Browse files Browse the repository at this point in the history
…dal-data

Fix joint fusion bugs multi modal data
  • Loading branch information
ntustison authored Feb 5, 2022
2 parents 54ba991 + 2d85646 commit b9a1b74
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
8 changes: 4 additions & 4 deletions ImageSegmentation/itkWeightedVotingFusionImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ class WeightedVotingFusionImageFilter final

/**
* Add an atlas (multi-modal image + segmentation)
* imageList is a vector of image pointers
* *segmentation is the pointer for the single segmentation corresponding to imageList
*/
void AddAtlas( InputImageList imageList, LabelImageType *segmentation = nullptr )
{
for( unsigned int i = 0; i < imageList.size(); i++ )
{
this->m_AtlasImages.push_back( imageList );
}
this->m_AtlasImages.push_back( imageList );

if( this->m_NumberOfAtlasModalities == 0 )
{
itkDebugMacro( "Setting the number of modalities to " << this->m_NumberOfAtlasModalities );
Expand Down
34 changes: 30 additions & 4 deletions ImageSegmentation/itkWeightedVotingFusionImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,17 @@ WeightedVotingFusionImageFilter<TInputImage, TOutputImage>
}
SizeValueType searchNeighborhoodSize = searchNeighborhoodOffsetList.size();

InputImagePixelVectorType normalizedTargetPatch =
this->VectorizeImageListPatch( this->m_TargetImage, currentCenterIndex, true );
// if Metric is MSQ, create both target patch and normalized target patch for use.
// target patch is for metric calculation, and normalized patch is for weight calculation.
// If metric is PC, only need to use normalizedTargetPatch

const InputImagePixelVectorType normalizedTargetPatch = this->VectorizeImageListPatch( this->m_TargetImage, currentCenterIndex, true );

InputImagePixelVectorType targetPatch;
if(this->m_SimilarityMetric == NonLocalPatchBasedImageFilterEnums::SimilarityMetric::MEAN_SQUARES)
{
targetPatch = this->VectorizeImageListPatch( this->m_TargetImage, currentCenterIndex, false );
}

absoluteAtlasPatchDifferences.fill( 0.0 );
originalAtlasPatchIntensities.fill( 0.0 );
Expand All @@ -512,8 +521,25 @@ WeightedVotingFusionImageFilter<TInputImage, TOutputImage>
continue;
}

RealType patchSimilarity = this->ComputeNeighborhoodPatchSimilarity(
this->m_AtlasImages[i], searchIndex, normalizedTargetPatch, useOnlyFirstAtlasImage );
const RealType patchSimilarity = [&] () -> RealType {
// use nonnormalized vector for MSQ
switch(this->m_SimilarityMetric)
{
case NonLocalPatchBasedImageFilterEnums::SimilarityMetric::MEAN_SQUARES):
// use non-normalized vectors for MSE
return this->ComputeNeighborhoodPatchSimilarity(
this->m_AtlasImages[i], searchIndex, targetPatch, useOnlyFirstAtlasImage);
break;
case NonLocalPatchBasedImageFilterEnums::SimilarityMetric::PEARSON_CORRELATION):
// use normalized vector for PC
return this->ComputeNeighborhoodPatchSimilarity(
this->m_AtlasImages[i], searchIndex, normalizedTargetPatch, useOnlyFirstAtlasImage );
break;
default:
itkGenericException("Invalid SimilarityMetric Chosen.");
}
return 0.0;
}

if( patchSimilarity < minimumPatchSimilarity )
{
Expand Down

0 comments on commit b9a1b74

Please sign in to comment.