Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
imagej-elphel
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
imagej-elphel
Commits
12670bc5
Commit
12670bc5
authored
Dec 22, 2014
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented post-UV manual adjustment control
parent
52e7ddde
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
7 deletions
+99
-7
Aberration_Calibration.java
src/main/java/Aberration_Calibration.java
+35
-0
FocusingField.java
src/main/java/FocusingField.java
+39
-0
LensAdjustment.java
src/main/java/LensAdjustment.java
+25
-7
No files found.
src/main/java/Aberration_Calibration.java
View file @
12670bc5
...
...
@@ -9983,11 +9983,19 @@ if (MORE_BUTTONS) {
}
// double [] targetTilts={0.0,0.0};
double [] manualScrewsCW=null;
double [] postUVScrews=null;
if (zTxTyM1M2M3!=null){
manualScrewsCW=FOCUSING_FIELD.fieldFitting.mechanicalFocusingModel.getManualScrews(
zTxTy[0]-FOCUSING_FIELD.targetRelFocalShift, //double zErr, // positive - away from lens
zTxTy[1]-FOCUSING_FIELD.targetRelTiltX, //targetTilts[0], // double tXErr,// positive - 1,2 away from lens, 3 - to the lens
zTxTy[2]-FOCUSING_FIELD.targetRelTiltY); //targetTilts[1]); // double tYErr);
postUVScrews=FOCUSING_FIELD.fieldFitting.mechanicalFocusingModel.getManualScrews(
FOCUS_MEASUREMENT_PARAMETERS.postUVscrewSensitivity,
zTxTy[0]-FOCUSING_FIELD.targetRelFocalShift, //double zErr, // positive - away from lens
zTxTy[1]-FOCUSING_FIELD.targetRelTiltX, //targetTilts[0], // double tXErr,// positive - 1,2 away from lens, 3 - to the lens
zTxTy[2]-FOCUSING_FIELD.targetRelTiltY); //targetTilts[1]); // double tYErr);
}
double scaleMovement=1.0; // calculate automatically - reduce when close
boolean parallelMove=false;
...
...
@@ -10011,6 +10019,16 @@ if (MORE_BUTTONS) {
else System.out.println("Suggested rotation for screw # "+(i+1)+
" "+IJ.d2s(manualScrewsCW[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CCW)");
}
if (postUVScrews!=null) {
System.out.println("----- Post-UV fixture screw adjustments -----");
for (int i=0;i<postUVScrews.length;i++){
double deg=360*Math.abs(postUVScrews[i]);
if (postUVScrews[i]>=0) System.out.println("Suggested rotation for screw # "+(i+1)+
" "+IJ.d2s(postUVScrews[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CW)");
else System.out.println("Suggested rotation for screw # "+(i+1)+
" "+IJ.d2s(postUVScrews[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CCW)");
}
}
System.out.println("----- end of Focus/tilt measurement results -----");
if (MASTER_DEBUG_LEVEL>0) System.out.println(FOCUSING_FIELD.showSamples());
...
...
@@ -10042,6 +10060,17 @@ if (MORE_BUTTONS) {
if (manualScrewsCW[i]>=0) gd.addMessage("Screw # "+(i+1)+" "+IJ.d2s(manualScrewsCW[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CW)");
else gd.addMessage("Screw # "+(i+1)+" "+IJ.d2s(manualScrewsCW[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CCW)");
}
if (postUVScrews!=null) {
for (int i=0;i<postUVScrews.length;i++){
double deg=360*Math.abs(postUVScrews[i]);
if (postUVScrews[i]>=0) gd.addMessage("Screw # "+(i+1)+" "+IJ.d2s(postUVScrews[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CW)");
else gd.addMessage("Screw # "+(i+1)+" "+IJ.d2s(postUVScrews[i],3)+" ("+IJ.d2s(deg,0)+"\u00b0 CCW)");
}
gd.addMessage( "--- Post-UV fixture screws sensitivity ---");
for (int i=0;i<FOCUS_MEASUREMENT_PARAMETERS.postUVscrewSensitivity.length;i++){
gd.addNumericField("Screw "+i+" sensitivity", FOCUS_MEASUREMENT_PARAMETERS.postUVscrewSensitivity[i], 4,6,"um/turn CW");
}
}
gd.addNumericField("Scale movement",scaleMovement,3,5,"x");
gd.addCheckbox("Recalculate and apply parallel move only",parallelMove); // should be false after manual movement
...
...
@@ -10076,6 +10105,12 @@ if (MORE_BUTTONS) {
newMotors[0]= (int) gd.getNextNumber();
newMotors[1]= (int) gd.getNextNumber();
newMotors[2]= (int) gd.getNextNumber();
if (postUVScrews!=null) {
for (int i=0;i<FOCUS_MEASUREMENT_PARAMETERS.postUVscrewSensitivity.length;i++){
FOCUS_MEASUREMENT_PARAMETERS.postUVscrewSensitivity[i]=gd.getNextNumber();
}
}
scaleMovement= gd.getNextNumber();
parallelMove= gd.getNextBoolean();
FOCUSING_FIELD.filterZ= gd.getNextBoolean();
src/main/java/FocusingField.java
View file @
12670bc5
...
...
@@ -8631,6 +8631,45 @@ public boolean LevenbergMarquardt(
return
turnCW
;
}
/**
* Post UV gluing fixture adjustment, screw numbers match motor numbers
* @param umPerTurn sensitivity of the 3 adjustment screws - microns of the uv-glued support movement per screw revolution
* @param zErr current focal distance error in microns, positive - away from lens
* @param tXErr current horizontal tilt in microns/mm , positive - 1,2 away from lens, 3 - to the lens
* @param tYErr current vertical tilt in microns/mm , positive - 2 away from lens, 1 - to the lens
* @return array of optimal CW rotations of each screw (1.0 == 360 deg)
* @return array of optimal CW rotations of each screw (1.0 == 360 deg)
*/
public
double
[]
getManualScrews
(
double
[]
umPerTurn
,
// if null - use defined here
double
zErr
,
// positive - away from lens
double
tXErr
,
// positive - 1,2 away from lens, 3 - to the lens
double
tYErr
){
// positive - 2 away from lens
double
[][]
screws
={
// right, up, thread pitch (pull) !!! Inverting Y! - again invert? 1 - far left, 2 - near left, 3 - right
{
-
13.5
,
-
6.5
,
192.8
},
// -2.908571735}, // 192.8, ... for proto push-away fixture
{
-
13.5
,
6.5
,
202.6
},
// -3.8198374024},
{
13.6
,
3.5
,
83.4
}};
// -2.4491867448}};
if
(
umPerTurn
!=
null
)
for
(
int
i
=
0
;
i
<
umPerTurn
.
length
;
i
++)
screws
[
i
][
2
]=
umPerTurn
[
i
];
double
[]
moveDownUm
=
new
double
[
screws
.
length
];
double
[]
turnCW
=
new
double
[
screws
.
length
];
for
(
int
i
=
0
;
i
<
screws
.
length
;
i
++){
moveDownUm
[
i
]=
zErr
+
screws
[
i
][
0
]*
tXErr
+
screws
[
i
][
1
]*
tYErr
;
turnCW
[
i
]=
moveDownUm
[
i
]/
screws
[
i
][
2
];
}
return
turnCW
;
}
/*
*
192.8479341564
202.5779753086
83.4354504792
-2.908571735
-3.8198374024
-2.4491867448
*/
/**
* Calculate three linearized values of motor positions for current parameters, target center focal
* shift and tilt (from the optic axis)
...
...
src/main/java/LensAdjustment.java
View file @
12670bc5
...
...
@@ -255,18 +255,18 @@ public class LensAdjustment {
// when approximating PSF with a second degree polynomial:
public
double
psf_cutoffEnergy
=
0.98
;
//0.5; // disregard pixels outside of this fraction of the total energy
public
double
psf_cutoffLevel
=
0.2
;
// disregard pixels below this fraction of the maximal value
public
int
psf_minArea
=
10
;
// continue increasing the selected area, even if beyo
u
nd psf_cutoffEnergy and psf_cutoffLevel,
// if the selected area is smaller than this (so approximation w
p
uld work)
public
int
psf_minArea
=
10
;
// continue increasing the selected area, even if beyond psf_cutoffEnergy and psf_cutoffLevel,
// if the selected area is smaller than this (so approximation w
o
uld work)
public
double
psf_blurSigma
=
0.0
;
// optionally blur the calculated mask
public
double
weightRatioRedToGreen
=
0.7
;
// Use this data when combining defocusing data from different color PSF
public
double
weightRatioBlueToGreen
=
0.
3
;
public
double
targetFarNear
=
0.0
;
// OBSOLETE target logari
p
hm of average tangential-to-radial resolution
public
double
weightRatioBlueToGreen
=
0.
2
;
public
double
targetFarNear
=
0.0
;
// OBSOLETE target logari
t
hm of average tangential-to-radial resolution
public
boolean
useRadialTangential
=
false
;
// Use targetFarNear (radial/tangential resolution) as a proxy for the distance
public
double
targetMicrons
=
0.0
;
// target lens center distance (away from "best focus"
public
double
toleranceMicrons
=
0.5
;
// microns
public
double
toleranceTilt
=
0.02
;
//
public
double
toleranceThreshold
=
3.0
;
// When each error is under s
wcaled thereshold, reduce correx
ction step twice
public
double
toleranceThreshold
=
3.0
;
// When each error is under s
caled threshold, reduce corre
ction step twice
// public boolean parallelAdjust=true; // move 3 motors parallel after each 3-motor focus/tilt adjustment
public
double
parallelAdjustThreshold
=
4.0
;
// adjust 3 motors parallel if focal distance error in the center exceeds this
...
...
@@ -353,7 +353,7 @@ public class LensAdjustment {
public
int
subdiv
=
4
;
// overwrites public static class MultiFilePSF.overexposedMaxFraction
public
double
overexposedMaxFraction
=
0.1
;
// allowed fraction of the overexposed pixels in the PSF kernel measurement area
// overw
i
rites public static class PSFParameters.minDefinedArea
// overwrites public static class PSFParameters.minDefinedArea
public
double
minDefinedArea
=
0.75
;
// minimal (weighted) fraction of the defined patter pixels in the FFT area
public
int
PSFKernelSize
=
32
;
// size of the detected PSF kernel
public
boolean
approximateGrid
=
true
;
// approximate grid with polynomial
...
...
@@ -375,6 +375,7 @@ public class LensAdjustment {
public
double
correlationMinAbsoluteContrast
=
0.5
;
// minimal contrast for the pattern to pass, does not compensate for low ligt
public
double
correlationMinAbsoluteInitialContrast
=
0.5
;
// minimal contrast for the pattern of the center (initial point)
public
double
[]
postUVscrewSensitivity
={-
2.908571735
,-
3.8198374024
,-
2.4491867448
};
public
boolean
flatFieldCorrection
=
true
;
public
double
flatFieldExpand
=
4.0
;
...
...
@@ -597,6 +598,7 @@ public class LensAdjustment {
double
correlationMinInitialContrast
,
// minimal contrast for the pattern of the center (initial point)
double
correlationMinAbsoluteContrast
,
// minimal contrast for the pattern to pass, does not compensate for low ligt
double
correlationMinAbsoluteInitialContrast
,
// minimal contrast for the pattern of the center (initial point)
double
[]
postUVscrewSensitivity
,
// microns/turn for 3 post-UV fixture adjustment screws
boolean
flatFieldCorrection
,
double
flatFieldExpand
,
double
thresholdFinish
,
// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
...
...
@@ -752,6 +754,7 @@ public class LensAdjustment {
this
.
correlationMinInitialContrast
=
correlationMinInitialContrast
;
// minimal contrast for the pattern of the center (initial point)
this
.
correlationMinAbsoluteContrast
=
correlationMinAbsoluteContrast
;
// minimal contrast for the pattern to pass, does not compensate for low ligt
this
.
correlationMinAbsoluteInitialContrast
=
correlationMinAbsoluteInitialContrast
;
// minimal contrast for the pattern of the center (initial point)
this
.
postUVscrewSensitivity
=
postUVscrewSensitivity
.
clone
();
// microns/turn for 3 post-UV fixture adjustment screws
this
.
flatFieldCorrection
=
flatFieldCorrection
;
this
.
flatFieldExpand
=
flatFieldExpand
;
this
.
thresholdFinish
=
thresholdFinish
;
// (copied from series) stop iterations if 2 last steps had less improvement (but not worsening )
...
...
@@ -910,6 +913,7 @@ public class LensAdjustment {
this
.
correlationMinInitialContrast
,
this
.
correlationMinAbsoluteContrast
,
this
.
correlationMinAbsoluteInitialContrast
,
this
.
postUVscrewSensitivity
,
this
.
flatFieldCorrection
,
this
.
flatFieldExpand
,
this
.
thresholdFinish
,
...
...
@@ -1078,7 +1082,9 @@ public class LensAdjustment {
properties
.
setProperty
(
prefix
+
"correlationMinInitialContrast"
,
this
.
correlationMinInitialContrast
+
""
);
properties
.
setProperty
(
prefix
+
"correlationMinAbsoluteContrast"
,
this
.
correlationMinAbsoluteContrast
+
""
);
properties
.
setProperty
(
prefix
+
"correlationMinAbsoluteInitialContrast"
,
this
.
correlationMinAbsoluteInitialContrast
+
""
);
for
(
int
i
=
0
;
i
<
this
.
postUVscrewSensitivity
.
length
;
i
++){
properties
.
setProperty
(
prefix
+
"postUVscrewSensitivity_"
+
i
,
this
.
postUVscrewSensitivity
[
i
]+
""
);
}
properties
.
setProperty
(
prefix
+
"flatFieldCorrection"
,
this
.
flatFieldCorrection
+
""
);
properties
.
setProperty
(
prefix
+
"flatFieldExpand"
,
this
.
flatFieldExpand
+
""
);
properties
.
setProperty
(
prefix
+
"thresholdFinish"
,
this
.
thresholdFinish
+
""
);
...
...
@@ -1405,6 +1411,10 @@ public class LensAdjustment {
this
.
correlationMinAbsoluteContrast
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"correlationMinAbsoluteContrast"
));
if
(
properties
.
getProperty
(
prefix
+
"correlationMinAbsoluteInitialContrast"
)!=
null
)
this
.
correlationMinAbsoluteInitialContrast
=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"correlationMinAbsoluteInitialContrast"
));
for
(
int
i
=
0
;
i
<
this
.
postUVscrewSensitivity
.
length
;
i
++){
if
(
properties
.
getProperty
(
prefix
+
"postUVscrewSensitivity_"
+
i
)!=
null
)
this
.
postUVscrewSensitivity
[
i
]=
Double
.
parseDouble
(
properties
.
getProperty
(
prefix
+
"postUVscrewSensitivity_"
+
i
));
}
if
(
properties
.
getProperty
(
prefix
+
"flatFieldCorrection"
)!=
null
)
this
.
flatFieldCorrection
=
Boolean
.
parseBoolean
(
properties
.
getProperty
(
prefix
+
"flatFieldCorrection"
));
if
(
properties
.
getProperty
(
prefix
+
"flatFieldExpand"
)!=
null
)
...
...
@@ -1679,6 +1689,11 @@ public class LensAdjustment {
gd
.
addNumericField
(
"Expand during extrapolation (relative to the average grid period)"
,
this
.
flatFieldExpand
,
3
);
gd
.
addNumericField
(
"Threshold RMS to exit LMA"
,
this
.
thresholdFinish
,
7
,
9
,
"pix"
);
gd
.
addNumericField
(
"Maximal number of LMA iterations per series"
,
this
.
numIterations
,
0
);
gd
.
addMessage
(
"--- Post-UV fixture screws sensitivity ---"
);
for
(
int
i
=
0
;
i
<
this
.
postUVscrewSensitivity
.
length
;
i
++){
gd
.
addNumericField
(
"Screw "
+
i
+
" sensitivity"
,
this
.
postUVscrewSensitivity
[
i
],
4
,
6
,
"um/turn CW"
);
}
gd
.
addMessage
(
"-----"
);
gd
.
addNumericField
(
"Report focal length at this temperature"
,
this
.
reportTemperature
,
1
,
5
,
"C"
);
...
...
@@ -1869,6 +1884,9 @@ public class LensAdjustment {
this
.
flatFieldExpand
=
gd
.
getNextNumber
();
this
.
thresholdFinish
=
gd
.
getNextNumber
();
this
.
numIterations
=
(
int
)
gd
.
getNextNumber
();
for
(
int
i
=
0
;
i
<
this
.
postUVscrewSensitivity
.
length
;
i
++){
this
.
postUVscrewSensitivity
[
i
]=
gd
.
getNextNumber
();
}
this
.
reportTemperature
=
gd
.
getNextNumber
();
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment