Giter Site home page Giter Site logo

Comments (12)

cookpa avatar cookpa commented on September 22, 2024 2

I'll work on it, and do some comparisons on the results

from ants.

ntustison avatar ntustison commented on September 22, 2024 1

Thanks @cookpa . I'm pretty sure that the only use that had was around the time the 2014 cortical thickness paper was written. As far as I'm concerned, we can get rid of it.

from ants.

cookpa avatar cookpa commented on September 22, 2024 1

OK I think we are good to go now, all uses of LabelGeometryImageFilter have been replaced.

from ants.

stnava avatar stnava commented on September 22, 2024

hmm - this would be a problem for me. @cookpa thickness = Volume / area .... so we compute area on the fly when we need to ... A is the surface area of one side of the sheet.

from ants.

cookpa avatar cookpa commented on September 22, 2024

Looks like this is a suggested replacement

https://itk.org/Doxygen/html/classitk_1_1LabelImageToShapeLabelMapFilter.html

from ants.

ntustison avatar ntustison commented on September 22, 2024

yes, thx @gdevenyi . @cookpa (or anyone else) do you want to work on replacement or would you like me to?

from ants.

gdevenyi avatar gdevenyi commented on September 22, 2024

I'm happy to test as I use LabelGeometryMeasures for some work.

from ants.

cookpa avatar cookpa commented on September 22, 2024

As well as LabelGeometryMeasures, this filter is used in

ImageSegmentation/antsAtroposSegmentationImageFilter.hxx
Examples/ImageMath_Templates.hxx
Examples/GetConnectedComponentsFeatureImages.cxx
Examples/CreateDTICohort.cxx

from ants.

cookpa avatar cookpa commented on September 22, 2024

LabelGeometryImageFilter is used in the undocumented "LabelThickness2" function in ImageMath. It appears to compute average thickness based on the ratio of the volume to perimeter, then replaces the input labels with the average thickness for each label.

@ntustison @stnava do we still need this?

template <unsigned int ImageDimension>
int
LabelThickness2(int argc, char * argv[])
{
typedef unsigned int LabelType;
typedef itk::Image<LabelType, ImageDimension> LabelImageType;
typedef float RealType;
typedef itk::Image<RealType, ImageDimension> RealImageType;
if (argc < 5)
{
// std::cout << " Not enough inputs " << std::endl;
return EXIT_FAILURE;
}
int argct = 2;
const std::string outname = std::string(argv[argct]);
argct += 2;
std::string fn = std::string(argv[argct++]);
typename LabelImageType::Pointer labelImage = nullptr;
ReadImage<LabelImageType>(labelImage, fn.c_str());
typename LabelImageType::SpacingType spacing = labelImage->GetSpacing();
float volumeElement = 1.0;
for (unsigned int i = 0; i < spacing.Size(); i++)
{
volumeElement *= static_cast<float>(spacing[i]);
}
typedef itk::LabelGeometryImageFilter<LabelImageType, RealImageType> GeometryFilterType;
typename GeometryFilterType::Pointer geometryFilter = GeometryFilterType::New();
geometryFilter->SetInput(labelImage);
geometryFilter->CalculatePixelIndicesOff();
geometryFilter->CalculateOrientedBoundingBoxOff();
geometryFilter->CalculateOrientedLabelRegionsOff();
geometryFilter->Update();
typedef itk::LabelPerimeterEstimationCalculator<LabelImageType> AreaFilterType;
typename AreaFilterType::Pointer areaFilter = AreaFilterType::New();
areaFilter->SetImage(labelImage);
areaFilter->SetFullyConnected(true);
areaFilter->Compute();
typename GeometryFilterType::LabelsType allLabels = geometryFilter->GetLabels();
typename GeometryFilterType::LabelsType::iterator allLabelsIt;
std::sort(allLabels.begin(), allLabels.end());
for (allLabelsIt = allLabels.begin(); allLabelsIt != allLabels.end(); allLabelsIt++)
{
if (*allLabelsIt == 0)
{
continue;
}
// RealType volume = geometryFilter->GetVolume( *allLabelsIt ) * volumeElement;
// RealType perimeter = areaFilter->GetPerimeter( *allLabelsIt );
// RealType thicknessPrior = volume / perimeter;
// std::cout << "Label " << *allLabelsIt << ": ";
// std::cout << "volume = " << volume << ", ";
// std::cout << "area = " << perimeter << ", ";
// std::cout << "thickness = " << thicknessPrior << std::endl;
}
typename RealImageType::Pointer thicknessPriorImage = RealImageType::New();
thicknessPriorImage->CopyInformation(labelImage);
thicknessPriorImage->SetRegions(labelImage->GetLargestPossibleRegion());
thicknessPriorImage->AllocateInitialized();
itk::ImageRegionIteratorWithIndex<LabelImageType> It(labelImage, labelImage->GetLargestPossibleRegion());
for (It.GoToBegin(); !It.IsAtEnd(); ++It)
{
LabelType label = It.Get();
if (label == 0)
{
continue;
}
RealType volume = geometryFilter->GetVolume(label) * volumeElement;
RealType perimeter = areaFilter->GetPerimeter(label);
RealType thicknessPrior = volume / perimeter;
thicknessPriorImage->SetPixel(It.GetIndex(), thicknessPrior);
}
ANTs::WriteImage<RealImageType>(thicknessPriorImage, outname.c_str());
return EXIT_SUCCESS;
}

from ants.

cookpa avatar cookpa commented on September 22, 2024

It seems that the pseudo-thickness image from ImageMath LabelThickness2 should be provided by GetConnectedComponentsFeatureImages - only there's a bug in the latter and it outputs area / volume, not volume / area.

from ants.

cookpa avatar cookpa commented on September 22, 2024

I talk about the changes a bit more here

InsightSoftwareConsortium/ITK#4624 (comment)

from ants.

ntustison avatar ntustison commented on September 22, 2024

Awesome. Thanks @cookpa.

from ants.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.