...
 
Commits (3)
......@@ -23,15 +23,20 @@ import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import org.apache.log4j.Logger;
import ij.IJ;
import ij.ImagePlus;
import ij.gui.GenericDialog;
import mosaic.bregman.Parameters;
import mosaic.core.GUI.HelpGUI;
import mosaic.plugins.BregmanGLM_Batch.RunMode;
import mosaic.utils.ImgUtils;
public class GenericGUI {
private static final Logger logger = Logger.getLogger(GenericGUI.class);
// Input params
protected final Parameters iParameters;
protected ImagePlus iInputImage;
......@@ -39,11 +44,11 @@ public class GenericGUI {
private boolean iIsConfigReadFromArguments;
private String iInputField = "";
protected ImagePlus imgch2; // TODO: it is not used currently (never assigned)
public GenericGUI(ImagePlus aInputImg, boolean aUseGui, Parameters aParameters, boolean aIsConfigReadFromArguments) {
iParameters = aParameters;
iInputImage = aInputImg;
logger.info("GUI input image: " + (aInputImg == null ? "<nullImg>" : ImgUtils.getImageInfo(aInputImg)));
iUseGui = aUseGui;
iIsConfigReadFromArguments = aIsConfigReadFromArguments;
}
......@@ -95,7 +100,7 @@ public class GenericGUI {
addButton(p, "Options", new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
final ColocalizationGUI gds = new ColocalizationGUI(iInputImage, imgch2, iParameters);
final ColocalizationGUI gds = new ColocalizationGUI(iInputImage, iParameters);
gds.run();
}
});
......@@ -128,7 +133,7 @@ public class GenericGUI {
if (!iUseGui && !iIsConfigReadFromArguments) {
BackgroundSubGUI.getParameters(iParameters);
SegmentationGUI.getParameters(iParameters);
new ColocalizationGUI(iInputImage, imgch2, iParameters).run();
new ColocalizationGUI(iInputImage, iParameters).run();
VisualizationGUI.getParameters(iParameters);
}
iInputField = gd.getNextString();
......@@ -176,14 +181,11 @@ public class GenericGUI {
@Override
public void actionPerformed(ActionEvent e) {
// close previosuly opened images
if (iInputImage != null) {
iInputImage.close();
iInputImage = null;
}
if (imgch2 != null) {
imgch2.close();
imgch2 = null;
}// close previosuly opened images
final JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
......
......@@ -39,7 +39,7 @@ public class Mask {
double minNorm = iGlobalMin;
double maxNorm = iGlobalMax;
if (iGlobalMax == 0) {
MinMax<Double> mm = ImgUtils.findMinMax(aImage);
MinMax<Double> mm = ImgUtils.findMinMax(aImage, 1, 1);
minNorm = mm.getMin();
maxNorm = mm.getMax();
}
......@@ -47,7 +47,7 @@ public class Mask {
}
private boolean[][][] generateMask(final ImagePlus aImage, double aNormalizationMin, double aNormalizationMax, double aMaskThreshold) {
ImagePlus mask = Mask.createBinaryCellMask(aImage, "Cell mask", aMaskThreshold * (aNormalizationMax - aNormalizationMin) + aNormalizationMin);
ImagePlus mask = Mask.createBinaryCellMask(aImage, "Cell mask", aMaskThreshold * (aNormalizationMax - aNormalizationMin) + aNormalizationMin, 1);
return ImgUtils.imgToZXYbinaryArray(mask);
}
......@@ -97,13 +97,13 @@ public class Mask {
return ((inside / size) > InsideThreshold);
}
public static ImagePlus createBinaryCellMask(ImagePlus aInputImage, String aTitle, double aThreshold) {
public static ImagePlus createBinaryCellMask(ImagePlus aInputImage, String aTitle, double aThreshold, int aChannel) {
int ni = aInputImage.getWidth();
int nj = aInputImage.getHeight();
int nz = aInputImage.getNSlices();
final ImageStack maskStack = new ImageStack(ni, nj);
for (int z = 0; z < nz; z++) {
aInputImage.setSlice(z + 1);
aInputImage.setPosition(aChannel, z, 1);
ImageProcessor ip = aInputImage.getProcessor();
final byte[] mask = new byte[ni * nj];
for (int i = 0; i < ni; i++) {
......
......@@ -6,7 +6,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
......@@ -47,7 +46,7 @@ public class RScript {
* -----------------------------------------------------------------------------------------
*/
public static void makeRScript(String path, String aObjectsDataFile, String aObjectsColocFile, String aImagesColocFile, List<ChannelPair> aChannelPairs, int[] ImagesPerGroup, String[] GroupNames, String Ch1Name, String Ch2Name) {
logger.info("Generateing Rscript with path=[" + path + "] aObjectsDataFile=[" + aObjectsDataFile + "] aObjectsColocFile=[" + aObjectsColocFile + "] aImagesColocFile=[" + aImagesColocFile + "] aChannelPairs=[" + aChannelPairs + "] ImagesPerGroup=[" + Debug.getString(ImagesPerGroup) + "] GroupNames=[" + Debug.getString(GroupNames) + "] Ch1Name=[" + Ch1Name + "] Ch2Name=[" + Ch2Name + "]");
logger.info("Generateing Rscript with path=[" + path + "] aObjectsDataFile=[" + aObjectsDataFile + "] aObjectsColocFile=[" + aObjectsColocFile + "] aImagesColocFile=[" + aImagesColocFile + "] aChannelPairs=[" + aChannelPairs + "] ImagesPerGroup=[" + Debug.getString(ImagesPerGroup) + "] GroupNames=[" + Debug.getString((Object[])GroupNames) + "] Ch1Name=[" + Ch1Name + "] Ch2Name=[" + Ch2Name + "]");
try {
PrintWriter Script = new PrintWriter(path + File.separator + ScriptName);
......
......@@ -31,12 +31,12 @@ class SamplePearsonCorrelationCoefficient {
iImageA = new double[iDepth][iWidth][iHeight];
double maxA = initImageAndGetMax(aImgA, iImageA);
double tx = aMaskImgA ? aMaskThresholdA * maxA : -1;
iMaskA = ImgUtils.imgToZXYbinaryArray(Mask.createBinaryCellMask(aImgA, "Channel1", tx));
iMaskA = ImgUtils.imgToZXYbinaryArray(Mask.createBinaryCellMask(aImgA, "Channel1", tx, 1));
iImageB = new double[iDepth][iWidth][iHeight];
double maxB = initImageAndGetMax(aImgB, iImageB);
double ty = aMaskImgB ? aMaskThresholdB * maxB : -1;
iMaskB = ImgUtils.imgToZXYbinaryArray(Mask.createBinaryCellMask(aImgB, "Channel2", ty));
iMaskB = ImgUtils.imgToZXYbinaryArray(Mask.createBinaryCellMask(aImgB, "Channel2", ty, 1));
}
/**
......
......@@ -387,7 +387,7 @@ public class SquasshLauncher {
double max = iGlobalNormalizationMax;
logger.info("Global min/max: " + min + "/" + max);
if (iGlobalNormalizationMax == 0) {
MinMax<Double> mm = ImgUtils.findMinMax(img);
MinMax<Double> mm = ImgUtils.findMinMax(img, 1, 1);
min = mm.getMin();
max = mm.getMax();
logger.info("Global min/max from image: " + min + "/" + max);
......
......@@ -402,7 +402,7 @@ public class ImgUtils {
return aImg.factory().create(dims, aImg.firstElement().copy());
}
public static MinMax<Double> findMinMax(ImagePlus img) {
public static MinMax<Double> findMinMax(ImagePlus img, int channel, int frame) {
int ni = img.getWidth();
int nj = img.getHeight();
int nz = img.getNSlices();
......@@ -410,7 +410,7 @@ public class ImgUtils {
double max = -Double.MAX_VALUE;
for (int z = 0; z < nz; z++) {
img.setSlice(z + 1);
img.setPosition(channel, z + 1, frame);
ImageProcessor imp = img.getProcessor();
for (int i = 0; i < ni; i++) {
for (int j = 0; j < nj; j++) {
......
package mosaic.bregman;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -14,8 +15,9 @@ import mosaic.bregman.ColocalizationAnalysis.ColocResult;
import mosaic.bregman.ColocalizationAnalysis.RegionColoc;
import mosaic.bregman.segmentation.Pix;
import mosaic.bregman.segmentation.Region;
import mosaic.test.framework.CommonBase;
public class ColocalizationAnalysisTest {
public class ColocalizationAnalysisTest extends CommonBase {
@Test
public void testSimpleTwoRegions() {
......@@ -85,4 +87,15 @@ public class ColocalizationAnalysisTest {
assertEquals(true, rc10.singleRegionColoc);
}
// @Test
// public void testGUI() {
// ImagePlus iInputImage = loadImagePlus("/Users/gonciarz/1/3C.tif");
// Parameters iParameters = new Parameters();
// iParameters.usecellmaskY=true;
// iParameters.thresholdcellmasky = 0.5;
// final ColocalizationGUI gds = new ColocalizationGUI(iInputImage, iParameters);
// gds.run();
// System.out.println(iParameters);
// }
}