フィルターのクリア

2nd Degree polynomial fit for the 3D array

33 ビュー (過去 30 日間)
jupiter
jupiter 2016 年 9 月 22 日
編集済み: Jason Stockmann 2020 年 7 月 22 日
I am trying to find the 2nd degree polynomial fit for the 3d array which contains the magnetic field distortion information of water in MR imaging. I have two 3D arrays, one having fieldmap values and the other having magnetic field distortion around the MR sample. I am using the expression (Bfieldmap-Xi*Bsample), where Xi is a random value for susceptibility to find the data and try to fit this. But I am not quite sure how to find the fit for the 3D array, since it will have 10 coordinates including all three directions. Please help if someone has already an info on this.
Thanks,
Guru
  3 件のコメント
jupiter
jupiter 2016 年 9 月 23 日
Basically there are 256 voxels each in all three directions. I need to find the fit in all three directions for the above expression. This is to ultimately find the background field in the water. Using the function 'polyfit', I can get only three coordinates, but thats in 2D space, for the 3D space, I need all ten coordinates, for (1,x,y,z,xx,yy,zz,xy,yz,zx). I hope now, the question is clear.
Jason Stockmann
Jason Stockmann 2020 年 7 月 22 日
編集済み: Jason Stockmann 2020 年 7 月 22 日
Guru, you could try the code below. This worked for me. 'data' is your distortion map. 'polyorder' is the scalar input specifying the order of polynomial you'd like to fit to the data. You need to vectorize both your MRI distortion map (dependent variable) and the coordinate system (independent variable). I am also fitting a 3D polynomial to MRI field map data. I just picked integer indices for the coordinate system (independent variables). I didn't bother scaling them into meaningful values for the image field of view. You could replace them with physically meaningful values if you intend to use them for plotting, etc. later on.
dims=size(data);
[XX,YY,ZZ] = ndgrid(1:dims(1),1:dims(2),1:dims(3));
polymodel = polyfitn([XX(:) YY(:) ZZ(:)],data(:),polyorder);
ypred = polyvaln(polymodel,[XX(:) YY(:) ZZ(:)]);
ypred_array = reshape(ypred,dims);

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2016 年 9 月 23 日
If you have Curve Fitting Toolbox it can perform surface fitting. Use the Curve Fitting App to perform the fitting interactively or see "Fit and Plot a Polynomial Surface" on this documentation page for instructions on how to do it programmatically.
If you don't have Curve Fitting Toolbox, see the "Multiple Regression" section on this documentation page.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLinear and Nonlinear Regression についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by