Skip to content

MATLAB toolbox implementing different methods for performing interpolation of 3D magnetic field data.

License

Notifications You must be signed in to change notification settings

ethz-msrl/Magnetic_Field_Interpolation

Repository files navigation

Magnetic Field Interpolation Toolbox

This toolbox contains MATLAB code that implements various mathematical interpolation methods for interpolating 3D magnetic fields.

This code was written working on the paper. Modeling Electromagnetic Navigation Systems, Charreyron S.L., Boehler Q., Kim B., Weibel C., Chautems C., Nelson B.J.

The code is used to generate the experimental data that was used in the interpolation section of the paper, as well as generating the plots for that section. The same were also used for chapter 2 of my PhD thesis.

Implemented Methods

  • Tricubic 3D Interpolation (TRI-3D)
  • Tricubic Scalar Potential Interpolation (TRI-LPL)
  • 3D RBF with Gaussian Kernal (RBF-G-3D)
  • Divergence-free RBF with Gaussian Kernel (RBF-G-DF)
  • 3D RBF with Multiquadric Kernel (RBF-MQ-3D)
  • Divergence-free RBF with Multiquadric Kernel (RBF-MQ-DF)
  • 3D B-spline interpolation (SPL-3D)
  • 3D B-spline interpolation with Laplacian Constraints (SPL-LPL)

File Organization

  • data/ contains all the data that is generated by these experiments as .mat files.
  • figures/ contains all the figures taht are generated by these experiments
  • `generic/' contains some helper functions that don't necesserarily need to be used on magnetic fields
  • models/ contains all the methods implemented using the common interpolator interface
  • old/ contains stuff that is no longer really used and that can be removed
  • rbf/ contains helper functions that implement RBF specific functionality
  • tricubic/ contains helper functions and precalculated matrices that implement functionality for both tricubic methods

Field Interpolator Interface

To help standardize the evaluation of the different methods, we used an abstract base class pattern for the interpolators. The base class is called FieldInterpolator and the derived class implement the following

  • getFieldAtPositions: This interpolates a 3D position and returns a 3D field value
  • getGradientAtPosition: This computes the first derivative and returns a 3x3 matrix at a position value
  • getFieldsAtPositions: this will interpolate many positions and return the associated field values. There is a default implementation that basically loops over positions and is slow. Alternatively if there is a way to vectorize the field calculation method, you can overwrite this method for faster performance.
  • getGradientsAtPositions: same as above.

A seperate object called FieldInterpolatorEvaluator takes a given model and computes all the metrics on that method.

Data Generation

These scripts are used to perform the experiments and generate data in the data folder that is used to evaluate the methods.

  • test_fields_all.m generates the fields using each method on a test set from synthetic data.
  • test_gradients_all.m generates the gradients using each method on a test set. It also makes the divergence and curl calculations.
  • test_rbf_optimal_eps.m calculates the optimal shape parameter for each RBF method based on a subset of test data. Note that the postions are normalized using normalize_positions_minmax.
  • test_eps_score_all.m calculates the N-RMSE score for a given value of the shape parameter over a range for each RBF method. It also calculates the condition number at that value.

Loading saved data

  • load_field_data.m loads the field data generated by test_fields_all.m
  • load_gradient_data.m loads the gradient data generated by test_gradients_all.m

Plotting

These scripts take the saved data and make plots that are saved as PDF files

  • plot_optimal_eps.m plots the optimal RBF shape parameters at different grid sizes
  • plot_eps_score.m plots the score and condition number for a given RBF method
  • plot_field_gradient_nmae.m plots the field and gradient N-MAE score for each method on increasing grid sizes as a single figure
  • plot_div_curl.m plots the divergence and curl for each method at increasing grid sizes as a single figure

Getting the synthetic dataset

The experiments run using a pregrenerated synthetic dataset that was generated with the MPEM. These datasets are available for a number of random electromagnet currents (Ne=8) and at various grid sizes from 3 to 32. The dataset is stored in HDF5 files.

The dataset can be obtained here. Make sure to set the correct path to the dataset files in the load_settings.m file.

Copyright 2020, Samuel Charreyron, All rights reserved.

About

MATLAB toolbox implementing different methods for performing interpolation of 3D magnetic field data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages