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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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