LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

bessel function best fit

Hi all,
 
Quite new to LabVIEW. I am capturing diffraction images that are described by Bessel J functions. The maxima of the diffraction correspond to the maxima of the Bessel J functions ( or zeros of 1st derivative).  I wish to fit the diffraction image intensities to a Bessel J function , pixel value -> best fit to x in J(x). Has anyone previously done this before? I know the order n of the Bessel function but not necessarilly the pixel where x=0.
 
Similarly, I hope to fit the diffraction image of a pinhole which is an Airy Disk to use as calibration ie pixel -> m^-1.
 
Any help or suggestions would be gratefully accepted.
 
Regards,
 
Leeser 
0 Kudos
Message 1 of 10
(5,922 Views)


Hi Leeser,

I'm looking into your query, but wondered if you could possibly provide me with some more information? If possible, could you send me the VI you're working on and a few screenshots of some of your captured diffraction patterns (use printscrren on your key board and paste into Paint). If you could describe in a bit more detail exactly what you require, hopefully I will be able to come up with something. I studied Physics at University and vaguely remember coming across these functions when describing vibration modes on a drum. Hopefully, the info. you send will jog my memory a bit more and we should be able to develop a solution for your needs! Smiley Wink

Best wishes

Rob


Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 2 of 10
(5,904 Views)
Hi Rob,

Thanks for your interest. Bessel functions do describe the vibrations of a drum, however, this is not my interest! The diffraction pattern attached is basically that of a single helix ie a coil. The diffraction pattern is basically the Fourier Transform of the helix (Cochrane, Crick, DNA and all that...!). The maxima of the diffraction pattern correspond to the maxima of the Bessel J function of order n, where n is the "layer line",see schematic diagram (schematic.jpg). From these images the coil diameter and pitch can be obtained. The problem is that the zero order intensity is so high it saturates part of the camera and the diffraction intensities close to the zero order are not discernable (open.jpg). I have tried various filtering schemes etc in Vision Assistant to isolate the maxima and also a variation on a Hough Transform. It still all comes back to the ability to fit  the diffraction intensities to the maxima of the Bessel J functions.

With the Airy Disk part, I was going to use the known pattern from the known size pinhole to determine the reciprocal space dimensions of each pixel for calibration purposes, again trying to fit the Airy Disk minima to the Airy Formula.

I suppose another way is just to have a table of Bessel J maxima and get the best correlation?

Anyway, thanks for your interest and any suggestions you may have,

Leeser
0 Kudos
Message 3 of 10
(5,874 Views)
Don't think I attached files previously....!
Download All
0 Kudos
Message 4 of 10
(5,873 Views)


Leeser

Thanks for sending over those images. I think i've grasped what you're trying to achieve now, so will see if I can find a method in LabVIEW of matching up the diffraction pattern to the Bessel maxima. I believe the only way you will be able to remove the saturation is by modifying your physical setup. However, without seeing your apparattus, I can only guess that the problem is due to your physical setup which it of course may not be!

I will try and develop a method and get back to you when I have something more solid. In the mean time, there are a couple of links to a few of our Vision aquisition help pages that might be of use to you, especially as you said you were new to LabVIEW. It's definately worthwhile having a good look round our help pages and developer zone if you haven't done so already.

http://zone.ni.com/devzone/cda/tut/p/id/3470

http://zone.ni.com/devzone/cda/tut/p/id/3849

http://forums.ni.com/ni/board/message?board.id=200&message.id=919&requireLogin=False

Best wishes

Rob


Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 5 of 10
(5,857 Views)
Hi Rob,

Thanks for your help in this. That's basically what I'm looking for, matching diff pattern maxima with Bessel Function maxima. The saturation is caused by the apparatus but can't really be removed easily. It consists of a collimated diode laser (1mm diameter)  impinging on the coil (sub milimetre dimensions). The diffraction pattern is then imaged onto the ccd. I have tried to develop a beam stop to prevent the zero order (effectively the laser beam) striking the ccd chip, but this causes more scatter and blocks part of the diff pattern (1mm metal dot deposited on glass slide!). Theoretically, this physical stop is a high pass filter but saturation of pixels prevents this being done computationally.

I actually uploaded the wrong diff pattern previously; a non-filtered version is attached.

Kristie Elam from NASA had an article on fitting Airy Disk data I still wasn't able to go any further with it, due to my inexperience with LabVIEW, not her help, which I am grateful for. Here's her reply from an email:

"For my fitting routine I used ‘Nonlinear Lev-Mar Fit.vi’ and its subvi ‘Target Fn & Deriv Nonlin.vi’ which are found in the directory LabVIEW 7.1/vi.lib/analysis/6fits.llb.  On the block diagram of ‘Target..’ I entered my airy formula.  Please note that the ‘Target..’ vi also appears in ‘Lev-Mar abx.vi’ and ‘Lev-Mar xx.vi’ in ‘Nonlinear Lev-Mar Fit.vi’. 

