Skip to content

Commit

Permalink
v.1.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ekatrukha committed Oct 25, 2022
1 parent 5713daa commit 3e7c667
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
Binary file modified release/DoM_-1.2.4.jar
Binary file not shown.
7 changes: 5 additions & 2 deletions src/main/java/fiji/plugin/DOM/Reconstruct_Image.java
Expand Up @@ -28,6 +28,7 @@ public void run(String arg)
double [] yloc;
double [] xnm;
double [] ynm;
double [] znm;
double [] falsepos;
double [] frames;
double xmax, ymax;
Expand Down Expand Up @@ -64,7 +65,7 @@ public void run(String arg)
{
//check if localization precision is less than 1 pixels
//old: if(falsepos[i]<0.2)
if(xloc[i]*pxsize<1 && yloc[i]*pxsize<1)
if(Math.abs(xloc[i]*pxsize)<1.0 && Math.abs(yloc[i]*pxsize)<1.0 && Double.isFinite(xloc[i]) && Double.isFinite(yloc[i]))
{
xlocavg+=xloc[i];
ylocavg+=yloc[i];
Expand Down Expand Up @@ -98,10 +99,12 @@ public void run(String arg)
ymax=ynm[i];
}
}
//calculate z-range
znm = sml.ptable.getColumnAsDoubles(DOMConstants.Col_Znm);

//show dialog with options
//here we provide xmax and ymax in original pixels
if (!dlg.ReconstructImage(xlocavg,ylocavg,fminframe,fmaxframe, xmax*pxsize, ymax*pxsize)) return;
if (!dlg.ReconstructImage(xlocavg,ylocavg,fminframe,fmaxframe, xmax*pxsize, ymax*pxsize,SMLReconstruct.getZmaxmin(znm))) return;
//and here we transform values of rectangle back
dlg.nRecWidth=dlg.nRecWidth/pxsize;
dlg.nRecHeight=dlg.nRecHeight/pxsize;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fiji/plugin/DOM/SMLDialog.java
Expand Up @@ -387,7 +387,7 @@ public boolean getValues()
* @return user choice
*/

public boolean ReconstructImage(double xlocavg_, double ylocavg_, double fminframe, double fmaxframe, double xmax, double ymax)
public boolean ReconstructImage(double xlocavg_, double ylocavg_, double fminframe, double fmaxframe, double xmax, double ymax, double [] zRange)
{
int LutChoice;
GenericDialog dgReconstruct = new GenericDialog("Reconstruct Dataset");
Expand Down Expand Up @@ -438,8 +438,8 @@ public boolean ReconstructImage(double xlocavg_, double ylocavg_, double fminfra
dgReconstruct.addCheckboxGroup(1,2,sLabelsCheckbox,sLabelsDefault);
dgReconstruct.addChoice("LUT for colorcode render:",luts,Prefs.get("SiMoLoc.zLutChoice","Fire"));
dgReconstruct.addCheckbox("Use Z-range", Prefs.get("SiMoLoc.Zrange", false));
dgReconstruct.addNumericField("Z min:", Prefs.get("SiMoLoc.zMin", 0), 2,6, "nm");
dgReconstruct.addNumericField("Z max:", Prefs.get("SiMoLoc.zMax", 0), 2,6, "nm");
dgReconstruct.addNumericField("Z min:", zRange[0], 2,6, "nm");
dgReconstruct.addNumericField("Z max:", zRange[1], 2,6, "nm");
//dgReconstruct.addCheckbox("Calculate z-values based on calibration", Prefs.get("SiMoLoc.recalZvalues", false));
//dgReconstruct.addMessage("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

Expand Down
49 changes: 25 additions & 24 deletions src/main/java/fiji/plugin/DOM/SMLReconstruct.java
Expand Up @@ -57,10 +57,9 @@ public class SMLReconstruct {
/** linearly interpolated drift x coordinates for each frame */
double [] approxy;

/** max Z value*/
double zmax;
/** min Z value*/
double zmin;
/** min max Z value*/
double [] zRange = new double [2];


double max=0;
double min=9999999;
Expand Down Expand Up @@ -168,12 +167,12 @@ public class SMLReconstruct {
{
if(dlg_.bZRange)
{
zmin = dlg_.dZMin;
zmax = dlg_.dZMax;
zRange[0]=dlg_.dZMin;
zRange[1] = dlg_.dZMax;
}
else
{
getZmaxmin();
zRange = getZmaxmin(z);
}
}

Expand Down Expand Up @@ -288,7 +287,7 @@ void draw_zstack(int fstart, int fstop, double zstep)
//zmax=Prefs.get("SiMoLOc.ZC_fitRangeMax", 1000);


nSlices = (int) Math.ceil((zmax-zmin)/zstep);
nSlices = (int) Math.ceil((zRange[1]-zRange[0])/zstep);

//in case all z-values are zero still one slice has to be drawn
if(nSlices==0)
Expand All @@ -309,8 +308,8 @@ void draw_zstack(int fstart, int fstop, double zstep)

for (int n=0;n<nParticlesCount;n++)
{
//if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold)
if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold && z[n]>zmin && z[n]<zmax)
if (Double.isFinite(loc_errx[n])&&Double.isFinite(loc_erry[n])&&Double.isFinite(loc_errz[n]))
if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold && z[n]>zRange[0] && z[n]<zRange[1])
{
IJ.showProgress(n, nParticlesCount);
xmag=(int) Math.round(x[n]*settings.dMagnification);
Expand Down Expand Up @@ -353,7 +352,7 @@ void draw_zstack(int fstart, int fstop, double zstep)
{
if((i<new_width) && (j<new_height)&&(i>0)&&(j>0))
{
sliceNumber = (int)Math.round(k-(zmin/zstep));
sliceNumber = (int)Math.round(k-(zRange[0]/zstep));
if(sliceNumber>=0 && sliceNumber<nSlices)
{
old_i=ipf[sliceNumber].getf(i, j);
Expand Down Expand Up @@ -435,7 +434,7 @@ void draw_colorcodedZ(int fstart, int fstop)
for (int n=0;n<nParticlesCount;n++)
{
//if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold)
if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold && z[n]>zmin && z[n]<zmax)
if (f[n]>=fstart && f[n]<=fstop && fp[n]<dFPThreshold && z[n]>zRange[0] && z[n]<zRange[1])
{
IJ.showProgress(n, nParticlesCount);
xmag=(int) Math.round(x[n]*settings.dMagnification);
Expand Down Expand Up @@ -472,7 +471,7 @@ void draw_colorcodedZ(int fstart, int fstop)
dErrx = ErrorFunction.erf2((i-xpeak)/loc_errxmag) - ErrorFunction.erf2((1+i-xpeak)/loc_errxmag);
dErry = ErrorFunction.erf2((j-ypeak)/loc_errymag) - ErrorFunction.erf2((1+j-ypeak)/loc_errymag);

zhue = (z[n]-zmin)/(zmax-zmin);
zhue = (z[n]-zRange[0])/(zRange[1]-zRange[0]);


zInd = dZcolorScale[(int)Math.round(zhue*255)];
Expand Down Expand Up @@ -551,9 +550,9 @@ void draw_colorcodedZ(int fstart, int fstop)
for(j=25;j<40;j++)
imcolcode.putPixel(i, j, newrgb);
imcolcode.setJustification(ImageProcessor.LEFT_JUSTIFY);
imcolcode.drawString(new DecimalFormat("#").format(zmin)+ " nm",0,40);
imcolcode.drawString(new DecimalFormat("#").format(zRange[0])+ " nm",0,40);
imcolcode.setJustification(ImageProcessor.RIGHT_JUSTIFY);
imcolcode.drawString(new DecimalFormat("#").format(zmax)+ " nm",250,40);
imcolcode.drawString(new DecimalFormat("#").format(zRange[1])+ " nm",250,40);
new ImagePlus("Z colorbar" , imcolcode).show();


Expand Down Expand Up @@ -1075,9 +1074,9 @@ void applylinearapproximationcorrection()
//build histogram
for (i =0; i<nParticlesCount; i++)
{
if(z[i]>zmin && z[i]<zmax)
if(z[i]>zRange[0] && z[i]<zRange[1])
{
ztemp = (z[i]-zmin)/(zmax-zmin);
ztemp = (z[i]-zRange[0])/(zRange[1]-zRange[0]);
cumHist[(int)Math.round(ztemp*255)]++;
}
}
Expand Down Expand Up @@ -1607,18 +1606,20 @@ void addTranslation()
}
/**function calculating zmin and zmax
* */
void getZmaxmin()
static double [] getZmaxmin(final double [] z)
{
zmax=(-1)*Double.MAX_VALUE;
zmin=Double.MAX_VALUE;
double [] zRange = new double [2];
zRange[1]=(-1)*Double.MAX_VALUE;
zRange[0]=Double.MAX_VALUE;
for (int i=0;i<z.length;i++)
{
if(z[i]>zmax)
zmax=z[i];
if(z[i]<zmin)
zmin=z[i];
if(z[i]>zRange[1])
zRange[1]=z[i];
if(z[i]<zRange[0])
zRange[0]=z[i];

}
return zRange;
}

}

0 comments on commit 3e7c667

Please sign in to comment.