Looping thru lists containing ROI's and Axes, then creating a table - rather than using the same code sequentially
Show older comments
Hello, I have 3 ROI (images), ROI1, ROI2 & ROI3 that are children of their respective uiaxes (ax1,ax2,ax3)
Im interested in creating a table of the outputs of my functions below with the following parameters gathered in the table:
medMaxI1,fwhmBlockX1,fwhmBlockY1,fwhm2D1 % For ROI1 and ax1
medMaxI2,fwhmBlockX2,fwhmBlockY2,fwhm2D2 % For ROI2 and ax2
medMaxI3,fwhmBlockX3,fwhmBlockY3,fwhm2D3 % For ROI3 and ax3
My sequencial code is below
IM=ROI1; AX=ax1;
[x1, y1]=myAnalysisFunctions.FindSpotsGaussian(IM,fwhm,thresh);
app.x1=x1; app.y1=y1;
F=isnan(x1); % 1 means its a nan, i.e no spots found
if F==0
hold(AX,'on'); plot(AX,x1,y1,'r.');
[mask,medMaxI1]=myAnalysisFunctions.createMaskFromCentroids(x1,y1,IM,4);
[fwhmBlockX1,fwhmBlockY1,fwhm2D1] = getFHWMbyACF(app,AX,IM,x1,y1,nl, linespacing, maxFwhm); drawnow
end
IM=ROI2; AX=ax2;
[x1, y1]=myAnalysisFunctions.FindSpotsGaussian(IM,fwhm,thresh);
app.x1=x1; app.y1=y1;
F=isnan(x1); % 1 means its a nan, i.e no spots found
if F==0
hold(AX,'on'); plot(AX,x1,y1,'r.');
[mask,medMaxI2]=myAnalysisFunctions.createMaskFromCentroids(x1,y1,IM,4);
[fwhmBlockX2,fwhmBlockY2,fwhm2D2] = getFHWMbyACF(app,AX,IM,x1,y1,nl, linespacing, maxFwhm); drawnow
end
IM=ROI3; AX=ax3;
[x1, y1]=myAnalysisFunctions.FindSpotsGaussian(IM,fwhm,thresh);
app.x1=x1; app.y1=y1;
F=isnan(x1); % 1 means its a nan, i.e no spots found
if F==0
hold(AX,'on'); plot(AX,x1,y1,'r.');
[mask,medMaxI3]=myAnalysisFunctions.createMaskFromCentroids(x1,y1,IM,4);
[fwhmBlockX3,fwhmBlockY3,fwhm2D3] = getFHWMbyACF(app,AX,IM,x1,y1,nl, linespacing, maxFwhm); drawnow
end
I was wanting to use something like this so just have a loop
IMlist={ROI1,ROI2,ROI3};
AXlist={ax1,ax2,ax3};
for idx = 1:length(IMlist)
IM = IMlist{idx};
AX = Axlist{idx};
....
end
But then, Im not too sure how to construct my table - this is how I do it when using the "sequential" code
% Create a Table to display parameters
params = ["ROI_L";"ROI_C";"ROI_R"];
FWHMX = [fwhmBlockX1;fwhmBlockX2;fwhmBlockX3];
FWHMY = [fwhmBlockY1;fwhmBlockY2;fwhmBlockY3];
FWHM2D = [fwhm2D1; fwhm2D2;fwhm2D3];
CenInt = [medMaxI1; medMaxI2;medMaxI3];
format bank
tbl = table(params,FWHMX,FWHMY,FWHM2D,CenInt);
which gives me:
params FWHMX FWHMY FWHM2D CenInt
_______ _____ _____ ______ ______
"ROI_L" 3.22 2.81 3.02 235.00
"ROI_C" 3.23 2.80 3.02 223.00
"ROI_R" 3.19 2.82 3.00 200.00
Accepted Answer
More Answers (0)
Categories
Find more on Whos 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!