<div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">​Hi Yohann,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">line 56 in your TextureFeature.cxx:</div><div class="gmail_default" style="font-size:small"><font face="monospace, monospace">glcmGenerator->SetPixelValueMinMax(0, 255); //for input UCHAR pixel type</font></div><div class="gmail_default" style=""><span style="font-size:small;font-family:verdana,sans-serif">could be the culprit.​ The input files in <a href="http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures">my example</a> were uchar, and 0-255 range was OK. For general processing, you should use <a href="http://www.itk.org/Doxygen/html/classitk_1_1MinimumMaximumImageCalculator.html">minMax finder</a> and pass those 2 values to </span><font face="monospace, monospace" style="font-size:small">calcTextureFeatureImage</font><font face="verdana, sans-serif" style="font-size:small"> function. Your </font><font face="verdana, sans-serif"><i>Example_DataMatrix.csv</i> contained values over 255 (300+), but not a lot of them. The other image might have higher maximum values or negative minimum values, which would cause more anomalies such as NaNs.</font></div><div class="gmail_default" style=""><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style=""><font face="verdana, sans-serif">As for conversion of DICOM to MHA or NRRD, you can use Slicer for that. Just import it via DICOM module, and then save them with .mha or .nrrd extension. Then you can read them easily via </font><font face="monospace, monospace">itk::ImageFileReader</font><font face="verdana, sans-serif">.</font></div><div class="gmail_default" style=""><font face="verdana, sans-serif"><br></font></div><div class="gmail_default" style=""><font face="verdana, sans-serif">HTH,</font></div><div class="gmail_default" style=""><font face="verdana, sans-serif">Dženan</font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 12, 2016 at 6:18 PM, Yohann Tschudi <span dir="ltr"><<a href="mailto:yxt227@med.miami.edu" target="_blank">yxt227@med.miami.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Ok, I finally implemented everything and I got a "result".<br>
It means I got an 3D image (.mha) for each features with some numbers<br>
different from nan (I do not understand yet how that is possible).<br>
Here is an example of outputs for this study:<br>
_Energy0.mha<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Energy0.mha" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Energy0.mha</a>><br>
_Correlation0.mha<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Correlation0.mha" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/_Correlation0.mha</a>><br>
<br>
However for another study, I got 0 or nan or out of frame (I am using<br>
3Dslicer to vizualise .mha, it gives me directly the value for each pixel<br>
pointed by the mouse).<br>
Example2_Energy0.mha<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Energy0.mha" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Energy0.mha</a>><br>
Example2_Correlation0.mha<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Correlation0.mha" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example2_Correlation0.mha</a>><br>
<br>
I am a bit confused but I think this is coming from the construction of the<br>
input/3d data matrix.<br>
<br>
Let me explain what I am trying to do:<br>
I have an input file containing all the information of the data (a cube<br>
containing a prostate volume with T2 values (0 outside the prostate)):<br>
  -> the first line contains the size of the matrix width, height and depth<br>
  -> for each line, the value for each pixel<br>
