Asking question about GLCM per angle in radiomics

Hello, I’m new to the Pyradiomics. Recently, I read the document of Pyradiomics. It seems that I can’t use Pyradiomics to calculate GLCM per angle(eg. energy per angles or entropy per angle). Is there any method to calculate GLCM per angle?

Hello

I think your question might be related following URL;

I checked output of featureClass.P_glcm with following sample python code (2D, 4 directions).

https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/check_P_glcm.ipynb

I came across this recently while looking into whether it could be used for educational purposes. Although this question was asked over six months ago and I am unsure if this will be helpful, I wanted to leave a comment.

The calculation results are provisional.
For now, I have confirmed that there is relevant data inside that can be extracted.
In this provisional version, the output is asymmetric, even though a symmetric GLCM is required.
I am currently preparing an Excel worksheet for instructional purposes covering four directions (0–180°, 45–225°, 90–270°, and 135–215°).
I believe further consideration is needed before presenting this to students.

After checking with GitHub Copilot, I added code to save internal parameters to a part of glcm.py and placed it in the workspace folder.

In the code within the workspace, you can call the modified glcm.py that uses from glcm import RadiomicsGLCM instead of from radiomics.glcm import RadiomicsGLCM.This might allow us to verify the angle information (depending on the level of problem identification in Copilot).

I just learned about the existence of the symmetrization parameter weightingNorm and set it, but I found that the angle information disappears when applied to check_GLCM_raw.ipynb.

Further verification seems necessary.

sorry

135–215° → 135–315°

I modified the local glcm.py file within the workspace to enable the extraction of angular information and unnormalized GLCMs. Although I had assumed the matrices were unsymmetric, verification of the results revealed that the order of the array elements differed from that of a standard GLCM. This was confirmed by comparing the output with results from simulations performed using Julia’s radiomics.jl and Excel.

https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/check_P_glcm.ipynb

I have updated the Excel file containing the explanation of the “weightingNorm” parameter for Japanese students.

A summarized version in English (PDF) has also been posted in the same location.

If we can provide support for Radiomics.jl, just let us know

@aujinen if you want, Radiomics.jl can also provide the raw texture matrices.
See the section “Extraction raw matrices from Texture Features” in the example page.

Thank you for your kindly suggestions and detail information.

I have already been able to obtain GLCM values ​​in angle units using radiomics.jl as follows.

`features = Radiomics.extract_radiomic_features(img.raw, mask.raw, spacing; slices_2d=[(3,1)], features=[:glcm], bin_width=1, get_raw_matrices=true)`

I am using this Julia function call result to verify whether it is being retrieved correctly from within PyRadiomics.

Since that is a Julia topic, I thought it was inappropriate for this forum, so I haven’t provided details, but for my student education, the language I mainly use is Python, and I am looking for a way to call radiomics.jl from Python.

Currently, it is not working correctly with parameter passing during the call. The problem is with the part “slices_2d=[(3,1)]”.

If it is acceptable to discuss it in this thread, I would appreciate any information you can provide.

@aujinen you can open an issue here, we can discuss (and fix the bug) on github

1 Like

As it had been a while since I last ran Julia—and because I only installed and verified pyradiomics.jl and its Python interface two days ago—I hadn’t realized there was a GitHub repository for it until now.
Thank you. If I am unable to resolve the issue after conducting a few more tests regarding parameter passing with Python, I will certainly make use of its issues.

Summary of a provisional method to obtain angle-specific GLCMs using PyRadiomics

Note: As verification was performed only on 2D samples, there is no guarantee of proper operation with large datasets, including 3D data.

Strategy: Add self. to the copy of internal variable you want to access to make it accessible from the outside, such as self.XXX = XXX.copy().

Issue: Memory consumption increases. Since this results in a version different from the original glcm.py, I believe it is necessary to fork the repository and manage it separately, as I have done.

To obtain individual GLCMs with angle information, it was found that you need to add code to the _calculateMatrix(self, voxelCoordinates=None) function in glcm.py to make four parameters accessible externally. Please refer to the following link for the internal parameters to be retrieved:

https://github.com/aujinen/pyradiomics_edu/blame/master/workspace/glcm.py

The procedure for obtaining GLCMs in angle units from the four parameters is as follows.
Please refer to the following link for details and the results of the verification experiment:

https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/check_P_glcm.ipynb

If the target is a normalized GLCM, skip step 2.

Step 1
Set ‘weightingNorm’ to None

Step 2
Multiply the sum of the obtained internal parameters sumP_glcm by P_glcm to return to the GLCM before normalization.

Step 3
By reordering the array elements using <matrix>.[:,:,:,::-1].transpose(0,3,2,1), the original symmetric GLCM with angles can be obtained.

The internal arrangement of the matrix elements differs from the standard GLCM pattern; the layout appears to have been modified to improve computation speed.

I just posted about the issues related “Using Radiomics.jl from other languages” on the radiomics.jl site.

Thanks to the assistance of Mr. Aldo Giuliani, the issue regarding parameter conversion when using Julia’s radiomics.jl from Python has been resolved.

I incorporated this information into materials I created for students in Japan.

https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/radiomics_julia_2D.ipynb

1 Like

I finally understand the specific difference between the weightingNorm parameter [None] and [‘no_weighting’].

I have revised this post. I previously posted under the mistaken impression that the rotational dependence of GLCM is controlled by the weightingNorm parameter.

I now understand that the difference between [None] and ['no_weighting'] for this parameter lies in the extent to which image anisotropy is preserved. [None] preserves anisotropy more strongly, whereas ['no_weighting'] preserves it to a lesser degree—meaning the data is more prone to relative averaging.