Commit 8a937c46 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

debugging visualisations for manual selection protocol

parent d56c0795
......@@ -21,6 +21,7 @@ import ij.gui.Line;
import ij.gui.Overlay;
import ij.gui.PointRoi;
import ij.gui.Roi;
import ij.measure.Calibration;
import ij.plugin.Duplicator;
import ij.plugin.frame.RoiManager;
import ij.process.ImageProcessor;
......@@ -86,7 +87,7 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
String saveLzRoiFolder=new File(rootPath,"Selected.Embryo.LZ").getAbsolutePath();
String saveLzRoiBasename=String.format("Embryo_%s_%05d",FileUtils.cutExtension(newImgFile.getName()),zoomCounter);
ROIManipulator2D.saveRoiToFile(saveLzRoiFolder, saveLzRoiBasename, lzPointRoi);
experimentTable.setFileAbsolutePath(saveLzRoiFolder, saveLzRoiBasename, tableRowCounter, "Selected.Embryo.LZ", "ROI");
experimentTable.setFileAbsolutePath(saveLzRoiFolder, saveLzRoiBasename+".zip", tableRowCounter, "Selected.Embryo.LZ", "ROI");
experimentTable.writeNewFile("summary_"+Exper_nm+".txt", true);
......@@ -148,6 +149,7 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
return false;
embyroRoi=ROIManipulator2D.selBiggestRoi(selectedSlice, candidateRois);
selectedSlice.setRoi(embyroRoi);
selectedSlice.setCalibration(new Calibration());
ImageStatistics sliceStatistics=selectedSlice.getStatistics(/*ImageStatistics.CENTER_OF_MASS|*/ImageStatistics.ELLIPSE);
rotation=sliceStatistics.angle;
halfLength=sliceStatistics.major/2.0;
......@@ -189,7 +191,23 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
@Override
protected Overlay createOverlay(){
return new Overlay();
Overlay o=new Overlay();
if (embyroRoi==null)
return o;
embyroRoi.setStrokeColor(Color.ORANGE);
o.add(embyroRoi);
Roi pointRoi=new PointRoi(selectedXPosition, selectedYPosition);
pointRoi.setPosition(selectedZPosition);
o.add(pointRoi);
Double angleRadians=rotation/180*Math.PI;
Roi lineRoi=new Line(selectedXPosition, selectedYPosition, selectedXPosition+halfLength*Math.cos(angleRadians), selectedYPosition-halfLength*Math.sin(angleRadians));
lineRoi.setStrokeColor(Color.PINK);
o.add(lineRoi);
return o;
}
@Override
......@@ -230,23 +248,7 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
experimentTable.writeNewFile("summary_"+Exper_nm+".txt", true);
embyroRoi.setStrokeColor(Color.ORANGE);
Roi pointRoi=new PointRoi(selectedXPosition, selectedYPosition);
pointRoi.setPosition(0, selectedZPosition, 0);
Double angleRadians=rotation/180*Math.PI;
Roi lineRoi=new Line(selectedXPosition, selectedYPosition, selectedXPosition+halfLength*Math.cos(angleRadians), selectedYPosition*Math.sin(angleRadians));
lineRoi.setStrokeColor(Color.PINK);
saveRoisForImage(newImgFile,new Roi[] {embyroRoi,pointRoi});
// 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);
saveRoisForImage(newImgFile,getOverlay().toArray());
}
......@@ -264,6 +266,15 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
experimentTable.setBooleanValue(false, tableRowCounter, "Success");
experimentTable.writeNewFile("summary_"+Exper_nm+".txt", true);
}
protected void postProcessOffline(){
try {
this.showDebug(img, "Image with overlay", true,getOverlay());
}catch (Exception ex){
IJ.error("Error during offline visualisation");
}
}
@Override
......@@ -298,7 +309,7 @@ public class Job_FocusEmbryoAutoDataset extends Job_Default{
String tblFnm="summary_test8_m.txt";
Job_FocusEmbryoAutoDataset testJob=new Job_FocusEmbryoAutoDataset();
testJob.initialise(null, "Focus.Image", false);
testJob.testJobMicTable(0, tblPth, tblFnm);
testJob.testJobMicTable(1, tblPth, tblFnm);
}
}
......@@ -26,10 +26,15 @@ public class Job_SelectMultipleEmbryosManual3D extends Job_Default{
private String KEY_SCREEN_POSITION_MANUAL_SELECTION_X="Screen position X";
private String KEY_SCREEN_POSITION_MANUAL_SELECTION_Y="Screen position Y";
private String KEY_WAIT_IMAGE_OPENING="Wait for image opening (milliseconds)";
private String KEY_CHANNEL_COLORS="Channel colors";
private int screenPositionX=100;
private int screenPositionY=100;
private int imageOpeningTimeDelay=2000;
private String[] channelColors= new String[]{"Green","Grays"};
private ImagePlus img=null;
......@@ -56,13 +61,18 @@ public class Job_SelectMultipleEmbryosManual3D extends Job_Default{
Exper_nm=Exper_nm.substring(0, Exper_nm.indexOf(fileTag));
this.setSharedValue("Experiment Name", Exper_nm);
TimeUnit.MILLISECONDS.sleep(2000);
TimeUnit.MILLISECONDS.sleep(imageOpeningTimeDelay);
img=openSelectedSlices(newImgFile);
if(channelColors.length!=img.getNChannels())
throw new Exception("Unexpected number of channels");
}
@Override
protected void preProcessOffline()throws Exception{
img=openSelectedSlices(currentTable.getFile(curDInd, imgColumnNm, "IMG"));
if(channelColors.length!=img.getNChannels())
throw new Exception("Unexpected number of channels");
}
......@@ -76,6 +86,10 @@ public class Job_SelectMultipleEmbryosManual3D extends Job_Default{
@Override
protected boolean runProcessing()throws Exception{
img.setDisplayMode(IJ.COMPOSITE);
for (int iChannels=0;iChannels<img.getNChannels();iChannels++) {
img.setC(iChannels+1);
IJ.run(img, channelColors[iChannels], "");
}
ImageWindow.setNextLocation(screenPositionX, screenPositionY);
RoiManager rm=ROIManipulator2D.getEmptyRm();
......@@ -164,7 +178,10 @@ public class Job_SelectMultipleEmbryosManual3D extends Job_Default{
ParameterCollection jobCollection=new ParameterCollection();
jobCollection.addParameter(KEY_SCREEN_POSITION_MANUAL_SELECTION_X, null, screenPositionX, ParameterType.INT_PARAMETER);
jobCollection.addParameter(KEY_SCREEN_POSITION_MANUAL_SELECTION_Y, null, screenPositionY, ParameterType.INT_PARAMETER);
jobCollection.addParameter(KEY_WAIT_IMAGE_OPENING, null, imageOpeningTimeDelay,ParameterType.INT_PARAMETER);
jobCollection.addArrayParameter(KEY_CHANNEL_COLORS, null, channelColors, ParameterType.STRING_PARAMETER);
return jobCollection;
}
......@@ -172,6 +189,8 @@ public class Job_SelectMultipleEmbryosManual3D extends Job_Default{
public void parseInputParameterValues(ParameterCollection _jobParameterCollection){
this.screenPositionX=(Integer)_jobParameterCollection.getParameterValue(KEY_SCREEN_POSITION_MANUAL_SELECTION_X);
this.screenPositionY=(Integer)_jobParameterCollection.getParameterValue(KEY_SCREEN_POSITION_MANUAL_SELECTION_Y);
this.imageOpeningTimeDelay= (Integer)_jobParameterCollection.getParameterValue(KEY_WAIT_IMAGE_OPENING);
this.channelColors=(String[])_jobParameterCollection.getParameterValue(KEY_CHANNEL_COLORS);
}
/**
......
Markdown is supported
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