MATLAB Answers

How can I modify code to Fit tif image series of beads (PSF) with Gaussian; Handling empty or non-fittable problematic tif frames inbetween series?

3 views (last 30 days)
SNT on 17 Jul 2017
Hello, I am new to Matlab coding and have a small problem with some code I am using and would be great if someone could help me out!
I use the (attached on this thread) fitpeak.m to fit a series of moving fluorescent beads on microscope saved as a tif series. It fits the bead psf with a gausian and gives me the fitted values as output.
This fitpeak.m is called by the script as follow;
%Fit the data
for k=1:size(selected_frames,3)
cur_frame = selected_frames(:,:,k);
[temp_peakpos_x, temp_peakwidth_x, temp_rmse_x]= fitpeak(double(x_lineprof),1,1,maxy(k),10,1);
[temp_peakpos_y, temp_peakwidth_y, temp_rmse_y]= fitpeak(double(y_lineprof'),1,1,maxx(k),10,1);
peakpos_x(k) = temp_peakpos_x;
peakpos_y(k) = temp_peakpos_y;
peakwidth_x(k) = temp_peakwidth_x;
peakwidth_y(k) = temp_peakwidth_y;
rmse_x(k) = temp_rmse_x;
rmse_y(k) = temp_rmse_y;
But currently if there is a blank tif image between the series (example, if the bead moves out of focus and disappears just for one frame and comes back in the next) or a frame which cannot be fitted appears, the script does not complete the run, giving following error;
Subscript indices must either be real positive integers or logicals.
Error in fitpeak (line 19)
win(i,:) = xcoord(ppos(i)-35:ppos(i)+35);
Error in TifSPT (line 136)
[temp_peakpos_x, temp_peakwidth_x, temp_rmse_x]= fitpeak(double(x_lineprof),1,1,maxy(k),10,1);
Could someone help me on how I can modify the script so as to accommodate such blank tifs by skipping to the next tif, (after filling the array with a zero value for that particular frame which was not fitted) and carrying on the analysis (and keep filling the array with fitted values till end of tif frame series)?
Thanks a lot in advance!


Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!