Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import numpy as np
import cellprofiler.cpmodule as cpm
import cellprofiler.objects as cpo
import cellprofiler.preferences as cpprefs
import identify as I
import cellprofiler.settings as cps
from cellprofiler.cpmath.outline import outline
from cellprofiler.cpmath.cpmorphology import draw_line
from cellprofiler.cpmath.cpmorphology import fill_labeled_holes
TOOL_OUTLINE = "Outline"
TOOL_ZOOM_IN = "Zoom in"
TOOL_ERASE = "Erase"
class IdentifyObjectsManually(I.Identify):
category = "Object Processing"
module_name = "IdentifyObjectsManually"
variable_revision_number = 1
def create_settings(self):
self.image_name = cps.ImageNameSubscriber(
"Select the input image", "None",
doc = """Choose the name of the image to display in the object
selection user interface.""")
self.objects_name = cps.ObjectNameProvider(
"Name the objects to be identified", "Cells",
doc = """What do you want to call the objects
that you identify using this module? You can use this name to
refer to your objects in subsequent modules.""")
import cellprofiler.settings as cps
import identify as cpmi
import cellprofiler.cpmath.threshold as cpthresh
from cellprofiler.cpmath.propagate import propagate
from cellprofiler.cpmath.cpmorphology import fill_labeled_holes
from cellprofiler.cpmath.cpmorphology import fixup_scipy_ndimage_result as fix
from cellprofiler.cpmath.watershed import fast_watershed as watershed
from cellprofiler.cpmath.outline import outline
M_PROPAGATION = "Propagation"
M_WATERSHED_G = "Watershed"
M_WATERSHED_I = "Watershed - Image"
M_DISTANCE_N = "Distance - N"
M_DISTANCE_B = "Distance - B"
class IdentifySecondaryObjects(cpmi.Identify):
module_name = "IdentifySecondaryObjects"
variable_revision_number = 4
category = "Object Processing"
def create_settings(self):
self.primary_objects = cps.ObjectNameSubscriber("Select the input objects","Nuclei",doc="""
What did you call the objects you want to use as "seeds" to identify a secondary
object around each one? By definition, each primary object must be associated with exactly one
secondary object and completely contained within it.""")
self.objects_name = cps.ObjectNameProvider("Name the objects to be identified","Cells")
self.method = cps.Choice("Select the method to identify the secondary objects",
[M_PROPAGATION, M_WATERSHED_G, M_WATERSHED_I,
M_DISTANCE_N, M_DISTANCE_B],
# addresses and build a list of all the devices that reply
for ip in addresses:
if ip[0]==2: # IP v4
# create a socket
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0.5)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.bind((ip[4][0], 0))
s.sendto(request, ('255.255.255.255', 44818))
try:
while(1):
ret=s.recv(1024)
context=unpack_from('
import cellprofiler.objects as cpo
import cellprofiler.settings as cps
import cellprofiler.workspace as cpw
from cellprofiler.cpmath.outline import outline
import identify as I
###########################################
#
# Choices for the "do you want to renumber your objects" setting
#
###########################################
R_RENUMBER = "Renumber"
R_RETAIN = "Retain"
class EditObjectsManually(I.Identify):
category = "Object Processing"
variable_revision_number = 1
module_name = 'EditObjectsManually'
def create_settings(self):
"""Create your settings by subclassing this function
create_settings is called at the end of initialization.
You should create the setting variables for your module here:
# Ask the user for the input image
self.image_name = cellprofiler.settings.ImageNameSubscriber(...)
# Ask the user for the name of the output image
self.output_image = cellprofiler.settings.ImageNameProvider(...)
# Ask the user for a parameter
self.smoothing_size = cellprofiler.settings.Float(...)
"Image": MC_IMAGE,
"Keep overlapping region": P_MASK,
"Remove": P_REMOVE,
"Remove depending on overlap": P_REMOVE_PERCENTAGE,
"Keep": P_KEEP,
"Retain": R_RETAIN,
"Renumber": R_RENUMBER
}
def s_lookup(x):
'''Look up the current value for a setting choice w/backwards compatibility
x - setting value from pipeline
'''
return S_DICTIONARY.get(x, x)
class MaskObjects(I.Identify):
category = "Object Processing"
module_name = "MaskObjects"
variable_revision_number = 1
def create_settings(self):
'''Create the settings that control this module'''
self.object_name = cps.ObjectNameSubscriber(
"Select objects to be masked","None",
doc="""Select the objects that will be masked (that is, excluded in whole
or in part based on the other settings in the module).
You can choose from any objects created by
a previous object processing module, such as <b>IdentifyPrimaryObjects</b>,
<b>IdentifySecondaryObjects</b> or <b>IdentifyTertiaryObjects</b>.""")
self.remaining_objects = cps.ObjectNameProvider(
SMOOTHING_SIZE_VAR = 12
MAXIMA_SUPPRESSION_SIZE_VAR = 13
LOW_RES_MAXIMA_VAR = 14
SAVE_OUTLINES_VAR = 15
FILL_HOLES_OPTION_VAR = 16
TEST_MODE_VAR = 17
AUTOMATIC_SMOOTHING_VAR = 18
AUTOMATIC_MAXIMA_SUPPRESSION = 19
MANUAL_THRESHOLD_VAR = 20
BINARY_IMAGE_VAR = 21
LIMIT_NONE = "Continue"
LIMIT_TRUNCATE = "Truncate"
LIMIT_ERASE = "Erase"
class IdentifyPrimaryObjects(cpmi.Identify):
variable_revision_number = 6
category = "Object Processing"
module_name = "IdentifyPrimaryObjects"
def create_settings(self):
self.image_name = cps.ImageNameSubscriber(
"Select the input image",doc="""
What did you call the images you want to use to identify objects?""")
self.object_name = cps.ObjectNameProvider(
"Name the primary objects to be identified",
"Nuclei",doc="""
What do you want to call the objects identified by this module?""")
self.size_range = cps.IntegerRange(