Commit bed48c29 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

debugging new embryo focus Job

parent 52ff7b61
package feedback.fly.embryo.jobs; package feedback.fly.embryo.jobs;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.io.File; import java.io.File;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -9,13 +7,12 @@ import automic.online.microscope.ZeissKeys; ...@@ -9,13 +7,12 @@ import automic.online.microscope.ZeissKeys;
import automic.online.jobs.Job_Default; import automic.online.jobs.Job_Default;
import automic.parameters.ParameterCollection; import automic.parameters.ParameterCollection;
import automic.parameters.ParameterType; import automic.parameters.ParameterType;
import automic.utils.FileUtils; import automic.table.TableModel;
import ij.ImageJ; import ij.ImageJ;
import ij.ImagePlus; import ij.ImagePlus;
import ij.ImageStack; import ij.ImageStack;
import ij.gui.Overlay; import ij.gui.Overlay;
import ij.gui.PointRoi; import ij.plugin.Duplicator;
import ij.gui.Roi;
import ij.process.ImageProcessor; import ij.process.ImageProcessor;
import ij.process.ImageStatistics; import ij.process.ImageStatistics;
import loci.plugins.BF; import loci.plugins.BF;
...@@ -31,8 +28,8 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{ ...@@ -31,8 +28,8 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
//private static final Roi nullRoi=null; //private static final Roi nullRoi=null;
private ImagePlus img=null; private ImagePlus img=null;
private Integer selectedXPosition; private Double selectedXPosition;
private Integer selectedYPosition; private Double selectedYPosition;
private Integer selectedZPosition; private Integer selectedZPosition;
private Integer zSubmit; private Integer zSubmit;
...@@ -52,30 +49,26 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{ ...@@ -52,30 +49,26 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
@Override @Override
protected void preProcessOnline()throws Exception{ protected void preProcessOnline()throws Exception{
//super.clearSharedData(); int zoomCounter=(int)this.getSharedValue("Zoom Counter");
//currentTable.cleanRecord(curDInd); int tableRowCounter=(int)this.getSharedValue("Table Row Counter");
currentTable.setFileAbsolutePath(newImgFile, curDInd, imgColumnNm, "IMG"); zoomCounter++;
tableRowCounter++;
Integer zoomIndex=(Integer)getSharedValue("Zoom Counter"); String Exper_nm=(String)getSharedValue("Experiment Name");// newImgFile.getName();
zoomIndex++; File experimentTableFile=new File(currentTable.getRootPath(),"summary_"+Exper_nm+".txt");
setSharedValue("Zoom Counter",zoomIndex); TableModel experimentTable=new TableModel(experimentTableFile);
Point2D.Double[] zoompts=(Point2D.Double[])this.getSharedValue("Zoom Points"); while(experimentTable.getBooleanValue(tableRowCounter, "Success")==false) {
currentTable.setNumericValue(zoompts[zoomIndex].getX(), curDInd, "Zoom.X"); tableRowCounter++;
currentTable.setNumericValue(zoompts[zoomIndex].getY(), curDInd, "Zoom.Y"); }
Roi selectedEmbryoLZ=((Roi[])this.getSharedValue("Selected Embryo Rois"))[zoomIndex]; experimentTable.setFileAbsolutePath(newImgFile, tableRowCounter, imgColumnNm, "IMG");
selectedEmbryoLZ.setStrokeColor(Color.green);
currentTableProcessor.saveRoiToTable(curDInd, selectedEmbryoLZ, "Selected.Embryo.LZ", String.format("Embryo_%s_%05d",FileUtils.cutExtension(newImgFile.getName()),zoomIndex));
//String Exper_nm=newImgFile.getName();
//Exper_nm=Exper_nm.substring(0, Exper_nm.indexOf(fileTag));
//this.setSharedValue("Experiment Name", Exper_nm);
//img=ImageOpenerWithBioformats.openImage(newImgFile);
TimeUnit.MILLISECONDS.sleep(imageOpeningTimeDelay); TimeUnit.MILLISECONDS.sleep(imageOpeningTimeDelay);
img=openSelectedSlices(newImgFile); img=openSelectedSlices(newImgFile);
this.setSharedValue("Zoom Counter", zoomCounter);
this.setSharedValue("Table Row Counter", tableRowCounter);
} }
@Override @Override
...@@ -114,11 +107,17 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{ ...@@ -114,11 +107,17 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
if (selectedZPosition==null) return false; if (selectedZPosition==null) return false;
selectedZPosition+=focusOffset; selectedZPosition+=focusOffset;
//correct position
ImagePlus selectedSlice=new Duplicator().run(img, targetChannel, targetChannel, selectedZPosition, selectedZPosition, 1, 1);
ImageStatistics sliceStatistics=selectedSlice.getStatistics(ImageStatistics.CENTER_OF_MASS);
//invert zPosition if required //invert zPosition if required
zSubmit=selectedZPosition-1;//(invert_Z)?(nSlices-selectedZPosition):(selectedZPosition-1); zSubmit=selectedZPosition-1;//(invert_Z)?(nSlices-selectedZPosition):(selectedZPosition-1);
selectedXPosition=img.getWidth()/2-1; selectedXPosition=sliceStatistics.xCenterOfMass;
selectedYPosition=img.getHeight()/2-1; selectedYPosition=sliceStatistics.yCenterOfMass;
return true; return true;
...@@ -175,23 +174,29 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{ ...@@ -175,23 +174,29 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
ZeissKeys.submitCommandsToMicroscope("trigger2", ""+selectedXPosition,""+selectedYPosition,""+zSubmit,"","","","",""); ZeissKeys.submitCommandsToMicroscope("trigger2", ""+selectedXPosition,""+selectedYPosition,""+zSubmit,"","","","","");
Roi saveRoi=null; // Roi saveRoi=null;
if(selectedXPosition!=null && selectedYPosition!=null){ // if(selectedXPosition!=null && selectedYPosition!=null){
saveRoi=new PointRoi(selectedXPosition, selectedYPosition); // saveRoi=new PointRoi(selectedXPosition, selectedYPosition);
//saveRoi=new OvalRoi(selectedXPosition-3, selectedYPosition-3, 6, 6); // //saveRoi=new OvalRoi(selectedXPosition-3, selectedYPosition-3, 6, 6);
saveRoi.setPosition(0,selectedZPosition,0); // saveRoi.setPosition(0,selectedZPosition,0);
} // }
//
saveRoiForImage(newImgFile,saveRoi); // saveRoiForImage(newImgFile,saveRoi);
//
//currentTable.setNumericValue(selectedXPosition, curDInd, "Pos.X"); // //currentTable.setNumericValue(selectedXPosition, curDInd, "Pos.X");
//currentTable.setNumericValue(selectedYPosition, curDInd, "Pos.Y"); // //currentTable.setNumericValue(selectedYPosition, curDInd, "Pos.Y");
currentTable.setNumericValue(selectedZPosition, curDInd, "Focus.Z"); // currentTable.setNumericValue(selectedZPosition, curDInd, "Focus.Z");
//this.recordSummaryDataset(true); // //this.recordSummaryDataset(true);
} }
@Override
public void postProcessFail()throws Exception{
ZeissKeys.submitCommandsToMicroscope("nothing",null,null,null,null,null,null,null, "Suitable object is not found");
}
@Override @Override
public ParameterCollection createJobParameters(){ public ParameterCollection createJobParameters(){
ParameterCollection jobCollection=new ParameterCollection(); ParameterCollection jobCollection=new ParameterCollection();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment