Finding the maximum value of displacement fields using python

Operating system: windows 10
Slicer version: 4.8.1
Hi 3D slicer experts and all users
I work with 3D slicer, but I am unfamiliar with python, and now I am learning it. I calculated the displacement fields for a specific segment (eg, lung), and as we know these vectors include components in 3 directions (RAS).
1- I want to find the value of these vectors ( Di = ( Ri2 + Ai2 + Si2 )0.5 )
, then find the maximum among these values Di (Di max) .
2- If we consider for each components of R, A, S ;3 variables P, Q, N ; then what is the maximum value of each variables (eg, Pi max , Qi max , Ni max)?

You can use arrayFromGridTransform to get displacement values as a numpy array and you can use basic numpy functions to compute magnitude (norm) of the vectors and find maxima.

You can also convert any transform to a volume node containing displacement field vectors or magnitudes and use arrayFromVolume to get numpy array.