# Asking question about GLCM per angle in radiomics

**URL:** <https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967>\
**Category:** Radiomics\
**Tags:** python\
**Created:** [November 5, 2025, 1:00pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967 "2025-11-05T13:00:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicolas\_hsieh](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nicolas_hsieh/32/81376_2.png) [@Nicolas\_hsieh](https://discourse.slicer.org/u/Nicolas_hsieh)\
**Post date:** [November 5, 2025, 1:00pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/1 "2025-11-05T13:00:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 25, 2026, 1:30pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/2 "2026-06-25T13:30:22Z")

</div>

Hello

I think your question might be related following URL;

> **[Raw 2D (GLCM, GLRLM, etc) matrix](https://groups.google.com/g/pyradiomics/c/s1tbbvPFgyk)**

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](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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 26, 2026, 2:24am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/3 "2026-06-26T02:24:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 26, 2026, 3:43am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/4 "2026-06-26T03:43:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 26, 2026, 7:31am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/5 "2026-06-26T07:31:31Z")

</div>

sorry

135–215° → 135–315°

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 27, 2026, 9:49pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/6 "2026-06-27T21:49:11Z")

</div>

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/normal_ordered_GLCM_sample.png>

[https://github.com/aujinen/pyradiomics\_edu/blob/master/workspace/check\_P\_glcm.ipynb](https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/check_P_glcm.ipynb)

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 28, 2026, 1:33am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/7 "2026-06-28T01:33:15Z")

</div>

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.

