Skip to content

Commit

Permalink
COMP: Remove #if 0 clauses
Browse files Browse the repository at this point in the history
I also removed 3 header files whose entire contents
were inside #if 0, and weren't being included anywhere
  • Loading branch information
Kent Williams committed May 14, 2013
1 parent 632de69 commit 3f83aa7
Show file tree
Hide file tree
Showing 53 changed files with 367 additions and 2,257 deletions.
16 changes: 0 additions & 16 deletions BRAINSABC/brainseg/AtlasDefinition.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,6 @@ XMLcharhandler(void *data, const char *txt, int txtlen)
}
}
}
#if 0
const char *AtlasDefinition::tissueTypes[] =
{
"WM",
"GM",
"BGM",
"CSF",
"VB",
"NOTCSF",
"NOTGM",
"NOTVB",
"NOTWM",
"AIR",
0
};
#endif

AtlasDefinition::AtlasDefinition() :
m_LastWeight(0.0),
Expand Down
92 changes: 1 addition & 91 deletions BRAINSABC/brainseg/AtlasRegistrationMethod.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

// MI registration module
#include "AtlasRegistrationMethod.h"
#include "RegistrationParameters.h"

#include "vnl/vnl_math.h"

Expand Down Expand Up @@ -605,96 +604,7 @@ AtlasRegistrationMethod<TOutputPixel, TProbabilityPixel>
<< " " << m_AtlasToSubjectTransform->GetParameters() << std::endl );
}
}
// End generating the best initial transform for atlas T1 to subject T1
#if 0
// Update the registration with all the other non-primary images.
{
for( unsigned int atlasIter = 1; atlasIter < m_AtlasOriginalImageList.size(); atlasIter++ )
{
// Save code snippets for future integration 2012-10-18
{ // Set the fixed image
InternalImageType::Pointer currentWarpedIntraSubject = NULL;
// NOTE: This is to save memory, so just resample the images as needed
// to avoid keeping an extra copy of them
if( atlasReferenceImageIndex == 0 )
{ // First subject image does not need to be resampled
currentWarpedIntraSubject = m_IntraSubjectOriginalImageList[0];
}
else
{ // All other subject images must be resampled
typedef itk::ResampleImageFilter<InternalImageType, InternalImageType> ResampleType;
typedef ResampleType::Pointer ResamplePointer;

ResamplePointer resampler = ResampleType::New();
resampler->SetInput(m_IntraSubjectOriginalImageList[atlasReferenceImageIndex]);
resampler->SetTransform(m_IntraSubjectTransforms[atlasIter]);
resampler->SetOutputParametersFromImage(m_IntraSubjectOriginalImageList[0]);
resampler->SetDefaultPixelValue(0);
resampler->Update();
currentWarpedIntraSubject = resampler->GetOutput();
}
atlasToSubjectRegistrationHelper->SetFixedVolume(currentWarpedIntraSubject);
}
std::string preprocessMovingString("");
{ // Set the moving image
// TODO: Just turn histogram matching off at this point.
// histogram matching often help in the registration for difficult
// cases
// Need to find some way to quantify how much it helps/hurts.
// Changed so FLAIR doesn't get histogram matched to non-existing
// atlas
// const bool histogramMatch=true;//Setting histogram matching to true
const bool histogramMatch = false;
// const bool histogramMatch=(m_InputVolumeTypes[atlasIter]=="FLAIR")?false:true;
if( histogramMatch )
{
typedef itk::HistogramMatchingImageFilter<InternalImageType,
InternalImageType> HistogramMatchingFilterType;
HistogramMatchingFilterType::Pointer histogramfilter
= HistogramMatchingFilterType::New();

histogramfilter->SetInput( m_AtlasOriginalImageList[atlasIter] );
histogramfilter->SetReferenceImage( atlasToSubjectRegistrationHelper->GetFixedVolume() );

histogramfilter->SetNumberOfHistogramLevels( 128 );
histogramfilter->SetNumberOfMatchPoints( 2 );
histogramfilter->ThresholdAtMeanIntensityOn();
histogramfilter->Update();
InternalImageType::Pointer equalizedMovingImage = histogramfilter->GetOutput();
if( equalizedMovingImage->GetLargestPossibleRegion().GetSize() !=
m_AtlasOriginalImageList[atlasIter]->GetLargestPossibleRegion().GetSize() )
{
itkExceptionMacro(<< "Histogram equalized image has wrong size." );
}
preprocessMovingString = "histogram equalized ";
atlasToSubjectRegistrationHelper->SetMovingVolume(equalizedMovingImage);
if( this->m_DebugLevel > 7 )
{
typedef itk::ImageFileWriter<InternalImageType> ShortWriterType;
ShortWriterType::Pointer writer = ShortWriterType::New();
writer->UseCompressionOn();

std::string fn =
this->m_OutputDebugDir + std::string("AtlasPostHistogram_") + ".nii.gz";

writer->SetInput( equalizedMovingImage );
writer->SetFileName(fn.c_str() );
writer->Update();
muLogMacro( << __FILE__ << " " << __LINE__ << " " << std::endl );
itkExceptionMacro(<< "Histogram match");
}
}
else
{
atlasToSubjectRegistrationHelper->SetMovingVolume(m_AtlasOriginalImageList[atlasIter]);
}
}
// muLogMacro( << "Refining transform with information from atlas " << atlasIter << " of " <<
// m_AtlasOriginalImageList.size() << " to subject image " << atlasIter << "." << std::endl);
// Code for updateing and refining the registration for all non-zero index locations. Not implemented yet.
}
}
#endif
// End generating the best initial transform for atlas T1 to subject T1
{
muLogMacro(<< "Writing " << this->m_AtlasToSubjectTransformFileName << "." << std::endl);
WriteTransformToDisk(m_AtlasToSubjectTransform, this->m_AtlasToSubjectTransformFileName);
Expand Down
161 changes: 33 additions & 128 deletions BRAINSABC/brainseg/BRAINSABC.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -804,34 +804,6 @@ int main(int argc, char * *argv)
}
// Initialize with file read in
FloatImageType::Pointer typewiseEqualizedToFirstImage = imgreader->GetOutput();
#if 0 // This needs more testing.
// Now go looking to see if this image type has already been found,
// and equalize to the first image of this type if found.
for( unsigned int prevImageIndex = 0; prevImageIndex < i; prevImageIndex++ )
{
if( inputVolumeTypes[i] == inputVolumeTypes[prevImageIndex] )
// If it matches a previous found image type,
// then histogram equalize
{
muLogMacro( << "Equalizing image (" << i << ") to image (" << prevImageIndex << ")" << std::endl );
typedef itk::HistogramMatchingImageFilter<FloatImageType,
FloatImageType> HistogramMatchingFilterType;
HistogramMatchingFilterType::Pointer histogramfilter
= HistogramMatchingFilterType::New();

histogramfilter->SetInput( imgreader->GetOutput() );
histogramfilter->SetReferenceImage( intraSubjectNoiseRemovedImageList[prevImageIndex] );

histogramfilter->SetNumberOfHistogramLevels( 128 );
histogramfilter->SetNumberOfMatchPoints( 16 );
// histogramfilter->ThresholdAtMeanIntensityOn();
histogramfilter->Update();
// Overwrite if necessary.
typewiseEqualizedToFirstImage = histogramfilter->GetOutput();
break;
}
}
#endif

