Giter Site home page Giter Site logo

Comments (10)

neduchal avatar neduchal commented on June 25, 2024

Hi Kai,
try to install it to python3 using:
sudo python3 setup.py install

It should work. If you get some error feel free to report it here.

from lbplibrary.

ejlai avatar ejlai commented on June 25, 2024

Um...it seems to be something wrong with the directory:

(base) kai@kai-VirtualBox:~/masterthesis/lbpLibrary/build/lbpLibrary$ sudo python3 setup.py install
running install
running build
running build_py
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/lbp2d.py (for module lbp2d) not found
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/lbp3d.py (for module lbp3d) not found
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/extend.py (for module extend) not found
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/lbp2d.py (for module lbp2d) not found
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/lbp3d.py (for module lbp3d) not found
file /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/extend.py (for module extend) not found
running install_lib
running install_egg_info
Removing /usr/local/lib/python3.6/dist-packages/lbpLibrary-0.0.0.egg-info
Writing /usr/local/lib/python3.6/dist-packages/lbpLibrary-0.0.0.egg-info

from lbplibrary.

neduchal avatar neduchal commented on June 25, 2024

It looks like python files were not generated by cmake from its templates. What was an output of the cmake and make commands, can you recompile it and put it here?

Moreover, try to look to the folder /home/kai/masterthesis/lbpLibrary/build/lbpLibrary/LbpLibrary/python/ is there anything or is it empty?

from lbplibrary.

ejlai avatar ejlai commented on June 25, 2024

Right the installation seems easy. Thanks! Do you have any resources or paper that talks this library? I have 3D volume and mask images from LIDC-IDRI that I would like to test them with your library.

:~/lbpLibrary/tests/python$ python3 test3d.py

TEST Load LbpLibrary3D 

test3d.py:23: DeprecationWarning: Please use assertTrue instead.
  self.assert_(libLbp is not None)
.
TEST 3D LBP

/usr/lib/python3.6/unittest/case.py:605: ResourceWarning: unclosed file <_io.TextIOWrapper name='../../masks/mask3D_8_4.json' mode='r' encoding='UTF-8'>
  testMethod()
.
----------------------------------------------------------------------
Ran 2 tests in 0.019s

OK

from lbplibrary.

neduchal avatar neduchal commented on June 25, 2024

Unfortunately, it was my project 8 years ago (when i was bachelor student) and I don't have any English materials. But in principle if you want to use 3d part of the library you should follow the following code:

import json
from lbp import *
mask = {}
data = loadData 
f = open('path_to_mask_file', 'r')
mask = json.load()["mask"]
f.close()
libLbp = lbp3d.load()
lbp3d.coordsToPoints(mask, width, height) % width and height are sizes of the slice in the 3d data
res = lbp3d.compute(libLbp, data, mask)

Mask is used to define size and number of points which will be used in the LBP algorithm. coordsToPoints transforms mask coordinates into data coordinates . For example we have a point [1,1,2] (lets assume [height, width, slice]) . So the point for this coordinate is width * point[0] + point[1] * height * width * point[2] -- it is more complicated because it creates 8 points from one coordinate in order to compute their mean value during computation of LBP vector.
LBP code is then computed using method lbp3d.compute.

There are four pre-created mask files in the repository but you can create different masks using octave utilities -- maskGenerator.m script. In the mask you can specify the size of your data, so you can skip coordsToPoints function -- this function is useful when you have data of different sizes because in the file there are both the coords -- geometry of the mask -- and points with respect to some size of the data.

I hope it is clear. If you have some question, feel free to put it here and I'll do my best to answer you.

from lbplibrary.

ejlai avatar ejlai commented on June 25, 2024

Ok, thanks for the tips! I will try to see if I can test your model with this type of data, which is similar to that from this site https://www.fmrib.ox.ac.uk/primers/intro_primer/ExBox14/IntroBox14.html
The data is a file like this T1_brain.nii.gz and the mask is like this: T1_brain_mask.nii.gz
In your example, I can plug the mask file in. How do the data get plugged in? Thanks for your help!

from lbplibrary.

neduchal avatar neduchal commented on June 25, 2024

Hi, sorry for delay I was on vacation last week.

I'm not sure if your mask is the same thing as the mask in the library. The mask here is supposed to set the geometry of the LBP code computation. For example LBP1x8 in the 2D version is 8 points in the distance 1.

Can you describe your task in more detail?

from lbplibrary.

ejlai avatar ejlai commented on June 25, 2024

No problem. The mask is for lung CT scan segmentation, to extract region of interest.

I have this function below to read the data from the image or mask to 3D numpy.ndarray.

def readNifty(filePath):
    image = sitk.ReadImage(filePath)
    print("Reading Nifty format from {}".format(filePath))
    print("Image size: {}".format(image.GetSize()))
    #metadata = Metadata(image.GetOrigin(), image.GetSpacing(), image.GetDirection())

    # Converting from SimpleITK image to Numpy array. But also is changed the coordinate systems
    # from the image which use (x,y,z) to the array using (z,y,x).
    volume_zyx = sitk.GetArrayFromImage(image)
    volume_xyz = np.transpose(volume_zyx, (2, 1, 0)) #back to the initial xyz coordinate system
    print("Volume shape: {}".format(volume_xyz.shape))
    print("Minimum value: {}".format(np.min(volume_xyz)))
    print("Maximum value: {}".format(np.max(volume_xyz)))
    return volume_xyz     # return two items.

Execute the above function, niiMask=readNifty('LIDC-IDRI-0124_GT1_2_Mask.nii.gz') . The mask is like this:

In[12]: niiMask
Out[12]: 
array([[[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]],

...

       [[0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0],
        [0, 0, 0]]], dtype=int32)

> type(niiMask)
> Out[13]: numpy.ndarray
> 
> niiMask.size
> Out[14]: 360
> 
> niiMask.shape
> Out[15]: (10, 12, 3)

The data (region of interest) are similar as it was extracted with the mask. So I would like to produce 3D LBP with the 3D numpy.ndarray (float or int32) data and/or the mask. Thank you very much!

For about info about this type of data set, there is a page about it: https://www.ncbi.nlm.nih.gov/pubmed/21452728

from lbplibrary.

neduchal avatar neduchal commented on June 25, 2024

Am I right that you want to compute LBP codes only on the voxels inside your mask?

In general you need to write a loop that will compute LBP vector for a part of the data. The result will be a list of LBP vectors.

import json
from lbp import *
mask = {}
data = loadData 
slices, rows, columns = data.shape
f = open('path_to_mask_file', 'r') # this is LBP geometry mask
mask = json.load()["mask"]
f.close()
libLbp = lbp3d.load()
lbp3d.coordsToPoints(mask, columns, rows) 
lbp_vec = []
for i in range(0,slices, step_slices):
    for j in range(0,rows, step_rows):
        for k in range(0,columns, step_columns):
            is_in = is_in_mask(i,j,k) # your method that return boolean value based on the comparison with mask from your data
            if is_in:
                lbp_vec.append(lbp3d.compute(libLbp, data, mask))

I hope that the code is clear. In lbp_vec you will find the list of LBP vectors.

from lbplibrary.

ejlai avatar ejlai commented on June 25, 2024

Thank you so much! I think when using the PyRadiomics, I would need to feed it with the mask and the segmented data (ROI). For the 3D LBP, perhaps I can obtain the LBP value without the mask. I will start another topic if I need further help. Thanks again!

from lbplibrary.

Related Issues (5)

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.