[ITK] [ITK-users] Texture analysis - two basics questions
Yohann Tschudi
yxt227 at med.miami.edu
Tue Jan 12 18:18:12 EST 2016
Ok, I finally implemented everything and I got a "result".
It means I got an 3D image (.mha) for each features with some numbers
different from nan (I do not understand yet how that is possible).
Here is an example of outputs for this study:
_Energy0.mha
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Energy0.mha>
_Correlation0.mha
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Correlation0.mha>
However for another study, I got 0 or nan or out of frame (I am using
3Dslicer to vizualise .mha, it gives me directly the value for each pixel
pointed by the mouse).
Example2_Energy0.mha
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Energy0.mha>
Example2_Correlation0.mha
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Correlation0.mha>
I am a bit confused but I think this is coming from the construction of the
input/3d data matrix.
Let me explain what I am trying to do:
I have an input file containing all the information of the data (a cube
containing a prostate volume with T2 values (0 outside the prostate)):
-> the first line contains the size of the matrix width, height and depth
-> for each line, the value for each pixel
Example:
Example_DataMatrix.csv
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example_DataMatrix.csv>
74 60 17
0 0 0 0.0
0 0 1 0.0
0 0 2 0.0
...
11 42 3 0.0
11 42 4 290.0
11 42 5 265.0
11 42 6 269.0
...
73 59 14 0.0
73 59 15 0.0
73 59 16 0.0
This data matrix is then transformed in itk::Image<float, 3>
InternalImageType image (I think there is a problem here maybe):
/int Create3DImageFromMatrix(InternalImageType::Pointer &_image, string
_dataMatrixFile)
{
//Create image
InternalImageType::Pointer image = InternalImageType::New();
// Get file
std::cout << "Get data matrix file " << _dataMatrixFile << endl;
ifstream dataFile(_dataMatrixFile);
//Read file
string line;
int xSize = 0;
int ySize = 0;
int zSize = 0;
int iLine = 0;
while (getline(dataFile, line))
{
istringstream iss(line);
if (iLine == 0)
{
//First line size of matrix
iss >> xSize >> ySize >> zSize;
std::cout << "Data matrix size verification: " << xSize << "x" << ySize
<< "x" << zSize << endl;
//Initialize image
InternalImageType::RegionType region;
InternalImageType::IndexType start;
start[0] = 0;
start[1] = 0;
start[2] = 0;
InternalImageType::SizeType size;
size[0] = xSize;
size[1] = ySize;
size[2] = zSize;
region.SetSize(size);
region.SetIndex(start);
image->SetRegions(region);
image->Allocate();
++iLine;
}
else
{
//Fill image
int x, y, z;
double value;
if (!(iss >> x >> y >> z >> value))
{
return -1;
}
else
{
InternalImageType::IndexType pixelIndex;
pixelIndex[0] = x;
pixelIndex[1] = y;
pixelIndex[2] = z;
image->SetPixel(pixelIndex, value);
++iLine;
}
}
}
_image = image;
std::cout << "Image created from data matrix file" << endl;
return 0;
}/
Finally, the code to compute the features is the same (in 3D) than in the
example :
http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures
<http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures>
/ int index0 = inputImage->GetLargestPossibleRegion().GetSize(0);
int index1 = inputImage->GetLargestPossibleRegion().GetSize(1);
int index2 = inputImage->GetLargestPossibleRegion().GetSize(2);
//slide window over the entire image
for (unsigned x = 1; x < index0 - 1; x++)
{
pi.SetElement(0, x);
window.SetIndex(0, x - 1);
for (unsigned y = 1; y < index1 - 1; y++)
{
pi.SetElement(1, y);
window.SetIndex(1, y - 1);
for (unsigned z = 1; z < index2 - 1; z++)
{
pi.SetElement(2, z);
window.SetIndex(2, z - 1);
roi->SetRegionOfInterest(window);
roi->Update();
glcmGenerator->SetInput(roi->GetOutput());
glcmGenerator->Update();
featureCalc->SetInput(glcmGenerator->GetOutput());
featureCalc->Update();
outInertia->SetPixel(pi,featureCalc->GetFeature(Hist2FeaturesType::Inertia));
outCorrelation->SetPixel(pi,
featureCalc->GetFeature(Hist2FeaturesType::Correlation));
outEnergy->SetPixel(pi,
featureCalc->GetFeature(Hist2FeaturesType::Energy));
outEntropy->SetPixel(pi,
featureCalc->GetFeature(Hist2FeaturesType::Entropy));
}
}
//Print step
int total = index0 - 2;
string step = to_string(x) + " on " + to_string(total);
std::cout << step << endl;
}/
As I wrote upper, the output values for this last example are either 0 or
nan or out of frame.
I am pretty sure that for the first example, getting values different from
0 are lucky (I still have nan values in it though).
I am missing something and I am looking since hours without seeing what is
wrong. Hope this is obvious ...
Here is the c++ file I am using :
TextureFeatures.cxx
<http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/TextureFeatures.cxx>
Thank you for your help
--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-analysis-two-basics-questions-tp7588334p7588348.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list