LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the Gaussian surface with offset fit.vi to detect focal drift in ultrafast laser microscope

I am looking for a way to quickly check for focal drift in my laser microscope using calibration beads. I ran across the "Gaussian surface with offset fit.vi" in the example folder and I would love to edit it to where I can upload my 2D array data of my bead at the desired focal position, tell the code to hold this plot, then upload the new 2D array of the bead into the plot to check for any differences indicating that the bead has drifted. 

 

Right now, I am struggling to see where I can edit the code to upload my data in the block diagram. I know how to add the path to my data and extract the file and inputs I need; I'm just not sure if I need to modify the 2D gauss model function on the block diagram to add my data.

If anyone has any suggestions for editing this code or better ideas for quickly checking focal drift using .dat file or .tif files, I'm all ears (and eyes in this case)!

Download All
0 Kudos
Message 1 of 4
(2,591 Views)

The Demo you attached generates (for testing purposes) a 2D Gaussian (in Gaussian Surface Data) and adds Gaussian Noise (so there are "known parameters" + Noise to check on accuracy of fit).  My question is what is the nature of your microscope data?  I assume you are plotting "something" (light intensity?  height of a surface?) as a function of spatial X and Y coordinates -- do you expect this surface plot to be well-fit by a 2D Gaussian?  One should note that the Gaussian model has six parameters, and thus an implicit constraint that the axes of symmetry are along the X and Y axes (as opposed to, say, rotated by 45 degrees).  Maybe you should attach a picture of your "image" that you are trying to analyze ...

 

In any case, what you'd want to do is to replace this "Generate Test Data" with another VI that says "Create 2D Data from Sample File", and pass that in.  The rest of the code does the fit.

 

Bob Schor

0 Kudos
Message 2 of 4
(2,578 Views)

Hi Bob, 

 

You would be correct with your assumption. I am plotting the intensity of different things overtime using two photon laser scanning. I have some pretty strong thermal drift, even after warming up the objective by taking blank scans of a coverslip for hours with the laser before actually trying to image my sample. Attached is a timelapse of a ~1 micron bead, after I had "warmed up" my microscope for 3 hours, along with the recorded z positions of my microscope stage, except my microscope stage does not seem to recognize when drift is occurring. The last "jet color scale" image is where I went in and refocused in the z plane only, but I am also experiencing x and y drift too (which is just the salt to the wound of my frustration), as shown by the red and blue dots. Since my axial resolution is theoretical calculated to be ~646 nm given my wavelength and optical components, I thought I could use a 2D Gaussian fit of the original focal spot and then overlap the Gaussian fit of the bead overtime to quickly fix the drift by comparing the changes in the peaks, while also looking for x and y position changes. I'm not great at judging if I am actually at my original focal position using just line thresholds... I'm hoping to be one day. 

 

I'll definitely try your recommendation! If anything I just added sparked a new idea, I would love to hear it!

0 Kudos
Message 3 of 4
(2,542 Views)

Thank you for capturing and showing the data you are trying to fit.  I'd say that there's something wrong with your microscope if it drifts that much (in X, Y, and Z -- could it be a mechanical or imaging problem?).

 

What is Z?  Is it intensity?  I'm not certain (given the various factors at play here) that fitting a 2D Gaussian make "logical" sense, as there is no obvious reason to assume that Z varies as a Gaussian.  If you did choose to fit a 2DG, then you'd speed up the fit without materially sacrificing "information" by fitting a Gaussian without offset, and one with radial symmetry, i.e. only a single Sigma for both X and Y.  Note that you could probably do as well (for this example) by the following algorithm:

  1. Find the Pixel with the maximum value.
  2. Consider a square area around this pixel, say 41x41 pixels (put the Max Pixel in the middle of this square).
  3. Within this square, position a "search square", say 15x15 pixels (not sure of size, you may want to experiment) at every position within the big square and get the intensity in this Search Square.
  4. Choose as the center the center of the Search Square with the highest intensity.

This is, undoubtedly, Crude, but Probably Effective.  It makes no assumption about how intensity (or whatever Z represents) falls off with distance, so it is, in effect, "Model-deficient" (not quite "model-free").  Still, easy to implement, easy to test, and since you don't really want the "edges" to play much of a role, probably as accurate (and almost certainly faster) than "better" fitting schemes.

 

Bob Schor

0 Kudos
Message 4 of 4
(2,517 Views)