Giter VIP home page Giter VIP logo

itktexturefeatures's Introduction

ITKTextureFeatures

Build Status

Overview

This repository contains ITK filters to estimate texture feature maps from N-dimensional images.

For more information, see the Insight Journal article:

Vimort J., McCormick M., Budin F., Paniagua B.
Computing Textural Feature Maps for N-Dimensional images
McCormick M.
The Insight Journal. January-December. 2017.
https://hdl.handle.net/10380/3574
https://insight-journal.org/browse/publication/985

Installation

Python

Binary Python packages are available for macOS, Linux, and Windows. They can be installed with:

python -m pip install --upgrade pip
python -m pip install itk-texturefeatures

3D Slicer Extension

The module functionality is also available in the 3D Slicer desktop application. Install the BoneTextureExtension in the 3D Slicer extension manager. Additional documentation is available for the extension.

C++

Since ITK 4.13.0, this module is available in the ITK source tree as a Remote module. To enable it, set:

Module_TextureFeatures:BOOL=ON

in ITK's CMake build configuration.

License

The source code is distributed under the Apache 2.0 License. Please see LICENSE file for details.

Acknowledgements

This work was supported by the National Institute of Health (NIH) National Institute for Dental and Craniofacial Research (NIDCR) grant R21DE025306 (Textural Biomarkers of Arthritis for the Subchondral Bone in the Temporomandibular Joint) and NIDCR grant R01DE024450 (Quantification of 3D bony Changes in Temporomandibular Joint Osteoarthritis).

itktexturefeatures's People

Contributors

blowekamp avatar dzenanz avatar fbudin69500 avatar hjmjohnson avatar jbvimort avatar jhlegarreta avatar maekclena avatar mseng10 avatar pranjalsahu avatar tbirdso avatar thewtex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itktexturefeatures's Issues

Add as a remote module to ITK

@jbvimort I was about to bump the latest version of the ITKTextureFeatures when I realized that it has not been added as a remote to ITK yet.

I'm wondering whether it should be added as a remote to ITK, or whether you are waiting for #3 to be tackled.

May be Matt, Beatriz and/or François should may be inquired to be sure?

itkCoocurrenceTextureFeaturesImageFilter missing wrapped itk::ImageIOBase

Description

[4696/5195] Generating ../../Typedefs/itkCoocurrenceTextureFeaturesIma...eFilter.idx, ../../Typedefs/itkRunLengthTextureFeaturesImageFilter.id
itkCoocurrenceTextureFeaturesImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageIOBase
itkRunLengthTextureFeaturesImageFilter: warning(4): ITK type not wrapped, or currently not known: itk::ImageIOBase

Expected behavior

All classes wrapped.

Reproducibility

Wrapping failure.

Versions

2020-03-18 master branch.

Seg fault in texture calculation

Hi. I am getting seg fault when I try to execute the code bellow. Any idea why?

import itk
import numpy as np

img = np.random.randint(0,256,64**3).reshape(64,64,64).astype(np.uint8)

msk = 1 + np.zeros_like(img)

img = itk.GetImageFromArray(img)
msk = itk.GetImageFromArray(msk)

filtr = itk.CoocurrenceTextureFeaturesImageFilter.New(img)
filtr.SetMaskImage(msk)
filtr.SetHistogramMinimum(0)
filtr.SetHistogramMaximum(255)
filtr.SetNeighborhoodRadius([3,3,3])
filtr.SetNumberOfBinsPerAxis(4)
result = filtr.GetOutput()

I am running with

python 3.6
itk                      5.0rc2     
itk-core                 5.0rc2     
itk-filtering            5.0rc2     
itk-io                   5.0rc2     
itk-numerics             5.0rc2     
itk-registration         5.0rc2     
itk-segmentation         5.0rc2     
itk-texturefeatures      3.2.1      

Wrong output with signed pixel value

When using an image with signed pixel type as input, the output is wrong.
Minimal example:

#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkCoocurrenceTextureFeaturesImageFilter.h"

template<typename TImage>
void run()
{
	typename TImage::Pointer image = TImage::New();
	typename TImage::RegionType region;
	region.SetIndex({{0, 0}});
	region.SetSize({{5, 5}});
	image->SetRegions(region);
	image->Allocate(true);
	
	using TextureType = itk::Statistics::CoocurrenceTextureFeaturesImageFilter<TImage, itk::VectorImage<float, 2>>;
	typename TextureType::Pointer texture = TextureType::New();
	texture->SetInput(image);
	texture->Update();
	
	std::cout << texture->GetOutput()->GetPixel({{2, 2}}) << std::endl;;
}

int main()
{
	run<itk::Image<signed int, 2>>();
	run<itk::Image<unsigned int, 2>>();
}

Output:

[0, 0, 0, 0, 0, 0, 0, 0]
[1, 0, 0, 1, 0, 0, 0, -0.00392157]

The problem comes from the DigitizerFunctor, on line 80 the computing of the output range overflows.

Python wrapped version results in warnings with Python 3.9.4

Python 3.9.4

pip install itk -U
pip install itk-texturefeatures

ITK 5.2.0 python install + itk-texturefeatures 3.5.0 install.