Your line profiles will be the Y input to ‘Nonlinear..’  For the X input I used an array of 1 to N.  Your output will be the ‘Best Fit’ array. "


This looks straightforward enough, but the syntax of formulae was my stumbling block and I never got past a non-functioning vi.


Regards,

Leeser

0 Kudos
Message 6 of 10
(5,849 Views)


Hi Leeser

I'm continuing to investigate your query but would like a little bit more information if possible. Are you using any image aquisition software, and do you have any of the Vision IMAQ driver sets (i.e. IEEE-1394) installed? If you have the NI Vision Apllication development module, then I believe we would be able to develop a solution pretty easily for you. This software is very powerful and allows you to do direct manipulation of realtime imaging. Don't worry if not though, I beilieve you can still use LabVIEW 7.1 to achieve your goal, but I have only found a possible solution using the IMAQ drivers so far. 

Let me know if you have any such software installed and I will see what options there are. If you are simply taking a screenshot of your video signal, and then trying to modify the picture in LabVIEW, it will be a lot harder to try and analyse the line profiles (i.e. intensity of each individual pixel) and then map this to the Bessel function. It may still be possible to come up with some method though and I am continuing to investigate with this in mind.

Hope this makes sense!

Regards

Rob



Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
0 Kudos
Message 7 of 10
(5,830 Views)
Hi Rob,

I have the full LabVIEW 8.2 Development software with all the IMAQ drivers, IEEE-1394 drivers also. I had been using  version 7.1 until recently but 8.2 has more useful Vision routines!

I am using it in real time, taking an image from a firewire camera. At the moment I have a very simple routine to get the centre of mass of the maxima; minor adjustments from a Vision Assistant Script! It was working fine for images where the straight through diffraction order was off ccd and only the 1st and 2nd "layer lines" were on. Typically there are around 100-200 maxima.

My particle analysis vi is attached for what it's worth...

Cheers,

Leeser
0 Kudos
Message 8 of 10
(5,807 Views)


Leeser,

Considering you are relatively new to labVIEW, your program was very well structured and seems to approach the problem in the right manner. As you correctly guessed right from the beginning, no-one it seems has attempted fitting a Bessel function to their data. The 'best-fit' VI's found in the 'Fitting Pallette' are more generally concerned with parametric, powers and exponential type functions, rather than more complex differentials such as the Bessel. In cases similar to yours, it seems that people haave tried adopting the Levenberg-Marquardt algorithm which is a Non-Linear Fitting VI found in the Fitting Pallette. This is the Lev-Mar VI which Kristie Elam reccomended you using for the Airy disc. This function allows one to define the equation with which they wish to fit their data, but due to the complexity of the Bessel function, this may be quite tricky.

I have been working on an example VI which provides the basic structure of what you need to implement in to your program. The Bestfit VI converts a picture using the IMAQ functions and then plots the converted data. You can manipulate the row control to choose which row of pixels you wish to analyse. The VI then calls the Lev-Mar Best Fit function which in itself calls the Bessel Formulae VI which is a template for the Bessel Formulae that the Lev-Mar function will use in its best-fit approximation. It is within this VI that you will need to enter the neccessary formulae to produce your theoretical Bessel function. The Lev-Mar Bestfit function can then use this data to plot a Least Squares Best Fit approximation against your spectrum.

Aswell as the Bestfit and Bessel Formulae VI's, I have attached a Gaussian Example VI which gives a complete example of a Bestfit approximation using this method. Furthermore, I have attached a couple of VI's that I found which I hope may help you to develop the Bessel formulae. These include a table of Bessel roots, which you may be able to use to produce a table of the derivative roots, those found on your schematic.

I really hope this information and the files I have attached will be of use to you, I'm just sorry there isn't a direct tool with which you can produce the bestfit approximation. Keep me posted on your progress as I've been working on this for a few days now and would like to see how it goes!

With regards to the Airy disc, I would keep on with the files that you received from Kristie Elam, hopefully using the same method with both the Bessel functions and Airy disc might make things easier for you.

I hope this informtaion is of use to you, best wishes and good luck!

Rob



Rob L

NI Applications Engineer

UK & Ireland


It only takes a click to rate this message 😉
Message 9 of 10
(5,789 Views)
Leeser,

I think Rob's suggestion is a good one. I have not tried fitting to Bessel functions, but I have found that the Lev-Mar VIs do not fit sine waves well if more than one cycle of data is involved and the frequency is one of the parameters to fit. Part of the problem seems to be that the derivatives do not force the function to "move" along the frequency axis. With Bessel functions this may be less of a problem as the zeros are not uniformly spaced. Try the fitting funtions with simulated data until you are sure they work well before throwing too much real data at them.

Lynn
0 Kudos
Message 10 of 10
(5,783 Views)