What is difference between get_data and get_fdata in Nibabel library?
Asked Answered
L

2

8

I'm working with Nibabel to read some .nii files. I came across different examples and some of them use get_data() function while some of them use get_fdata() function. I could not find what the difference is in their documentation (nibabel manuel). Can anyone explain?

Thanks in advance.

Litterbug answered 15/2, 2019 at 8:34 Comment(0)
R
8

I found in their documentation the function-description.

Link to the documentation

get_data(caching='fill')

Return image data from image with any necessary scaling applied

get_fdata(caching='fill', dtype=)

Return floating point image data with necessary scaling applied

So to be short... the get_fdata function takes a float as parameter and return a floating point of that image data. Further informations about how they work are in the documentation.

Recitativo answered 15/2, 2019 at 8:56 Comment(3)
There is also a warning that says get_data will be deprecated in the future and get_fdata should be used. thanks for the answer.Litterbug
Yep right. So if you want to use your application in long term i would recommend to use get_fdata. No problem!Recitativo
According to their developer documentation, the developers of nibabel believe that loading the image with the original but possibly small data type (such as 16-bit integer) may silently cause some issues like overflow.Nucleotidase
E
2

get_fdata() :- provides a more standardized and user-friendly way to access image data by converting it to floating-point values, suitable for many common use cases without manual data type conversion.

get_data() :- preserves the original data type and scaling, which may require additional handling based on specific analysis needs but ensures fidelity to the original data.

Englis answered 17/12, 2023 at 9:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.