Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Sbalzarini Lab
S
Software
Bio-Imaging
MosaicSuite
Commits
98f61e34
Commit
98f61e34
authored
Jul 31, 2019
by
Krzysztof Gonciarz
Browse files
Colocalization GUI cleaned up a little - now it is able to handle n-channels instead of fixed 2
parent
52bdd612
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/mosaic/bregman/GUI/ColocalizationGUI.java
View file @
98f61e34
This diff is collapsed.
Click to expand it.
src/main/java/mosaic/bregman/GUI/GenericGUI.java
View file @
98f61e34
...
...
@@ -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: "
+
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
);
...
...
src/main/java/mosaic/bregman/Mask.java
View file @
98f61e34
...
...
@@ -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
.
set
Slice
(
z
+
1
);
aInputImage
.
set
Position
(
aChannel
,
z
,
1
);
ImageProcessor
ip
=
aInputImage
.
getProcessor
();
final
byte
[]
mask
=
new
byte
[
ni
*
nj
];
for
(
int
i
=
0
;
i
<
ni
;
i
++)
{
...
...
src/main/java/mosaic/bregman/RScript.java
View file @
98f61e34
...
...
@@ -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
);
...
...
src/main/java/mosaic/bregman/SamplePearsonCorrelationCoefficient.java
View file @
98f61e34
...
...
@@ -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
));
}
/**
...
...
src/main/java/mosaic/bregman/SquasshLauncher.java
View file @
98f61e34
...
...
@@ -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
);
...
...
src/main/java/mosaic/utils/ImgUtils.java
View file @
98f61e34
...
...
@@ -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
.
set
Slice
(
z
+
1
);
img
.
set
Position
(
channel
,
z
+
1
,
frame
);
ImageProcessor
imp
=
img
.
getProcessor
();
for
(
int
i
=
0
;
i
<
ni
;
i
++)
{
for
(
int
j
=
0
;
j
<
nj
;
j
++)
{
...
...
src/test/java/mosaic/bregman/ColocalizationAnalysisTest.java
View file @
98f61e34
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
;
...
...
@@ -9,13 +10,16 @@ import java.util.Map;
import
org.junit.Test
;
import
ij.ImagePlus
;
import
mosaic.bregman.ColocalizationAnalysis.ChannelPair
;
import
mosaic.bregman.ColocalizationAnalysis.ColocResult
;
import
mosaic.bregman.ColocalizationAnalysis.RegionColoc
;
import
mosaic.bregman.GUI.ColocalizationGUI
;
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 +89,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
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment