Change optimization function for dipole fitting in Fieldtrip MATLAB
3 views (last 30 days)
Show older comments
Hello MATLAB users,
I am currently working on dipole optimization problem and using the MATLAB code from fieldtrip to optimize the goodness of fit of my dipole function. The fieldtrip uses either fminsearch or fminunc for the dipole optimization method
[param, fval, exitflag, output] = optimfun(@dipfit_error, param, options, dat, sens, headmodel, constr, metric, checkinside, mleweight, reducerank, normalize, normalizeparam, weight, backproject); where optimfun is either @fminsearch or @fminunc.
I want to apply simulated annealing algorithm for my optimization function, but I am not quite familiar with the arguments that it takes. Can I set lb=[], ub=[] and apply simulated annealing to the above function and calculate goodness of fit for my function? What should be the order of the input arguments if I use Simulated annealing?
Will this work?
[param, fval, exitflag, output] =@simulannealbnd(@dipfit_error, param,lb=[],ub=[], options, dat, sens, headmodel, constr, metric, checkinside, mleweight, reducerank, normalize, normalizeparam, weight, backproject);
the complete code of fieldtrip function is here
The optimization is done on line 186.
0 Comments
Answers (1)
Ayush Anand
on 22 Nov 2023
Edited: Ayush Anand
on 22 Nov 2023
Hi Subrat,
I understand you are working on dipole optimization problem and using fieldtrip to optimize the goodness of the fit. You want to apply simulated annealing for the optimization function and would like to know more about the arguments that it takes.
You can use the “simulannealbnd” function for applying the simulated annealing algorithm on the optimization function. The function signature for “simulannealbnd” is as follows:
x= simulannealbnd(fun,x0,lb,ub,options)
where x0 is an initial point for the simulated annealing algorithm, a real vector, and lb and ub are the lower bounds and upper bounds for the solution respectively. If no bounds exist, one can set lb = [] and/or ub=[]. So for your case, you can specify an anonymous function that includes all the additional parameters (dat, sens, headmodel etc.) and then pass it to “simulannealbnd” along with the bounds:
lb = [];
ub = [];
% Define an anonymous function that includes all the additional parameters
objFun = @(x) dipfit_error(x, dat, sens, headmodel, constr, metric, checkinside, mleweight, reducerank, normalize, normalizeparam, weight, backproject);
% Call simulannealbnd with the objective function and parameters
[param, fval, exitflag, output] = simulannealbnd(objFun, param, lb, ub, options);
You can read more about the syntax for “simulannealbnd” here:
I hope this helps!
0 Comments
See Also
Categories
Find more on Simulated Annealing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!