# TensorFractionalAnisotropyImageFilter calculate FA bigger than 1

**URL:** <https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432>\
**Category:** Algorithms\
**Tags:** itk, dicom\
**Created:** [February 14, 2025, 3:17am UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432 "2025-02-14T03:17:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pinyu\_Huang](https://discourse.itk.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@Pinyu\_Huang](https://discourse.itk.org/u/Pinyu_Huang)\
**Post date:** [February 14, 2025, 3:17am UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432/1 "2025-02-14T03:17:13Z")

</div>

I use **`TensorFractionalAnisotropyImageFilter`** to calculate FA for the DTI image. The code is:

```auto
using Image3DType = itk::Image<float, 3>
using FAFilterType = itk::TensorFractionalAnisotropyImageFilter<TensorReconstructionFilterType::OutputImageType, Image3DType>;
auto faFilter = FAFilterType::New();
faFilter->SetInput(tensorImage);
faFilter->Update();
auto faImage = faFilter->GetOutput();

```

while the `tensorimage` is generated by

```auto
	tensorFilter->SetGradientImage(gradientContainer, vectorImage);
	tensorFilter->SetThreshold(5);
	tensorFilter->SetBValue(1000.0);
	tensorFilter->Update();

```

And with writing down vectorImage, the scalar range is a little bit change from 0-3095 to about 0-3000, and the gradientContainer is checked fine.

But after get the `faImage`, the range is from 0-1.2247, which is bothering me a lot. Does it mean that the lambda1, lambda2, lambda3 is calculated wrong like all zero? but the background is 0 in FA which seems well-solved. The correct FA should be 0-1.

So what problem might be in my pipeline? Could you give me a hand? Great appreciation!

---

<div class="post-metadata">

**Author:** ![cookpa](https://discourse.itk.org/user_avatar/discourse.itk.org/cookpa/32/255_2.png) [@cookpa](https://discourse.itk.org/u/cookpa)\
**Post date:** [February 14, 2025, 3:00pm UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432/2 "2025-02-14T15:00:34Z")

</div>

> But after get the `faImage` , the range is from 0-1.2247, which is bothering me a lot. Does it mean that the lambda1, lambda2, lambda3 is calculated wrong like all zero?

No, that would produce FA of 0. If FA \> 1, it is usually because lambda3 (the smallest one) is negative. This is not physically possible, but sometimes happens because of noise or other image artifacts. Also, if any voxels outside the brain are included, especially voxels containing air outside the head, FA is more likely to exceed one.

I would write out the faImage and look at how extensive these problem voxels are, and where they are. It might just be a few outliers that can be removed with better brain masking.

---

<div class="post-metadata">

**Author:** ![Pinyu\_Huang](https://discourse.itk.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@Pinyu\_Huang](https://discourse.itk.org/u/Pinyu_Huang)\
**Post date:** [February 17, 2025, 1:27am UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432/3 "2025-02-17T01:27:49Z")

</div>

I’ve written down the FAImage, the range is like this:

 ![image](https://discourse.itk.org/uploads/default/original/2X/0/0008d1225ab77daa6d717256051006f9616d211a.png)  
There’re so many values higher than 1 in the map.

This confuse me a lot. I tried `dipy` to calculate FA and got, But `dipy` cannot remove the background well like the below:

 ![image](https://discourse.itk.org/uploads/default/original/2X/4/4e4a1884cda3a2528bec077c7329ed1ffcc812a6.png)

I’ve compared two different ways to calculate FA. Here the first row is `dipy` the second row is `ITK` as below.

 ![image](https://discourse.itk.org/uploads/default/original/2X/b/bbd82233f0f765c105c35fd04c1a69b923acb185.jpeg)

---

<div class="post-metadata">

**Author:** ![cookpa](https://discourse.itk.org/user_avatar/discourse.itk.org/cookpa/32/255_2.png) [@cookpa](https://discourse.itk.org/u/cookpa)\
**Post date:** [February 17, 2025, 3:00pm UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432/4 "2025-02-17T15:00:59Z")

</div>

It’s possible there is a problem with your tensor fit. It’s a bit hard to tell though. I see you are using ITK-SNAP - can you threshold the FA at 1.0 and then overlay it in ITK-SNAP?

Using the c3d command that comes with ITK-SNAP, you can do this with

c3d fa.nii.gz -thresh 1 Inf 1 0 -o fa\_1mask.nii.gz

itksnap -g fa.nii.gz -s fa\_1mask.nii.gz

---

<div class="post-metadata">

**Author:** ![Pinyu\_Huang](https://discourse.itk.org/letter_avatar_proxy/v4/letter/p/34f0e0/32.png) [@Pinyu\_Huang](https://discourse.itk.org/u/Pinyu_Huang)\
**Post date:** [February 18, 2025, 1:42am UTC](https://discourse.itk.org/t/tensorfractionalanisotropyimagefilter-calculate-fa-bigger-than-1/7432/5 "2025-02-18T01:42:21Z")

</div>

I check my code and finally found the bugs in the eigen values and vectors calculation, the assignment of D matrix is wrong, so the FA and PDD calculation is not correct.  
After fixing that, the map is like

 ![image](https://discourse.itk.org/uploads/default/original/2X/2/2f8de297a2d2155336121f276e028ec83ba74584.png)  
Seems work for me.

 ![image](https://discourse.itk.org/uploads/default/original/2X/f/fc03c9c6177d66685df0ab8e137f553af9bda78d.png)  
Here is the colored FA image, just a little bit of masiac style XD.
