# How to get HU values at each fiducial points

**URL:** <https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378>\
**Category:** Support\
**Created:** [November 2, 2020, 10:57am UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378 "2020-11-02T10:57:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MasatoshiOBA](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MasatoshiOBA](https://discourse.slicer.org/u/MasatoshiOBA)\
**Post date:** [November 2, 2020, 10:57am UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/1 "2020-11-02T10:57:51Z")

</div>

Operating system: windows 10  
Slicer version: 4.11.20200930

How can I get the HU (CT) value at each fiducial placed on a model surface?  
I could convert vertices of an STL model to a group of fiducials as shown in the attached image.  
Then I would like to add another column next to the RAS coordinate table of the fiducial group.

Thank you for your assistance.

 ![example1](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/b/fbfa248cbf2813c35a4c01c3ffab2791c2625734.jpeg)

Expected behavior:

Actual behavior:

---

<div class="post-metadata">

**Author:** ![MasatoshiOBA](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MasatoshiOBA](https://discourse.slicer.org/u/MasatoshiOBA)\
**Post date:** [November 2, 2020, 12:52pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/2 "2020-11-02T12:52:52Z")

</div>

I would like to know how I can get HU values at multiple fiducial points in the same group.  
Ultimately, I’d like to get the HU values of the pixels corresponding to the vertices of the STL model placed in the CT volume data in a tabular format.

I was able to convert each vertex of the STL model to fiducial, as shown in the attached figure.

For these fiducial, is it possible to get the HU value and coordinate values of the pixels in which each of them is located in a table format?

I appriciate all supports from comunity members.

[example|690x388](https://discourse.slicer.org/uploads/short-url/d4qVz1cWWlDjsyrf97wrxWjWuoB.jpeg)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 2, 2020, 7:27pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/3 "2020-11-02T19:27:45Z")

</div>

You can sample a CT volume with at each point of a mesh using “Probe volume with model” module, and get the point coordinates and density values as numpy arrays by typing these into the Python console:

```auto
modelNode = getNode('Output Model')
coords = slicer.util.arrayFromModelPoints(modelNode)
densities = slicer.util.arrayFromModelPointData(modelNode, 'NRRDImage')

```

If you need the CT density values for FEM analysis then an STL file will not be sufficient, as it is a surface mesh, so it will not contain density information in the bone. You can generate a volumetric mesh from a segmentation using [SegmentMesher extension](https://github.com/lassoan/SlicerSegmentMesher#segment-mesher-extension).

---

<div class="post-metadata">

**Author:** ![MasatoshiOBA](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MasatoshiOBA](https://discourse.slicer.org/u/MasatoshiOBA)\
**Post date:** [November 3, 2020, 7:41am UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/4 "2020-11-03T07:41:30Z")

</div>

Dear Andras Lasso.

Thank you for your kind reply. In addition, I would like to thank you for teaching me how to obtain the data for finite element analysis.

And I could get the list of coordinates of the model vertices. (I confirmed that by typing “print (coords)” in console window.)  
However, I only could get the error in your code line3.

It says

> > > modelNode = getNode(‘Dishreg3’)  
> > > coords = slicer.util.arrayFromModelPoints(modelNode)  
> > > densities = slicer.util.arrayFromModelPointData(modelNode, ‘ikeimage’)  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “C:\Users\MasatoshiOba\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Python\slicer\util.py”, line 1293, in arrayFromModelPointData  
> > > narray = vtk.util.numpy\_support.vtk\_to\_numpy(arrayVtk)  
> > > File “C:\Users\MasatoshiOba\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Lib\site-packages\vtkmodules\util\numpy\_support.py”, line 216, in vtk\_to\_numpy  
> > > typ = vtk\_array.GetDataType()  
> > > AttributeError: ‘NoneType’ object has no attribute ‘GetDataType’

Is there something wrong with the way I installed Slicer? Or am I specifying the files in my NRRDimage the wrong way?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 3, 2020, 4:03pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/5 "2020-11-03T16:03:53Z")

</div>

> [@MasatoshiOBA](#):
>
> densities = slicer.util.arrayFromModelPointData(modelNode, ‘ikeimage’)

Can you try to use the code that I wrote above (‘NRRDImage’ instead of ‘ikeimage’)?

---

<div class="post-metadata">

**Author:** ![MasatoshiOBA](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MasatoshiOBA](https://discourse.slicer.org/u/MasatoshiOBA)\
**Post date:** [November 3, 2020, 10:20pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/6 "2020-11-03T22:20:27Z")

</div>

Thank you again.  
I tried that

> > > densities = slicer.util.arrayFromModelPointData(modelNode, ‘NRRDImage’)  
> > > Traceback (most recent call last):  
> > > File “”, line 1, in   
> > > File “C:\Users\MasatoshiOba\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Python\slicer\util.py”, line 1293, in arrayFromModelPointData  
> > > narray = vtk.util.numpy\_support.vtk\_to\_numpy(arrayVtk)  
> > > File “C:\Users\MasatoshiOba\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Lib\site-packages\vtkmodules\util\numpy\_support.py”, line 216, in vtk\_to\_numpy  
> > > typ = vtk\_array.GetDataType()  
> > > AttributeError: ‘NoneType’ object has no attribute ‘GetDataType’

If I type  
print(modelNode) and print(coords) after I typed line 2, they return what I want.  
So something wrong with executing line3.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 3, 2020, 10:44pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/7 "2020-11-03T22:44:39Z")

</div>

Do you run this on the output of “Probe volume with model”?  
Do you see the ‘NRRDImage’ array in Models module Scalars section?

---

<div class="post-metadata">

**Author:** ![MasatoshiOBA](https://avatars.discourse-cdn.com/v4/letter/m/b487fb/32.png) [@MasatoshiOBA](https://discourse.slicer.org/u/MasatoshiOBA)\
**Post date:** [November 3, 2020, 11:12pm UTC](https://discourse.slicer.org/t/how-to-get-hu-values-at-each-fiducial-points/14378/8 "2020-11-03T23:12:03Z")

</div>

> [@lassoan](#):
>
> Do you run this on the output of “Probe volume with model”?

> Do you run this on the output of “Probe volume with model”?

Thank you so much, it resolved!  
I didn’t run “Probe volume with model” module first, and that was the reason of failure.

> > > modelNode = getNode(‘Output Model’)  
> > > coords = slicer.util.arrayFromModelPoints(modelNode)  
> > > densities = slicer.util.arrayFromModelPointData(modelNode, ‘NRRDImage’)  
> > > print(densities)  
> > > [ 376 320 83 541 523 420 488 537 364 508 532 260 168 244  
> > > 171 651 948 203 166 438 422 135 32 136 145 216 263 79  
> > > 471 252 42 15 493 620 492 537 428 537 573 117 287 35 …