// Normalize Image Intensities:
muLogMacro( << "Standardizing Intensities: ...\n" );
Expand All @@ -842,47 +814,43 @@ int main(int argc, char * *argv)
1, 0.95 * MAX_IMAGE_OUTPUT_VALUE,
0, MAX_IMAGE_OUTPUT_VALUE);
muLogMacro( << "done.\n" );
#if 1
{
std::vector<unsigned int> unused_gridSize;
double localFilterTimeStep = filterTimeStep;
if( localFilterTimeStep <= 0 )
{
std::vector<unsigned int> unused_gridSize;
double localFilterTimeStep = filterTimeStep;
if( localFilterTimeStep <= 0 )
FloatImageType::SpacingType::ValueType minPixelSize =
vcl_numeric_limits<FloatImageType::SpacingType::ValueType>::max();
const FloatImageType::SpacingType & imageSpacing = intraSubjectRawImageList[i]->GetSpacing();
for( int is = 0; is < FloatImageType::ImageDimension; ++is )
{
FloatImageType::SpacingType::ValueType minPixelSize =
vcl_numeric_limits<FloatImageType::SpacingType::ValueType>::max();
const FloatImageType::SpacingType & imageSpacing = intraSubjectRawImageList[i]->GetSpacing();
for( int is = 0; is < FloatImageType::ImageDimension; ++is )
{
minPixelSize = vcl_min( minPixelSize, imageSpacing[is]);
}
localFilterTimeStep =
( (minPixelSize - vcl_numeric_limits<FloatImageType::SpacingType::ValueType>::epsilon() )
/ ( vcl_pow(2.0, FloatImageType::ImageDimension + 1 ) )
);
}
intraSubjectNoiseRemovedImageList[i] =
DenoiseFiltering<FloatImageType>(intraSubjectRawImageList[i], filterMethod, filterIteration,
localFilterTimeStep,
unused_gridSize);
if( debuglevel > 1 )
{
// DEBUG: This code is for debugging purposes only;
typedef itk::ImageFileWriter<FloatImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->UseCompressionOn();

std::stringstream template_index_stream("");
template_index_stream << i;
const std::string fn = outputDir + "/DENOISED_INDEX_" + template_index_stream.str() + ".nii.gz";
writer->SetInput(intraSubjectNoiseRemovedImageList[i]);
writer->SetFileName(fn.c_str() );
writer->Update();
muLogMacro( << "DEBUG: Wrote image " << fn << std::endl);
minPixelSize = vcl_min( minPixelSize, imageSpacing[is]);
}
localFilterTimeStep =
( (minPixelSize - vcl_numeric_limits<FloatImageType::SpacingType::ValueType>::epsilon() )
/ ( vcl_pow(2.0, FloatImageType::ImageDimension + 1 ) )
);
}
#else
intraSubjectNoiseRemovedImageList[i] = intraSubjectRawImageList[i];
#endif
intraSubjectNoiseRemovedImageList[i] =
DenoiseFiltering<FloatImageType>(intraSubjectRawImageList[i], filterMethod, filterIteration,
localFilterTimeStep,
unused_gridSize);
if( debuglevel > 1 )
{
// DEBUG: This code is for debugging purposes only;
typedef itk::ImageFileWriter<FloatImageType> WriterType;
WriterType::Pointer writer = WriterType::New();
writer->UseCompressionOn();

std::stringstream template_index_stream("");
template_index_stream << i;
const std::string fn = outputDir + "/DENOISED_INDEX_" + template_index_stream.str() + ".nii.gz";
writer->SetInput(intraSubjectNoiseRemovedImageList[i]);
writer->SetFileName(fn.c_str() );
writer->Update();
muLogMacro( << "DEBUG: Wrote image " << fn << std::endl);
}
}
intraSubjectTransformFileNames[i] = outputDir
+ GetStripedImageFileNameExtension(inputVolumes[i]) + std::string(
"_to_")
Expand Down Expand Up @@ -1278,56 +1246,6 @@ int main(int argc, char * *argv)
// Start the segmentation process.
for( unsigned int segmentationLevel = 0; segmentationLevel < 1; segmentationLevel++ )
{
#if 0
// Prior Names
// Prior Names : [ AIR GM BGM CSF NOTCSF NOTGM NOTVB NOTWM VB
// WM ]
// Prior weight scales : [ 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00
// 1.00 0.50 ]
// Prior Label Codes : [ 0 2 3 4 6 7 9 8 5
// 1 ]
std::map<unsigned int, std::vector<unsigned int> > ParentLabels;
// Air
ParentLabels[100].push_back(0);
// GM-BGM-NOTGM
ParentLabels[101].push_back(2);
ParentLabels[101].push_back(3);
ParentLabels[101].push_back(7);
// CSF-NOTCSF
ParentLabels[102].push_back(4);
ParentLabels[102].push_back(6);
// WM-NOTWM
ParentLabels[103].push_back(1);
ParentLabels[103].push_back(8);
// VB-NOTVB
ParentLabels[104].push_back(5);
ParentLabels[104].push_back(9);

std::map<unsigned int, std::string> ParentLabelNames;
for(
std::map<unsigned int, std::vector<unsigned int> >::const_iterator plIter = ParentLabels.begin();
plIter != ParentLabels.end(); plIter++ )
{
std::string combinedName = "";
bool firstpass = true;
for(
std::vector<unsigned int>::const_iterator vIter = plIter->second.begin();
vIter != plIter->second.end(); vIter++ )
{
if( firstpass )
{
firstpass = false;
}
else
{
combinedName += "-";
}
combinedName += PriorNames[*vIter];
}
ParentLabelNames[plIter->first] = combinedName;
}

#endif

SegFilterType::Pointer segfilter = SegFilterType::New();
// __MAX__PROBS
Expand Down Expand Up @@ -1396,19 +1314,6 @@ int main(int argc, char * *argv)
// TODO: Expose the transform type to the BRAINSABC command line
// segfilter->SetAtlasTransformType("SyN"); // atlasTransformType);

#if 0
// THIS ACTAULLY NEEDS TO BE USED FOR ONLY DOING THE FINAL ITERATION OF THE
// SEGMENTATION PROCESS AND SKIPPING MOST OF EMLoop
// If this "Post" transform is given, then jump over the looping, and
// warp priors,do estimates, and bias correct in one step.
{
ReadGenericTransform;

segfilter->SetTemplateGenericTransform();
// Turn off warping, and just use the input given from disk.
}
#endif

if( !atlasWarpingOff )
{
segfilter->UpdateTransformationOn();
Expand Down
56 changes: 0 additions & 56 deletions BRAINSABC/brainseg/BRAINSABCUtilities.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,38 +109,6 @@ DuplicateImageList(const std::vector<typename TInputImage::Pointer> & inputList)
return outputList;
}

#if 0
template <class ImageType>
void WinnerTakesAll(std::vector<typename ImageType::Pointer> & listOfImages)
{
itk::ImageRegionIteratorWithIndex<ImageType> it(listOfImages[0], listOfImages[0]->GetLargestPossibleRegion() );

while( !it.IsAtEnd() )
{
const typename ImageType::IndexType currIndex = it.GetIndex();
unsigned int currMaxIndex = 0;
typename ImageType::PixelType currMax = listOfImages[0]->GetPixel(currIndex);
typename ImageType::PixelType sum = currMax;
listOfImages[0]->SetPixel(currIndex, 0);
for( unsigned int im = 1; im < listOfImages.size(); im++ )
{
const typename ImageType::PixelType currValue = listOfImages[im]->GetPixel(currIndex);
sum += currValue;
if( currValue > currMax )
{
currMax = currValue;
currMaxIndex = im;
}
listOfImages[im]->SetPixel(currIndex, 0);
}
listOfImages[currMaxIndex]->SetPixel(currIndex, sum);
++it;
}

return;
}

#endif

template <class TProbabilityImage>
typename ByteImageType::Pointer ComputeForegroundProbMask(
Expand Down Expand Up @@ -188,30 +156,6 @@ typename ByteImageType::Pointer ComputeForegroundProbMask(
}
}
}
#if 0
{
// Pre-Dilate mask
typedef itk::BinaryBallStructuringElement<unsigned char, 3> StructElementType;
typedef
itk::BinaryDilateImageFilter<ByteImageType, ByteImageType,
StructElementType> DilateType;

StructElementType structel;
structel.SetRadius(1);
structel.CreateStructuringElement();

typename DilateType::Pointer dil = DilateType::New();
dil->SetDilateValue(50);
dil->SetKernel(structel);
dil->SetInput(currForegroundMask);

dil->Update();

ByteImagePointer dilmask = dil->GetOutput();
// a simple assignment is probably sufficient, test both ways?
currForegroundMask = CopyImage<ByteImageType>(dilmask);
}
#endif
return currForegroundMask;
}

Expand Down

0 comments on commit 3f83aa7

Please sign in to comment.