help(itk.Image)

results in the following warning:

itkFixedArrayF8 not loaded from module TextureFeatures because of exception:
 module 'itk.TextureFeaturesPython' has no attribute 'itkFixedArrayF8'
itkFixedArrayF10 not loaded from module TextureFeatures  because of exception:
 module 'itk.TextureFeaturesPython' has no attribute 'itkFixedArrayF10'

Address memory access issues

The occasional test segfaults and inconsistency hopefully can be addressed by taking care of some memory access bugs identified by valgrind. These can be obtained by:

  1. Install valgrind
  2. Build ITKTextureFeatures with CMAKE_BUILD_TYPE set to RelWithDebInfo
  3. Run ctest -D ExperimentalMemCheck -R RunLengthTextureFeaturesImageFilterInstantiationTest -VV, etc. Or exclude -R to run all the tests.
  4. Address the issues identified in Testing/Temporary/MemoryChecker.*.log

Lower the default number of bins

256 makes computation very slow, and this is larger than the typical number of effective intensity bins encountered in many images. A better default is 8, 10, 16?

nan values in output

For some inputs, nan values can appear in the output. From the few tests I did, it seems to happen with floating values and isolated points in the mask.

Minimal example:

#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkCoocurrenceTextureFeaturesImageFilter.h"

typedef itk::Image<float, 2> ImageType;
typedef itk::Image<unsigned char, 2> MaskType;
typedef itk::VectorImage<float, 2> VectorType;
typedef itk::Statistics::CoocurrenceTextureFeaturesImageFilter<ImageType, VectorType> TextureType;

template<typename TImage>
typename TImage::Pointer createImage()
{
	typename TImage::Pointer image = TImage::New();
	typename TImage::RegionType region;
	region.SetIndex({{0, 0}});
	region.SetSize({{5, 5}});
	image->SetRegions(region);
	image->Allocate(true);
	return image;
}

int main()
{
	ImageType::Pointer image = createImage<ImageType>();
	MaskType::Pointer mask = createImage<MaskType>();
	mask->SetPixel({{2, 2}}, 1);
	TextureType::Pointer texture = TextureType::New();
	texture->SetInput(image);
	texture->SetMaskImage(mask);
	texture->Update();
	
	std::cout << texture->GetOutput()->GetPixel({{2, 2}}) << std::endl;
}

Output:

[nan, 0, nan, nan, nan, nan, nan, nan]

Interest in first order statistics?

Nice work here, I look forward to the insight journal article.

Just wanted to see if there was any interest in a filter which computed first order statistics (mean, min, max, variance, sigma, skewness, kurtosis, and entropy) over a sliding window of a scalar image. They seem very much inline with the subject of this repo.

I have an implementation here:
https://github.com/blowekamp/itkTextureAnalysis/blob/master/include/itkTextureMovingHistogramImageFilter.h
https://github.com/blowekamp/itkTextureAnalysis/blob/master/include/itkTextureHistogram.h

If you are interested an I make a pull request with these classes with tests and cleanup ( create? ) documentation for them.

ImportError: cannot import name 'itkHelpers' from 'itk.support' (unknown location)

Traceback (most recent call last):
  File "/home/user/a.py", line 27, in <module>
    filtr = itk.CoocurrenceTextureFeaturesImageFilter.New(im)
  File "/home/user/py_env/lib/python3.7/site-packages/itk/support/lazy.py", line 76, in __getattribute__
    base.itk_load_swig_module(module, namespace)
  File "/home/user/py_env/lib/python3.7/site-packages/itk/support/base.py", line 110, in itk_load_swig_module
    l_module = loader.load(swig_module_name)
  File "/home/user/py_env/lib/python3.7/site-packages/itk/support/base.py", line 259, in load
    l_spec.loader.exec_module(l_module)  # pytype: disable=attribute-error
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/user/py_env/lib/python3.7/site-packages/itk/support/../TextureFeaturesPython.py", line 74, in <module>
    from itk.itkCoocurrenceTextureFeaturesImageFilterPython import *
  File "/home/user/py_env/lib/python3.7/site-packages/itk/itkCoocurrenceTextureFeaturesImageFilterPython.py", line 3563, in <module>
    from itk.support import itkHelpers
ImportError: cannot import name 'itkHelpers' from 'itk.support' (unknown location)

Just updated itk package from pip to version 5.2 and I cannot run itk-texturefeatures anymore, here it's the Traceback for the example code found on this repository.

Searching a bit, I found this commit from ITK repo which deleted filter_args(object) from itk.support.helpers which also is referenced on itkCoocurrenceTextureFeaturesImageFilterPython.py as from itk.support import itkHelpers. So it was renamed from itkHelpers to helpers.

Also, accept_numpy_array_like_xarray() was changed to accept_array_like_xarray_torch()

helpers.py source file

Hope this information somehow help.

Review wrapping masked template parameter

With the merge of #41, the C++ interface has changed the default for the mask image type. Currently, they Wrapping still specifies the mask image type to be the same as the input images. Should the wrapping be changed?

Also consider wrapping for "VectorImage" as can simplify the usage, by not needing to specify the image vector size as part of the image type.

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.