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

debugging new embryo focus Job

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