File Exchange

image thumbnail


version (16.7 MB) by Natan
Apply polar onion peeling method for analyzing velocity map imaging (VMI) data.


Updated 09 Apr 2021

From GitHub

View Version History

View license on GitHub

The code implements the method shown at "Toward real-time charged-particle image reconstruction using polar onion-peeling" by G.M. Roberts et-al, Rev. Sci. Instr. 80, 053104 (2009). It supports images of up to 4K and accepts arbitrary (even) beta parameters. Specific quadrants of the image can be selected in the analysis in case of image asymmetries. NaN values can be used for masking unwanted pixels or areas.
For more info regarding the method see:

Cite As

Natan (2021). PolarOnionPeeling (, GitHub. Retrieved .

Comments and Ratings (13)


Hi Malte, I probably did that to play with the visibility of the deconvolved signal at higher r values, and forgot to un-comment it. the sqrt(r) is a just scaling factor,feel free to un-comment if you want to have the original code purpose. I'll edit this in the next round of updates...

Malte Sumfleth

Hey Natan,
while working with your code i noticed you had commented out the /sqrt(r) in lines 331 and 334 of POP.m.
Those remove the effect of pixelation as described in the paper.
Was there a specific reason for leaving them out?


Hi Paul and Bennet, I've updated the broken link (though the paper's details are mentioned above. Thanks for spotting this. Bennet, the "s.betas" typo was just in the commented code header, the output was always s.Betas as you saw with the pop_example.m script I've included. I've also added PESR to the output for what it's worth, I excluded it before because I didn't needed it, but now it is back again, as it doesn't cost anything, and it can be also calculated outside of the for loop.

Paul Kassebaum

Hi Natan, your link to the AIP paper in the description of your File Exchange entry (above) returns a 404 page not found.

Bennet Krebs

Hey Natan,
I just looked over your new code and I think I found some discrepancies between what your introduction says the outputs would be, and whats actually in the structure "s".
You state that your output structure "s" always contains 8 fields. The actual output is missing "s.PESR", but additionally contains the deconvoluted "s.sqpde" field. Also "s.betas" is actually upper case "s.Betas".
As far as I can see "s.PESR" is actually calculated in the "tripolar" function (however its not 1D yet), but then discarded.
I am an amateur when it comes to Matlab, so maybe I'm missing something here.

Bennet Krebs

Hello Natan,
I managed to fix the problem shortly after i posted here, so I didn't remember to check in again, sorry. Basicly (if I remember correctly) there was a problem with naming variables i.e. some 2d rectangular array suddenly changed its varable name inside the code so the script broke down. But you probably already found that yourself, since this version of the script works nicely. Thanks again for your work, it is very helpful.
On another note, the link in your description results in a 404 for me.


Hi Bennet, Can you please send me a sample of the code you are using, I manage to get the iradeconExp info... I'll also soon update the code with a more current version that allows for masking with NaN...

Bennet Krebs

Hi Natan, your code is very useful and i appreciate the time you took making it public.
My problem it with the "experimental image". I cannot seem to get your code to work with the 'exp' parameter, the following error occurs:

Error using POP>t2f (line 294)
Not enough input arguments.

Error in POP (line 249)

Error in TESTBED (line 2)
s=POP(im,2:2:4, 1:4, 'exp');

I tired it with multiple of my own VMI-Spectra and your testfile, which all work perfect with the 'sim' setting.
I'm currently reading through your refereed paper and the code itself, so maybe I find the answer in there.


Thanks Natan for the inversion code. Hopefully it works for me. I will try it on my ion/electron raw images. :)


Your data is probably all zeros in some radius, so the interpolation is not possible. Just add to your data a negligible const value, like: data=data+eps; to solve it. I'll update the code with a try\catch case in that loop for this case in the future.


The code is very cool!
I tried my images, it works very well and fast.
It can also give higher order beta, amazing.
But still some of my images meet one error as:
??? Error using ==> interp1 at 184
There should be at least two data points.

Error in ==> POP at 234

My image size is 990*990 (double)as .mat file.

Would you please give me some advice?


@Luis, if you press "Download Submission" you'll get a zip file ( that contains also delta_lut.mat ...


Tried to test it but couldn't find delta_lut.mat, thanks

MATLAB Release Compatibility
Created with R2013b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: cart2tripolar

Community Treasure Hunt

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

Start Hunting!