Commit 1c0dccf4 authored by Aliaksandr Halavatyi's avatar Aliaksandr Halavatyi
Browse files

moved photomanipulation protocols to the dedicated repository

parent e5e3b66d
......@@ -8,7 +8,7 @@
<version>5.0</version> <relativePath /> </parent> -->
<groupId>embl.almf</groupId>
<artifactId>AutoMicTools_</artifactId>
<version>1.1.20-SNAPSHOT</version>
<version>1.1.21-SNAPSHOT</version>
<name>plugins/AutoMicTools_.jar</name>
<description>Collection of tools for automated (feedback) microscopy data acquisition and analysis</description>
......
package automic.online.jobdistributors;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobs.common.Job_AutofocusInit_ZenBlue;
import automic.online.jobs.common.Job_RecordFinish;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_ZenBlue_AF extends JobDistributor_Abstract implements PlugIn {
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_ZenBlue.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="X:\\group\\Aliaksandr\\test_Feedback_LSM900";
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_ZenBlue_AF.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;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobs.adaptors.Job_CecoglinkAdaptor;
import automic.online.jobs.common.Job_AutofocusInit_ZenBlue;
import automic.online.jobs.common.Job_RecordFinish;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_ZenBlue_AF_Photomanipulation_Cecog extends JobDistributor_Abstract implements PlugIn {
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_ZenBlue.class, "AF--", "AF", true);
super.addImageJob(Job_CecoglinkAdaptor.class, "Selection--", "Selection", true);
super.addImageJob(Job_RecordFinish.class, "PA--", "PA", true);
}
@Override
protected TableModel constructTabModel(String _rpth){
TableModel outTbl=new TableModel(_rpth);
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("Selection", "IMG");
outTbl.addFileColumns("PA", "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="X:\\group\\ALMFstuff\\Aliaksandr\\test_Feedback_LSM900_Sanjana";
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_ZenBlue_AF_Photomanipulation_Cecog.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;
import ij.IJ;
import ij.ImageJ;
import ij.gui.GenericDialog;
import ij.plugin.PlugIn;
import automic.online.jobs.common.Job_AutofocusInit_ZenBlue;
import automic.online.jobs.common.Job_RecordFinish;
import automic.online.jobs.frap.Job_GetMultipleManualBleachRois_ZenBlue;
import automic.table.TableModel;
import automic.table.TableProcessor;
public class JobDistributor_ZenBlue_AF_Photomanipulation_Manual extends JobDistributor_Abstract implements PlugIn {
@Override
protected void fillJobList(){
super.addImageJob(Job_AutofocusInit_ZenBlue.class, "AF--", "AF", true);
super.addImageJob(Job_GetMultipleManualBleachRois_ZenBlue.class, "Selection--", "Selection", true);
super.addImageJob(Job_RecordFinish.class, "PA--", "PA", true);
}
@Override
protected TableModel constructTabModel(String _rpth){
TableModel outTbl=new TableModel(_rpth);
outTbl.addColumn("Date.Time");
outTbl.addFileColumns("AF", "IMG");
outTbl.addFileColumns("Selection", "IMG");
outTbl.addFileColumns("PA", "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_ZenBlue_AF_Photomanipulation_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.jobs.frap;
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.online.microscope.ZeissLSM800;
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_GetMultipleManualBleachRois_ZenBlue 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="Bleacing 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";
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;
}
}
*/
class SelectionManadgement{//singleton class to manage multiple seletions
public List<Roi> selectedRegions;
double[] xPositions;
double[] yPositions;
double[] radiusValues;
public SelectionManadgement() {
selectedRegions=new ArrayList<Roi>();
}
public void removeLasetSelectedRoi() {
int nRegionsOld=selectedRegions.size();
if (nRegionsOld<1)
return;
selectedRegions.remove(nRegionsOld-1);
}
public void updateCommandArrays(){
xPositions=new double[selectedRegions.size()];
yPositions=new double[selectedRegions.size()];
radiusValues=new double[selectedRegions.size()];
for (int iRoi=0;iRoi<selectedRegions.size();iRoi++){
Rectangle bounds=selectedRegions.get(iRoi).getBounds();
xPositions[iRoi]=bounds.getCenterX();
yPositions[iRoi]=bounds.getCenterY();
radiusValues[iRoi]=bleachRadius;
}
}
public void updateSelectionDisplay() {
Overlay o=createOverlay();
inImg.setOverlay(o);
IJ.log(String.format("%d ROIs are currently selected",selectedRoiManager.selectedRegions.size()));
}
}
class BleachMouseListener implements MouseListener{
//MouseListener methods
@Override
public void mouseClicked(MouseEvent e) {}
@Override
public void mousePressed(MouseEvent e) {}
@Override
public void mouseReleased(MouseEvent e) {
if (canMoveRoi)
return;
catchSelectedRoi(inImg);
}
@Override
public void mouseEntered(MouseEvent e) {}
@Override
public void mouseExited(MouseEvent e) {}
}
class BleachKeyboardListener implements KeyListener{
//KeyListener methods
@Override
public void keyPressed(KeyEvent e) {
int keyCode=e.getKeyCode();
switch(keyCode) {
case KeyEvent.VK_LEFT: //react on left arrow Key
//remove last selected region
selectedRoiManager.removeLasetSelectedRoi();
selectedRoiManager.updateSelectionDisplay();
break;
case KeyEvent.VK_RIGHT: //react on right arrow Key
//confirm region selection in case of "Can move Roi" mode
if (!canMoveRoi)
return;
catchSelectedRoi(inImg);
break;
default:return;
}
}
@Override
public void keyReleased(KeyEvent e) {}
@Override
public void keyTyped(KeyEvent e) {}
}
protected void catchSelectedRoi(ImagePlus _img) {
Roi selectedRoi=_img.getRoi();
if (selectedRoi==null)
return;
// check if ROI drawing is completed
if(selectedRoi.getState()!=Roi.NORMAL)