Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Aliaksandr Halavatyi
AutoMicTools
Commits
f4ec0244
Commit
f4ec0244
authored
May 26, 2021
by
Aliaksandr Halavatyi
Browse files
creating autofocus jobs for commander
parent
f31ddcd6
Changes
3
Hide whitespace changes
Inline
Side-by-side
pom.xml
View file @
f4ec0244
...
...
@@ -8,7 +8,7 @@
<version>5.0</version> <relativePath /> </parent> -->
<groupId>
embl.almf
</groupId>
<artifactId>
AutoMicTools_
</artifactId>
<version>
1.1.2
4
-SNAPSHOT
</version>
<version>
1.1.2
5
-SNAPSHOT
</version>
<name>
plugins/AutoMicTools_.jar
</name>
<description>
Collection of tools for automated (feedback) microscopy data acquisition and analysis
</description>
...
...
src/main/java/automic/online/jobs/common/Job_AutofocusInit_Commander.java
0 → 100644
View file @
f4ec0244
package
automic.online.jobs.common
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
import
automic.geom.Point3D
;
import
automic.online.jobs.Job_Default
;
import
automic.utils.imagefiles.ImageOpenerWithBioformats
;
import
automic.utils.roi.ROIManipulator2D
;
import
ij.ImageJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.gui.Line
;
import
ij.gui.Overlay
;
import
ij.gui.ProfilePlot
;
import
ij.gui.Roi
;
public
class
Job_AutofocusInit_Commander
extends
Job_Default
{
//private static final Roi nullRoi=null;
private
ImagePlus
img
=
null
;
int
maxind
=-
1
;
int
zSubmit
=-
1
;
Boolean
isLineScan
=
null
;
@Override
protected
void
cleanIterOutput
(){
img
=
null
;
isLineScan
=
null
;
}
@Override
protected
void
preProcessOnline
()
throws
Exception
{
super
.
clearSharedData
();
currentTable
.
cleanRecord
(
curDInd
);
//change the root path of the table to experiment folder
currentTable
.
setRootPath
(
newImgFile
.
getParentFile
().
getParent
());
//
currentTable
.
setFileAbsolutePath
(
newImgFile
,
curDInd
,
imgColumnNm
,
"IMG"
);
String
Exper_nm
=
newImgFile
.
getName
();
Exper_nm
=
Exper_nm
.
substring
(
0
,
Exper_nm
.
indexOf
(
fileTag
));
this
.
setSharedValue
(
"Experiment Name"
,
Exper_nm
);
TimeUnit
.
MILLISECONDS
.
sleep
(
1000
);
ImageOpenerWithBioformats
.
turnLineScans
=
true
;
img
=
ImageOpenerWithBioformats
.
openImage
(
newImgFile
);
isLineScan
=(
img
.
getNSlices
()==
1
);
}
@Override
protected
void
preProcessOffline
()
throws
Exception
{
//img=ImageOpenerWithBioformats.openImage(currentTable.getFile(curDInd, imgColumnNm, "IMG"));
ImageOpenerWithBioformats
.
turnLineScans
=
true
;
img
=
ImageOpenerWithBioformats
.
openImage
(
newImgFile
);
isLineScan
=(
img
.
getNSlices
()==
1
);
}
@Override
protected
boolean
runProcessing
()
throws
Exception
{
if
(
isLineScan
)
{
maxind
=
getFocusValueLine
(
img
);
zSubmit
=
img
.
getHeight
()-
maxind
-
1
;
}
else
{
maxind
=
getFocusValueFrameStack
(
img
);
zSubmit
=
maxind
;
}
return
true
;
}
private
int
getFocusValueLine
(
ImagePlus
_image
)
{
//find focus and send to the microscope macro
_image
.
setRoi
(
0
,
0
,
_image
.
getWidth
(),
_image
.
getHeight
());
double
[]
vals
=
new
ProfilePlot
(
_image
,
true
).
getProfile
();
_image
.
setRoi
((
Roi
)
null
);
int
npoints
=
vals
.
length
;
double
maxv
=
0
;
int
max_id
=-
1
;
for
(
int
i
=
0
;
i
<
npoints
;
i
++){
if
(
vals
[
i
]>
maxv
){
max_id
=
i
;
maxv
=
vals
[
i
];
}
}
return
max_id
;
}
private
int
getFocusValueFrameStack
(
ImagePlus
_image
)
{
//find focus and send to the microscope macro
_image
.
setRoi
((
Roi
)
null
);
double
maxv
=
0
;
int
max_id
=-
1
;
ImageStack
stack
=
img
.
getStack
();
int
nSlices
=
stack
.
getSize
();
double
currentValue
;
for
(
int
i
=
0
;
i
<
nSlices
;
i
++){
currentValue
=
stack
.
getProcessor
(
i
+
1
).
getStatistics
().
mean
;
if
(
currentValue
>
maxv
){
max_id
=
i
;
maxv
=
currentValue
;
}
}
return
max_id
;
}
@Override
protected
Overlay
createOverlay
(){
Overlay
o
=
new
Overlay
();
if
(
isLineScan
&&(
maxind
>
0
))
o
.
add
(
new
Line
(
0
,
maxind
,
img
.
getWidth
()-
1
,
maxind
));
return
o
;
}
@Override
public
void
visualise
(
int
_xvis
,
int
_yvis
){
this
.
visualiseImg
(
img
,
getOverlay
(),
_xvis
,
_yvis
);
if
((!
isLineScan
)
&&
(
maxind
>
0
))
{
img
.
setSlice
(
maxind
);
}
}
@Override
public
void
postProcessSuccess
()
throws
Exception
{
this
.
microscopeCommander
.
submitJobPixels
(
newImgFile
,
"spindle-LZ"
,
new
Point3D
(
null
,
null
,(
double
)
zSubmit
));
Roi
[]
rs
=
getOverlay
().
toArray
();
if
(!
ROIManipulator2D
.
isEmptyRoiArr
(
rs
))
saveRoisForImage
(
newImgFile
,
rs
);
}
@Override
public
void
postProcessOffline
()
throws
Exception
{
this
.
microscopeCommander
.
submitJobPixels
(
newImgFile
,
"spindle-LZ"
,
new
Point3D
(
null
,
null
,(
double
)
zSubmit
));
Roi
[]
rs
=
getOverlay
().
toArray
();
if
(!
ROIManipulator2D
.
isEmptyRoiArr
(
rs
))
saveRoisForImage
(
newImgFile
,
rs
);
this
.
visualise
(
1000
,
100
);
}
/**
* offline debugging
* @param args unsused
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// start ImageJ
new
ImageJ
();
Job_AutofocusInit_Commander
testJob
=
new
Job_AutofocusInit_Commander
();
testJob
.
initialise
(
null
,
"AFocus"
,
false
);
testJob
.
testImageFile
(
new
File
(
"X:\\group\\Aliaksandr\\User_data\\Marco_Cosenza\\test-AF-update\\AF--W0000--P0001-T0001.czi"
));
//testJob.testJobMicTable(0, tblPth, tblFnm);
}
}
src/main/java/automic/online/jobs/common/Job_Autofocus_Commander.java
0 → 100644
View file @
f4ec0244
package
automic.online.jobs.common
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
import
automic.geom.Point3D
;
import
automic.online.jobs.Job_Default
;
import
automic.utils.imagefiles.ImageOpenerWithBioformats
;
import
automic.utils.roi.ROIManipulator2D
;
import
ij.ImageJ
;
import
ij.ImagePlus
;
import
ij.ImageStack
;
import
ij.gui.Overlay
;
import
ij.gui.Roi
;
public
class
Job_Autofocus_Commander
extends
Job_Default
{
//private static final Roi nullRoi=null;
private
ImagePlus
img
=
null
;
int
maxind
=-
1
;
Roi
ln
=
null
;
@Override
protected
void
cleanIterOutput
(){
img
=
null
;
ln
=
null
;
}
@Override
protected
void
preProcessOnline
()
throws
Exception
{
super
.
clearSharedData
();
currentTable
.
setFileAbsolutePath
(
newImgFile
,
curDInd
,
imgColumnNm
,
"IMG"
);
String
Exper_nm
=
newImgFile
.
getName
();
Exper_nm
=
Exper_nm
.
substring
(
0
,
Exper_nm
.
indexOf
(
fileTag
));
this
.
setSharedValue
(
"Experiment Name"
,
Exper_nm
);
TimeUnit
.
MILLISECONDS
.
sleep
(
1000
);
img
=
ImageOpenerWithBioformats
.
openImage
(
newImgFile
);
}
@Override
protected
void
preProcessOffline
()
throws
Exception
{
//img=ImageOpenerWithBioformats.openImage(currentTable.getFile(curDInd, imgColumnNm, "IMG"));
img
=
ImageOpenerWithBioformats
.
openImage
(
newImgFile
);
}
@Override
protected
boolean
runProcessing
()
throws
Exception
{
//find focus and send to the microscope macro
//img.setRoi(0,0,img.getWidth(), img.getHeight());
//double [] vals=new ProfilePlot(img,true).getProfile();
//img.setRoi((Roi)null);
//int npoints=vals.length;
double
maxv
=
0
;
maxind
=-
1
;
ImageStack
stack
=
img
.
getStack
();
int
nSlices
=
stack
.
getSize
();
double
currentValue
;
for
(
int
i
=
0
;
i
<
nSlices
;
i
++){
currentValue
=
stack
.
getProcessor
(
i
+
1
).
getStatistics
().
mean
;
if
(
currentValue
>
maxv
){
maxind
=
i
;
maxv
=
currentValue
;
}
}
//ln=new Line(0,maxind,img.getWidth(),maxind);
//ln.setStrokeColor(Color.ORANGE);
return
true
;
}
@Override
protected
Overlay
createOverlay
(){
return
new
Overlay
();
}
@Override
public
void
visualise
(
int
_xvis
,
int
_yvis
){
this
.
visualiseImg
(
img
,
getOverlay
(),
_xvis
,
_yvis
);
if
(
maxind
>
0
)
img
.
setSlice
(
maxind
);
}
@Override
public
void
postProcessSuccess
()
throws
Exception
{
this
.
microscopeCommander
.
submitJobPixels
(
newImgFile
,
"spindle-LZ"
,
new
Point3D
(
null
,
null
,(
double
)
maxind
));
Roi
[]
rs
=
getOverlay
().
toArray
();
if
(!
ROIManipulator2D
.
isEmptyRoiArr
(
rs
))
saveRoisForImage
(
newImgFile
,
rs
);
}
@Override
public
void
postProcessOffline
()
throws
Exception
{
this
.
microscopeCommander
.
submitJobPixels
(
newImgFile
,
"spindle-LZ"
,
new
Point3D
(
null
,
null
,(
double
)
maxind
));
Roi
[]
rs
=
getOverlay
().
toArray
();
if
(!
ROIManipulator2D
.
isEmptyRoiArr
(
rs
))
saveRoisForImage
(
newImgFile
,
rs
);
}
/**
* offline debugging
* @param args unsused
*/
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// start ImageJ
new
ImageJ
();
Job_Autofocus_Commander
testJob
=
new
Job_Autofocus_Commander
();
testJob
.
initialise
(
null
,
"AFocus"
,
false
);
testJob
.
testImageFile
(
new
File
(
"W:\\halavaty\\Tobias-LSM800-data\\20190219-183148\\AF\\AF--W0000--P0001-T0001.czi"
));
//testJob.testJobMicTable(0, tblPth, tblFnm);
}
}
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