-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tried to remove the edge gradient and started the library
- Loading branch information
1 parent
20f3d86
commit 93ef9c3
Showing
2 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
volker/toolsets/measure_intensity_without_spots/quantification.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
|
||
|
||
class StainingAnalyzer: | ||
|
||
|
||
def __init__(self, image, nucleiChannel, signalChannel): | ||
self.image = image | ||
self.nucleiChannel = nucleiChannel | ||
self.signalChannel = signalChannel | ||
self.nucleiMask = None | ||
self.spotsMask = None | ||
self.nucleiWithoutSpotsMask = None | ||
|
||
|
||
def createNucleiMask(self): | ||
currentChannel = self.image.getC() | ||
self.image.setC(self.nucleiChannel) | ||
method = self.getNucleiSegmentationMethod() | ||
method.run() | ||
self.nucleiMask = method.getResultMask() | ||
self.image.setC(currentChannel) | ||
|
||
|
||
def setMethod(self, method): | ||
self.method = method | ||
|
||
|
||
def getMethod(self): | ||
if not self.method: | ||
self.method = self.getDefaultNucleiSegmentationMethd() | ||
return self.method | ||
|
||
|
||
def getDefaultNucleiSegmentationMethd(self): | ||
currentChannel = self.image.getC() | ||
self.image.setC(self.nucleiChannel) | ||
method = SubtractGaussianAndThresholdSegmentation(self.image.getTitle(), self.image.getProcessor()) | ||
self.image.setC(currentChannel) | ||
|
||
|
||
|
||
def NucleiSegmentationMethod(): | ||
|
||
|
||
def __init__(self, title, processor): | ||
self.processor = processor | ||
self.resultMask = None | ||
self.title = "Mask of " + title | ||
|
||
|
||
def getOptions(self): | ||
return {} | ||
|
||
|
||
def getResultMask(self): | ||
return self.resultMask | ||
|
||
|
||
def run(self): | ||
pass | ||
|
||
|
||
|
||
class SubtractGaussianAndThresholdSegmentation(NucleiSegmentationMethod): | ||
|
||
|
||
def __init__(self, title, processor): | ||
super(SubtractGaussianAndThresholdSegmentation, self).__init__(title, processor) | ||
self.sigma = 40.86 | ||
|
||
|
||
def setSigma(self, sigma): | ||
"""Set the sigma of the Gaussian Blur Filter in physical units (for example micron). | ||
""" | ||
self.sigma = sigma | ||
|
||
|
||
def getSigma(self): | ||
return sigma | ||
|
||
|
||
def run(self): | ||
self.resultMask = ImagePlus("Mask of ", ) |
51 changes: 51 additions & 0 deletions
51
volker/toolsets/measure_intensity_without_spots/smooth_outer_gradient.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import java | ||
from ij import IJ | ||
from jarray import array | ||
|
||
def main(): | ||
STEP = 5 | ||
|
||
image = IJ.getImage() | ||
width, height, nChannels, nSlices, nFrames = image.getDimensions() | ||
found = True | ||
counter = 1 | ||
while found and counter < 11: | ||
print("processing iteration: ", counter) | ||
found = False | ||
processor = image.getProcessor() | ||
newProcessor = processor.duplicate() | ||
numberOfChanges = 0 | ||
for x in range(0, width): | ||
for y in range(0, height): | ||
value = processor.get(x, y) | ||
if value == 0: | ||
newValue = getMinAboveZeroInNeighborhood(x, y, processor) | ||
if newValue == 65536: | ||
continue | ||
newProcessor.set(x, y, int(max(newValue-STEP, 1))) | ||
found = True | ||
numberOfChanges = numberOfChanges + 1 | ||
print(str(numberOfChanges) + " pixels changed") | ||
image.setProcessor(newProcessor) | ||
counter = counter + 1 | ||
|
||
|
||
def getMinAboveZeroInNeighborhood(x, y, processor): | ||
imp = processor | ||
line1 = array([float(0.0), float(0.0) ,float(0.0)], 'd') | ||
line2 = array([float(0.0), float(0.0) ,float(0.0)], 'd') | ||
line3 = array([float(0.0), float(0.0) ,float(0.0)], 'd') | ||
neighbors = array([line1, line2, line3], java.lang.Class.forName("[D")) | ||
imp.getNeighborhood(x, y, neighbors) | ||
neighbors = list([list(line) for line in neighbors]) | ||
smallest = 65536 | ||
for line in neighbors: | ||
for element in line: | ||
if element == 0.0: | ||
continue | ||
if element < smallest: | ||
smallest = element | ||
return smallest | ||
|
||
|
||
main() |