Commit 59b16f00 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

standand imaging workflows with commander

parent 05b869cc
......@@ -8,7 +8,7 @@
<version>5.0</version> <relativePath /> </parent> -->
<groupId>embl.almf</groupId>
<artifactId>AutoMicTools_</artifactId>
<version>1.1.32-SNAPSHOT</version>
<version>1.1.33-SNAPSHOT</version>
<name>plugins/AutoMicTools_.jar</name>
<description>Collection of tools for automated (feedback) microscopy data acquisition and analysis</description>
......
......@@ -4,14 +4,11 @@ package automic.online.jobdistributors;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.gui.WaitForUserDialog;
import ij.plugin.PlugIn;
import automic.online.jobdistributors.JobDistributor_Abstract;
import automic.online.jobs.common.Job_AutofocusInitOffset;
import automic.online.jobs.common.Job_AutofocusInit_Commander;
import automic.online.jobs.common.Job_RecordFinish;
import automic.parameters.ParameterCollection;
import automic.parameters.gui.ParameterGuiManager;
import automic.table.TableModel;
import automic.table.TableProcessor;
......@@ -23,23 +20,9 @@ public class JobDistributor_AFocus_Offset extends JobDistributor_Abstract implem
@Override
protected void fillJobList(){
Job_AutofocusInitOffset job1=new Job_AutofocusInitOffset();
ParameterCollection job1Parameters=job1.createJobParameters();
job1Parameters.setUndefinedValuesFromDefaults();
ParameterGuiManager pgManager1=new ParameterGuiManager(job1Parameters);
try{
pgManager1.refineParametersViaDialog("Coverslip focusing");
}catch(Exception _ex){
new WaitForUserDialog("error in parameter values");
}
job1.parseInputParameterValues(pgManager1.getParameterCollection());
super.addImageJob(job1, "DE_1_", "AFocus", true);
super.addImageJob(Job_AutofocusInit_Commander.class, "DE_1_", "AF", true);
super.addImageJob(Job_RecordFinish.class, "DE_2_", "Result.Image", true);
}
@Override
......@@ -48,7 +31,7 @@ public class JobDistributor_AFocus_Offset extends JobDistributor_Abstract implem
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AFocus", "IMG");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("Result.Image", "IMG");
outTbl.addValueColumn("Success", "BOOL");
......
package automic.online.jobdistributors.commander.imaging;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobdistributors.JobDistributor_Abstract;
import automic.online.jobs.common.Job_AutofocusInit_Commander;
import automic.online.jobs.common.Job_RecordFinish;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_MicroscopeCommander_AF_LowZoom extends JobDistributor_Abstract implements PlugIn{
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_Commander.class, "AF--", "AF", true);
super.addImageJob(Job_RecordFinish.class, "LowZoom--", "LowZoom", true);
}
@Override
protected TableModel constructTabModel(String _rpth){
TableModel outTbl=new TableModel(_rpth);
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("LowZoom", "IMG");
outTbl.addValueColumn("Success", "BOOL");
outTbl.addRow(new Object[outTbl.getColumnCount()]);
return outTbl;
}
@Override
protected TableProcessor configureTableProcessor(TableModel _tModel)throws Exception{
TableProcessor tProcessor=new TableProcessor(_tModel);
return tProcessor;
}
@Override
protected void putProtocolPreferencesToDialog(GenericDialog _dialog){
}
@Override
protected void getProtocolPreferencesFromDialog(GenericDialog _dialog){
}
@Override
protected boolean showDialogInDebugRun(){
return false;
}
@Override
protected void setDebugConfiguration(){
final String searchPath="D:\\tempDat\\AutoMic-test";
this.setGeneralOptions(searchPath, true, false);
}
/**
* main method for debugging.
* Sets debug configuration via the method defined for each JobDistributor implementation
* Then executes JobDistributor
*
*/
public static void main(String[] args) {
// set the plugins.dir property to make the plugin appear in the Plugins menu
Class<?> clazz = JobDistributor_MicroscopeCommander_AF_LowZoom.class;
//String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
//String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
//System.setProperty("plugins.dir", pluginsDir);
// start ImageJ
new ImageJ();
//DEBUG=true;
//Debug.run(plugin, parameters);
//new WaitForUserDialog("test Maven project").show();
// run the plugin
//exrerimentFolderPath="D:/tempDat/AutoFRAP_test";
//showDemo=true;
//pnum=1;
//setDebugConfiguration();
//IJ.runPlugIn(clazz.getName(),"Debug run");
IJ.runPlugIn(clazz.getName(),"");
}
}
package automic.online.jobdistributors.commander.imaging;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobdistributors.JobDistributor_Abstract;
import automic.online.jobs.common.Job_AutofocusInit_Commander;
import automic.online.jobs.common.Job_GetMultipleImagingPositions_Manual_Commander;
import automic.online.jobs.common.Job_RecordFinish;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_MicroscopeCommander_AF_LowZoom_HighZoom_Manual extends JobDistributor_Abstract implements PlugIn{
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_Commander.class, "AF--", "AF", true);
super.addImageJob(Job_GetMultipleImagingPositions_Manual_Commander.class, "LowZoom--", "LowZoom", true);
super.addImageJob(Job_RecordFinish.class, "HighZoom--", "HighZoom",true);
}
@Override
protected TableModel constructTabModel(String _rpth){
TableModel outTbl=new TableModel(_rpth);
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("LowZoom", "IMG");
outTbl.addFileColumns("HighZoom", "IMG");
outTbl.addValueColumn("Success", "BOOL");
outTbl.addRow(new Object[outTbl.getColumnCount()]);
return outTbl;
}
@Override
protected TableProcessor configureTableProcessor(TableModel _tModel)throws Exception{
TableProcessor tProcessor=new TableProcessor(_tModel);
return tProcessor;
}
@Override
protected void putProtocolPreferencesToDialog(GenericDialog _dialog){
}
@Override
protected void getProtocolPreferencesFromDialog(GenericDialog _dialog){
}
@Override
protected boolean showDialogInDebugRun(){
return false;
}
@Override
protected void setDebugConfiguration(){
final String searchPath="D:\\tempDat\\AutoMic-test";
this.setGeneralOptions(searchPath, true, false);
}
/**
* main method for debugging.
* Sets debug configuration via the method defined for each JobDistributor implementation
* Then executes JobDistributor
*
*/
public static void main(String[] args) {
// set the plugins.dir property to make the plugin appear in the Plugins menu
Class<?> clazz = JobDistributor_MicroscopeCommander_AF_LowZoom_HighZoom_Manual.class;
//String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
//String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
//System.setProperty("plugins.dir", pluginsDir);
// start ImageJ
new ImageJ();
//DEBUG=true;
//Debug.run(plugin, parameters);
//new WaitForUserDialog("test Maven project").show();
// run the plugin
//exrerimentFolderPath="D:/tempDat/AutoFRAP_test";
//showDemo=true;
//pnum=1;
//setDebugConfiguration();
//IJ.runPlugIn(clazz.getName(),"Debug run");
IJ.runPlugIn(clazz.getName(),"");
}
}
package automic.online.jobdistributors.commander.imaging;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobdistributors.JobDistributor_Abstract;
import automic.online.jobs.common.Job_AutofocusInit_Commander;
import automic.online.jobs.common.Job_GetMultipleImagingPositions_Script_Commander;
import automic.online.jobs.common.Job_RecordFinish;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_MicroscopeCommander_AF_LowZoom_HighZoom_Script extends JobDistributor_Abstract implements PlugIn{
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_Commander.class, "AF--", "AF", true);
super.addImageJob(Job_GetMultipleImagingPositions_Script_Commander.class, "LowZoom--", "LowZoom", true);
super.addImageJob(Job_RecordFinish.class, "HighZoom--", "HighZoom",true);
}
@Override
protected TableModel constructTabModel(String _rpth){
TableModel outTbl=new TableModel(_rpth);
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("LowZoom", "IMG");
outTbl.addFileColumns("HighZoom", "IMG");
outTbl.addValueColumn("Success", "BOOL");
outTbl.addRow(new Object[outTbl.getColumnCount()]);
return outTbl;
}
@Override
protected TableProcessor configureTableProcessor(TableModel _tModel)throws Exception{
TableProcessor tProcessor=new TableProcessor(_tModel);
return tProcessor;
}
@Override
protected void putProtocolPreferencesToDialog(GenericDialog _dialog){
}
@Override
protected void getProtocolPreferencesFromDialog(GenericDialog _dialog){
}
@Override
protected boolean showDialogInDebugRun(){
return false;
}
@Override
protected void setDebugConfiguration(){
final String searchPath="D:\\tempDat\\AutoMic-test";
this.setGeneralOptions(searchPath, true, false);
}
/**
* main method for debugging.
* Sets debug configuration via the method defined for each JobDistributor implementation
* Then executes JobDistributor
*
*/
public static void main(String[] args) {
// set the plugins.dir property to make the plugin appear in the Plugins menu
Class<?> clazz = JobDistributor_MicroscopeCommander_AF_LowZoom_HighZoom_Script.class;
//String url = clazz.getResource("/" + clazz.getName().replace('.', '/') + ".class").toString();
//String pluginsDir = url.substring(5, url.length() - clazz.getName().length() - 6);
//System.setProperty("plugins.dir", pluginsDir);
// start ImageJ
new ImageJ();
//DEBUG=true;
//Debug.run(plugin, parameters);
//new WaitForUserDialog("test Maven project").show();
// run the plugin
//exrerimentFolderPath="D:/tempDat/AutoFRAP_test";
//showDemo=true;
//pnum=1;
//setDebugConfiguration();
//IJ.runPlugIn(clazz.getName(),"Debug run");
IJ.runPlugIn(clazz.getName(),"");
}
}
......@@ -5,6 +5,8 @@ import java.util.concurrent.TimeUnit;
import automic.geom.Point3D;
import automic.online.jobs.Job_Default;
import automic.parameters.ParameterCollection;
import automic.parameters.ParameterType;
import automic.utils.imagefiles.ImageOpenerWithBioformats;
import automic.utils.roi.ROIManipulator2D;
import ij.ImageJ;
......@@ -16,12 +18,18 @@ import ij.gui.ProfilePlot;
import ij.gui.Roi;
public class Job_AutofocusInit_Commander extends Job_Default{
public static final String KEY_FOCUS_SLICE_OFFSET="Slice offset";
//private static final Roi nullRoi=null;
private ImagePlus img=null;
int maxind=-1;
int zSubmit=-1;
Boolean isLineScan=null;
int sliceOffset=0;
@Override
protected void cleanIterOutput(){
img=null;
......@@ -135,6 +143,21 @@ public class Job_AutofocusInit_Commander extends Job_Default{
}
@Override
public ParameterCollection createJobParameters(){
ParameterCollection jobCollection=new ParameterCollection();
jobCollection.addParameter(KEY_FOCUS_SLICE_OFFSET, null, sliceOffset, ParameterType.INT_PARAMETER);
return jobCollection;
}
@Override
public void parseInputParameterValues(ParameterCollection _jobParameterCollection){
this.sliceOffset=(Integer)_jobParameterCollection.getParameterValue(KEY_FOCUS_SLICE_OFFSET);
}
@Override
public void postProcessSuccess()throws Exception{
this.microscopeCommander.submitJobPixels(newImgFile, "", new Point3D(null,null,(double)zSubmit));
......
package automic.online.jobs.common;
import java.awt.Color;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import automic.online.jobs.Job_Default;
import automic.parameters.ParameterCollection;
import automic.parameters.ParameterType;
import automic.utils.imagefiles.ImageOpenerWithBioformats;
import ij.IJ;
import ij.ImageJ;
import ij.ImagePlus;
import ij.gui.ImageCanvas;
import ij.gui.ImageWindow;
import ij.gui.OvalRoi;
import ij.gui.Overlay;
import ij.gui.Roi;
import ij.gui.Toolbar;
import loci.plugins.in.ImporterOptions;
import mcib3d.geom.Point3D;
public class Job_GetMultipleImagingPositions_Manual_Commander extends Job_Default{
public static final String INPUT_IMG_TAG="Selection";
//public static String FRAP_IMG_TAG="PA";
private boolean selectionMade=false;
public static final String KEY_LOCATION_X="Selection window location X";
public static final String KEY_LOCATION_Y="Selection window location Y";
public static final String KEY_RESPONCE_TIME="Time to wait for responce";
public static final String KEY_USE_ROIS_TIME_END="Proceed with selected ROIs if time expires";
public static final String KEY_CAN_MOVE_ROI="Can move Roi after drawing";
public static final String KEY_REGION_TYPE="Region type (circle, rectangle, polygon)";
//TODO: for now only "circle" is implemented in ZenBlue interface. Implement other shapes in future
public static final String KEY_BLEACH_RADIUS="Bleach radius for circle";
//region keys
public static final String CIRCLE_REGION="circle";
public static final String RECTANGLE_REGION="rectangle";
public static final String POLYGON_REGION="polygon";
private ImagePlus inImg;
Point3D selPoint;
private int initialLocationX=1000;
private int initialLocationY=120;
private int responceTime=30;
private boolean useRoisTimeEnd=true;
private boolean canMoveRoi=false;
private String regionType=CIRCLE_REGION;
private int bleachRadius=40;
//String xRoisString;
//String yRoisString;
SelectionManadgement selectedRoiManager;
/*
class RoiCommand{
private String xRoiString;
private String yRoiString;
public RoiCommand(Roi _selectedRoi) {
if(_selectedRoi.getType()!=getExpectedSelectionType())
throw new RuntimeException ("Region does not match specified type");
switch(regionType) {
case CIRCLE_REGION:
Polygon pointPolygon=_selectedRoi.getPolygon();
int selectedXPosition=pointPolygon.xpoints[0];
int selectedYPosition=pointPolygon.ypoints[0];
xRoiString=""+selectedXPosition+", "+(selectedXPosition+bleachRadius);
yRoiString=""+selectedYPosition+", "+(selectedYPosition);
break;
case RECTANGLE_REGION:
Rectangle bounds=_selectedRoi.getBounds();
xRoiString=""+bounds.x+", "+(bounds.x+bounds.width);
yRoiString=""+bounds.y+", "+(bounds.y+bounds.height);
break;
case POLYGON_REGION:
Polygon pointPolygon2=_selectedRoi.getPolygon();
int nPoints=pointPolygon2.npoints;
xRoiString="";
yRoiString="";
for (int iPoint=0;iPoint<nPoints;iPoint++) {
if(iPoint!=0) {
xRoiString+=", ";
yRoiString+=", ";
}
xRoiString+=pointPolygon2.xpoints[iPoint];
yRoiString+=pointPolygon2.ypoints[iPoint];
}
break;
default: throw new RuntimeException ("Region type specified wrongly");
}
}
public String getXRoiString() {
return xRoiString;
}
public String getYRoiString() {
return yRoiString;
}
}