> **[GLCM-example.pdf](https://github.com/aujinen/Microsoft-Excel-sheets-with-Macro-VB/blob/master/GLCM-example.pdf)**

---

<div class="post-metadata">

**Author:** ![PaoloZaffino](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/paolozaffino/32/81052_2.png) [@PaoloZaffino](https://discourse.slicer.org/u/PaoloZaffino)\
**Post date:** [June 28, 2026, 6:16pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/8 "2026-06-28T18:16:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaoloZaffino](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/paolozaffino/32/81052_2.png) [@PaoloZaffino](https://discourse.slicer.org/u/PaoloZaffino)\
**Post date:** [June 28, 2026, 6:22pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/9 "2026-06-28T18:22:00Z")

</div>

@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](https://www.radiomicsjl.org/example.html)page.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 29, 2026, 12:09am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/10 "2026-06-29T00:09:37Z")

</div>

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.

> **[Cross Languages- Radiomics.jl](https://www.radiomicsjl.org/cross_languages.html)**

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.

---

<div class="post-metadata">

**Author:** ![PaoloZaffino](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/paolozaffino/32/81052_2.png) [@PaoloZaffino](https://discourse.slicer.org/u/PaoloZaffino)\
**Post date:** [June 29, 2026, 8:18am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/11 "2026-06-29T08:18:54Z")

</div>

@aujinen you can open an issue [here](https://github.com/pzaffino/Radiomics.jl/issues), we can discuss (and fix the bug) on github

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 29, 2026, 9:06am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/12 "2026-06-29T09:06:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [June 29, 2026, 10:32am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/13 "2026-06-29T10:32:00Z")

</div>

**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](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](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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [July 1, 2026, 1:41pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/14 "2026-07-01T13:41:40Z")

</div>

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

> <https://github.com/pzaffino/Radiomics.jl/issues/25>
>
> When attempting to call the following code—which runs without issues in Julia—fr…om Python via JuliaCall, passing the parameter \`slices\_2d=\[(3,1)\]\` causes it to fail. 
> I haven't explored all possible patterns, but they all result in failure. I haven't found a satisfactory answer even after checking GitHub Copliot.
> 
> \### Julia (without issues)
> \`\`\`
> using NIfTI
> using Radiomics
> using Printf
> 
> \# Load 2D test image and segmentation mask
> img = niread("forRadiomicsTest.nii.gz")
> mask = niread("forSegmentation.seg.nii.gz")
> 
> \# Extract voxel spacing from image header
> spacing = \[img.header.pixdim\[2\], img.header.pixdim\[3\], img.header.pixdim\[4\]\]
> 
> \# Extract radiomics features
> \# features = Radiomics.extract\_radiomic\_features(img.raw, mask.raw, spacing; slices\_2d=\[(3,1)\], features=\[:glcm\], bin\_width=1)
> 
> features = Radiomics.extract\_radiomic\_features(img.raw, mask.raw, spacing; slices\_2d=\[(3,1)\], features=\[:glcm\], bin\_width=1, get\_raw\_matrices=true)
> 
> mat = features\["raw\_glcm\_matrices"\]
> \# --\> get GLCM matrix per angle with normarization
> \`\`\`
> 
> \### Python (with issues)
> \`\`\`
> from juliacall import Main as jl
> jl.seval('import Pkg; Pkg.add("Radiomics")')
> 
> import SimpleITK as sitk
> import numpy as np
> 
> \# Load 2D images
> img\_sitk = sitk.ReadImage('./forRadiomicsTest.nii.gz')
> mask\_sitk = sitk.ReadImage('./forSegmentation.seg.nii.gz')
> 
> \# Convert to numpy arrays
> img = sitk.GetArrayFromImage(img\_sitk)
> mask = sitk.GetArrayFromImage(mask\_sitk)
> 
> \# Extract spacing information
> spacing = img\_sitk.GetSpacing()
> 
> radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=\[(3,1)\])
> \### --\> JuliaError
> \# JuliaError Traceback (most recent call last)
> \# Cell In\[7\], line 1
> \# ----\> 1 radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=\[(3,1)\])
> \#
> \# File ~\\.julia\\packages\\PythonCall\\5WGSP\\src\\JlWrap\\any.jl:263, in \_\_call\_\_(self, \*args, \*\*kwargs)
> \# 261 return ValueBase.\_\_dir\_\_(self) + self.\_jl\_callmethod($(pyjl\_methodnum(pyjlany\_dir)))
> \# 262 def \_\_call\_\_(self, \*args, \*\*kwargs):
> \# --\> 263 return self.\_jl\_callmethod($(pyjl\_methodnum(pyjlany\_call)), args, kwargs)
> \# 264 def \_\_bool\_\_(self):
> \# 265 return True
> \###
> 
> \### === The alternative code commented out below also halted with the same error.
> \# radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=\[3,1\])
> \# radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=(3,1))
> \# radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=((3,1)))
> \###
> 
> julia\_slices = jl.seval("\[(3,1)\]")
> radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=julia\_slices)
> 
> \### --\> JuliaError
> \# JuliaError Traceback (most recent call last)
> \# Cell In\[31\], \[line 2\](vscode-notebook-cell:?execution\_count=31&line=2)
> \# 1 # Extract radiomic features
> \# ----\> \[2\](vscode-notebook-cell:?execution\_count=31&line=2) radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d = julia\_slices)
> \#
> \# File ~\\.julia\\packages\\PythonCall\\5WGSP\\src\\JlWrap\\any.jl:263, in \_\_call\_\_(self, \*args, \*\*kwargs)
> \# 261 return ValueBase.\_\_dir\_\_(self) + self.\_jl\_callmethod($(pyjl\_methodnum(pyjlany\_dir)))
> \# 262 def \_\_call\_\_(self, \*args, \*\*kwargs):
> \# --\> \[263\](https://file+.vscode-resource.vscode-cdn.net/d%3A/pyradiomics/workspace/~/.julia/packages/PythonCall/5WGSP/src/JlWrap/any.jl:263) return self.\_jl\_callmethod($(pyjl\_methodnum(pyjlany\_call)), args, kwargs)
> \# 264 def \_\_bool\_\_(self):
> \# 265 return True
> \###
> 
> kwargs = jl.seval("slices\_2d = \[(3, 1)\]")
> radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, \*\*kwargs)
> \### --\> TypeError 
> \# TypeError Traceback (most recent call last)
> \# Cell In\[25\], line 1
> \# ----\> 1 radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, \*\*kwargs)
> \# 2 
> \# 3 # radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, slices\_2d=\[3,1\])
> \#
> \# TypeError: extract\_radiomic\_features argument after \*\* must be a mapping, not VectorValue
> \###
> 
> \### === The alternative code commented out below also halted with the same error.
> \# kwargs = jl.seval("slices\_2d = \[3, 1\]")
> \# kwargs = jl.seval("slices\_2d = (3, 1)")
> \# kwargs = jl.seval("slices\_2d = ((3, 1))")
> \### 
> 
> \####=== The alternative code commented out below also halted with the other error.
> radiomic\_features = jl.Radiomics.extract\_radiomic\_features(img, mask, spacing, kwargs)\`\`\`
> \###

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [July 4, 2026, 6:26pm UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/15 "2026-07-04T18:26:46Z")

</div>

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](https://github.com/aujinen/pyradiomics_edu/blob/master/workspace/radiomics_julia_2D.ipynb)

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [July 5, 2026, 11:10am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/16 "2026-07-05T11:10:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![aujinen](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aujinen/32/82516_2.png) [@aujinen](https://discourse.slicer.org/u/aujinen)\
**Post date:** [July 14, 2026, 1:06am UTC](https://discourse.slicer.org/t/asking-question-about-glcm-per-angle-in-radiomics/44967/17 "2026-07-14T01:06:23Z")

</div>

I had suspected that sensitivity to anisotropy might differ between [None] and [‘no\_weighting’], but it appears one cannot categorically state which offers higher sensitivity. While the relationship does not hold perfectly due to the asymmetry in where the normalization process is applied, the two generally follow the relationship defined by Jensen’s inequality for convex functions.

In any case, regarding anisotropy, it might be better to directly use the “GLCM” for each angle obtained during the [None] calculation process.