Example:<br>
Example_DataMatrix.csv<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example_DataMatrix.csv" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/Example_DataMatrix.csv</a>><br>
74 60 17<br>
0 0 0 0.0<br>
0 0 1 0.0<br>
0 0 2 0.0<br>
...<br>
11 42 3 0.0<br>
11 42 4 290.0<br>
11 42 5 265.0<br>
11 42 6 269.0<br>
...<br>
73 59 14 0.0<br>
73 59 15 0.0<br>
73 59 16 0.0<br>
<br>
This data matrix is then transformed in itk::Image<float, 3><br>
InternalImageType image (I think there is a problem here maybe):<br>
/int Create3DImageFromMatrix(InternalImageType::Pointer &_image, string<br>
_dataMatrixFile)<br>
{<br>
        //Create image<br>
        InternalImageType::Pointer image = InternalImageType::New();<br>
<br>
        // Get file<br>
        std::cout << "Get data matrix file " << _dataMatrixFile << endl;<br>
        ifstream dataFile(_dataMatrixFile);<br>
<br>
        //Read file<br>
        string line;<br>
        int xSize = 0;<br>
        int ySize = 0;<br>
        int zSize = 0;<br>
        int iLine = 0;<br>
        while (getline(dataFile, line))<br>
        {<br>
                istringstream iss(line);<br>
                if (iLine == 0)<br>
                {<br>
                        //First line size of matrix<br>
                        iss >> xSize >> ySize >> zSize;<br>
                        std::cout << "Data matrix size verification: " << xSize << "x" << ySize<br>
<< "x" << zSize << endl;<br>
<br>
                        //Initialize image<br>
                        InternalImageType::RegionType region;<br>
                        InternalImageType::IndexType start;<br>
                        start[0] = 0;<br>
                        start[1] = 0;<br>
                        start[2] = 0;<br>
                        InternalImageType::SizeType size;<br>
                        size[0] = xSize;<br>
                        size[1] = ySize;<br>
                        size[2] = zSize;<br>
                        region.SetSize(size);<br>
                        region.SetIndex(start);<br>
                        image->SetRegions(region);<br>
                        image->Allocate();<br>
<br>
                        ++iLine;<br>
                }<br>
                else<br>
                {<br>
                        //Fill image<br>
                        int x, y, z;<br>
                        double value;<br>
                        if (!(iss >> x >> y >> z >> value))<br>
                        {<br>
                                return -1;<br>
                        }<br>
                        else<br>
                        {<br>
                                InternalImageType::IndexType pixelIndex;<br>
                                pixelIndex[0] = x;<br>
                                pixelIndex[1] = y;<br>
                                pixelIndex[2] = z;<br>
                                image->SetPixel(pixelIndex, value);<br>
                                ++iLine;<br>
                        }<br>
                }<br>
        }<br>
<br>
        _image = image;<br>
        std::cout << "Image created from data matrix file" << endl;<br>
        return 0;<br>
}/<br>
<br>
Finally, the code to compute the features is the same (in 3D) than in the<br>
example :<br>
<a href="http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures" rel="noreferrer" target="_blank">http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures</a><br>
<<a href="http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures" rel="noreferrer" target="_blank">http://itk.org/Wiki/ITK/Examples/Statistics/TextureFeatures</a>><br>
/   int index0 = inputImage->GetLargestPossibleRegion().GetSize(0);<br>
        int index1 = inputImage->GetLargestPossibleRegion().GetSize(1);<br>
        int index2 = inputImage->GetLargestPossibleRegion().GetSize(2);<br>
<br>
        //slide window over the entire image<br>
        for (unsigned x = 1; x < index0 - 1; x++)<br>
        {<br>
                pi.SetElement(0, x);<br>
                window.SetIndex(0, x - 1);<br>
                for (unsigned y = 1; y < index1 - 1; y++)<br>
                {<br>
                        pi.SetElement(1, y);<br>
                        window.SetIndex(1, y - 1);<br>
                        for (unsigned z = 1; z < index2 - 1; z++)<br>
                        {<br>
                                pi.SetElement(2, z);<br>
                                window.SetIndex(2, z - 1);<br>
                                roi->SetRegionOfInterest(window);<br>
                                roi->Update();<br>
                                glcmGenerator->SetInput(roi->GetOutput());<br>
                                glcmGenerator->Update();<br>
                                featureCalc->SetInput(glcmGenerator->GetOutput());<br>
                                featureCalc->Update();<br>
<br>
outInertia->SetPixel(pi,featureCalc->GetFeature(Hist2FeaturesType::Inertia));<br>
                                outCorrelation->SetPixel(pi,<br>
featureCalc->GetFeature(Hist2FeaturesType::Correlation));<br>
                                outEnergy->SetPixel(pi,<br>
featureCalc->GetFeature(Hist2FeaturesType::Energy));<br>
                                outEntropy->SetPixel(pi,<br>
featureCalc->GetFeature(Hist2FeaturesType::Entropy));<br>
                        }<br>
                }<br>
<br>
                //Print step<br>
                int total = index0 - 2;<br>
                string step = to_string(x) + " on " + to_string(total);<br>
                std::cout << step << endl;<br>
        }/<br>
<br>
As I wrote upper, the output values for this last example are either 0 or<br>
nan or out of frame.<br>
I am pretty sure that for the  first example, getting values different from<br>
0 are lucky (I still have nan values in it though).<br>
I am missing something and I am looking since hours without seeing what is<br>
wrong. Hope this is obvious ...<br>
<br>
Here is the c++ file I am using :<br>
TextureFeatures.cxx<br>
<<a href="http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/TextureFeatures.cxx" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/file/n7588348/TextureFeatures.cxx</a>><br>
<br>
Thank you for your help<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-analysis-two-basics-questions-tp7588334p7588348.html" rel="noreferrer" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/ITK-users-Texture-analysis-two-basics-questions-tp7588334p7588348.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the ITK Insight Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/insight-users</a><br>
</div></div></blockquote></div><br></div>