Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_table_font():
return "%s,%f" % (
cellprofiler.preferences.get_table_font_name(),
cellprofiler.preferences.get_table_font_size(),
)
output_filename_help_button = wx.Button(panel,-1,'?', (0,0), (30,-1))
self.__analyze_images_button = wx.Button(panel,-1,'Analyze images')
self.__stop_analysis_button = wx.Button(panel,-1,'Stop analysis')
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.AddMany([(output_filename_help_button,0,wx.ALIGN_CENTER|wx.ALL,1),
(output_filename_text,0,wx.ALIGN_CENTER,1),
(self.__output_filename_edit_box,3,wx.ALL,1),
(self.__analyze_images_button,0,wx.ALL,1),
(self.__stop_analysis_button, 0, wx.ALL,1)])
sizer.Hide(self.__stop_analysis_button)
panel.SetSizer(sizer)
panel.Bind(wx.EVT_BUTTON,
lambda event: self.__on_help(event, OUTPUT_FILENAME_HELP),
output_filename_help_button)
panel.Bind(wx.EVT_TEXT, self.__on_output_filename_changed, self.__output_filename_edit_box)
cellprofiler.preferences.add_output_file_name_listener(self.__on_preferences_output_filename_event)
cellprofiler.preferences.add_image_directory_listener(self.__on_preferences_image_directory_event)
cellprofiler.preferences.add_output_directory_listener(self.__on_preferences_output_directory_event)
panel.Bind(wx.EVT_WINDOW_DESTROY, self.__on_destroy, panel)
thread.setDaemon(True)
thread.start()
cls.workers.append(thread)
return
close_fds = False
# start workers
for idx in range(num):
if sys.platform == "darwin":
close_all_on_exec()
aw_args = [
"--work-announce",
cls.work_announce_address,
"--plugins-directory",
cellprofiler.preferences.get_plugin_directory(),
"--ij-plugins-directory",
cellprofiler.preferences.get_ij_plugin_directory(),
]
jvm_arg = "%dm" % cellprofiler.preferences.get_jvm_heap_mb()
aw_args.append("--jvm-heap-size=%s" % jvm_arg)
# stdin for the subprocesses serves as a deadman's switch. When
# closed, the subprocess exits.
if hasattr(sys, "frozen"):
if sys.platform == "darwin":
executable = os.path.join(os.path.dirname(sys.executable), "cp")
args = [executable] + aw_args
elif sys.platform.startswith("linux"):
aw_path = os.path.join(os.path.dirname(__file__), "worker.py")
args = [sys.executable, aw_path] + aw_args
else:
args = [sys.executable] + aw_args
],
)
# set measurements mode, then fake an event to update output
# filename and which controls are shown.
measurements_mode_idx = [
cellprofiler.preferences.WRITE_HDF5,
True,
False,
].index(cellprofiler.preferences.get_write_MAT_files())
write_measurements_combo_box.SetSelection(measurements_mode_idx)
output_filename_help_button = wx.Button(panel, label="?", style=wx.BU_EXACTFIT)
output_file_format_text = wx.StaticText(panel, label="Output file format:")
cellprofiler.preferences.add_output_file_name_listener(
self.__on_preferences_output_filename_event
)
cellprofiler.preferences.add_image_directory_listener(
self.__on_preferences_image_directory_event
)
cellprofiler.preferences.add_output_directory_listener(
self.__on_preferences_output_directory_event
)
self.__hold_a_reference_to_progress_callback = self.progress_callback
cellprofiler.preferences.add_progress_callback(
self.__hold_a_reference_to_progress_callback
)
def on_output_filename_changed(event):
cellprofiler.preferences.set_output_file_name(
output_filename_edit_box.GetValue()
)
def on_allow_checkbox(event):
def prepare_run(self, pipeline, image_set_list, frame):
'''Set up omero image providers inside the image_set_list'''
if pipeline.in_batch_mode():
#TODO: Rewrite the OmeroImageProvider such that it can be used in batch mode
#e.g. omero session keys could be used to attach to existing sessions to
#keep OmeroImageProviders from creating a new session every time an image should be loaded
return False
if cpp.get_headless():
print 'OmeroLoadImages running in headless mode: image directory parameter will be used as omero object id'
self.omero_object_id.set_value(int(cpp.get_default_image_directory()))
print 'omero object id = %d'%self.omero_object_id.value
print 'omero object type = %s'%self.omero_object.value
self.create_omero_gateway()
if self.omero_object == MS_IMAGE:
omero_image_list = [self.omero_gateway.getImage(self.omero_object_id.value)]
elif self.omero_object == MS_DATASET:
#Get dataset without leaves(=images&pixels)
dataset = self.omero_gateway.getDataset(self.omero_object_id.value, False)
self.dataset_name = dataset.getName().getValue()
omero_image_list = self.get_images_from_dataset(self.omero_object_id.value)
elif self.omero_object == MS_PLATE:
self.wells = self.get_wells_from_plate(self.omero_object_id.value)
self.plate_name = self.wells[0].getPlate().getName().getValue()
"Display welcome text on startup",
cellprofiler.preferences.get_startup_blurb,
cellprofiler.preferences.set_startup_blurb,
CHOICE,
cellprofiler.preferences.SHOW_STARTUP_BLURB_HELP,
],
[
"Warn if Java runtime environment not present",
cellprofiler.preferences.get_report_jvm_error,
cellprofiler.preferences.set_report_jvm_error,
CHOICE,
cellprofiler.preferences.REPORT_JVM_ERROR_HELP,
],
[
'Show the "Analysis complete" message at the end of a run',
cellprofiler.preferences.get_show_analysis_complete_dlg,
cellprofiler.preferences.set_show_analysis_complete_dlg,
CHOICE,
cellprofiler.preferences.SHOW_ANALYSIS_COMPLETE_HELP,
],
[
'Show the "Exiting test mode" message',
cellprofiler.preferences.get_show_exiting_test_mode_dlg,
cellprofiler.preferences.set_show_exiting_test_mode_dlg,
CHOICE,
cellprofiler.preferences.SHOW_EXITING_TEST_MODE_HELP,
],
[
"Warn if images are different sizes",
cellprofiler.preferences.get_show_report_bad_sizes_dlg,
cellprofiler.preferences.set_show_report_bad_sizes_dlg,
CHOICE,
self.frame = VWFigureFrame(
parent,
title="CellProfiler Workspace",
secret_panel_class=wx.lib.scrolledpanel.ScrolledPanel,
help_menu_items=cellprofiler.gui.help.content.FIGURE_HELP,
)
self.workspace = workspace
self.ignore_redraw = False
self.image_rows = []
self.object_rows = []
self.mask_rows = []
self.measurement_rows = []
self.frame.set_subplots((1, 1))
self.axes = self.frame.subplot(0, 0)
self.axes.invert_yaxis()
interpolation = cellprofiler.preferences.get_interpolation_mode()
if interpolation == cellprofiler.preferences.IM_NEAREST:
interpolation = cellprofiler.gui.artist.INTERPOLATION_NEAREST
elif interpolation == cellprofiler.preferences.IM_BILINEAR:
interpolation = cellprofiler.gui.artist.INTERPOLATION_BILINEAR
else:
interpolation = cellprofiler.gui.artist.INTERPOLATION_BICUBIC
self.image = cellprofiler.gui.artist.CPImageArtist(interpolation=interpolation)
assert isinstance(self.axes, matplotlib.axes.Axes)
self.axes.add_artist(self.image)
self.axes.set_aspect("equal")
self.__axes_scale = None
panel = self.frame.secret_panel
panel.Sizer = wx.BoxSizer(wx.VERTICAL)
self.panel = panel
#
COLOR,
cellprofiler.preferences.PRIMARY_OUTLINE_COLOR_HELP,
],
[
"Secondary outline color",
cellprofiler.preferences.get_secondary_outline_color,
cellprofiler.preferences.set_secondary_outline_color,
COLOR,
cellprofiler.preferences.SECONDARY_OUTLINE_COLOR_HELP,
],
[
"Tertiary outline color",
cellprofiler.preferences.get_tertiary_outline_color,
cellprofiler.preferences.set_tertiary_outline_color,
COLOR,
cellprofiler.preferences.TERTIARY_OUTLINE_COLOR_HELP,
],
[
"Interpolation mode",
cellprofiler.preferences.get_interpolation_mode,
cellprofiler.preferences.set_interpolation_mode,
[
cellprofiler.preferences.IM_NEAREST,
cellprofiler.preferences.IM_BILINEAR,
cellprofiler.preferences.IM_BICUBIC,
],
cellprofiler.preferences.INTERPOLATION_MODE_HELP,
],
[
"Intensity normalization",
cellprofiler.preferences.get_intensity_mode,
cellprofiler.preferences.set_intensity_mode,
"Tertiary outline color",
cellprofiler.preferences.get_tertiary_outline_color,
cellprofiler.preferences.set_tertiary_outline_color,
COLOR,
cellprofiler.preferences.TERTIARY_OUTLINE_COLOR_HELP,
],
[
"Interpolation mode",
cellprofiler.preferences.get_interpolation_mode,
cellprofiler.preferences.set_interpolation_mode,
[
cellprofiler.preferences.IM_NEAREST,
cellprofiler.preferences.IM_BILINEAR,
cellprofiler.preferences.IM_BICUBIC,
],
cellprofiler.preferences.INTERPOLATION_MODE_HELP,
],
[
"Intensity normalization",
cellprofiler.preferences.get_intensity_mode,
cellprofiler.preferences.set_intensity_mode,
[
cellprofiler.preferences.INTENSITY_MODE_RAW,
cellprofiler.preferences.INTENSITY_MODE_NORMAL,
cellprofiler.preferences.INTENSITY_MODE_LOG,
cellprofiler.preferences.INTENSITY_MODE_GAMMA,
],
cellprofiler.preferences.INTENSITY_MODE_HELP,
],
[
"Intensity normalization factor",
cellprofiler.preferences.get_normalization_factor,
def subplot_imshow_labels(self, x, y, labels, title=None, clear=True,
renumber=True):
if renumber:
labels = renumber_labels_for_display(labels)
if np.all(labels == 0):
cm=matplotlib.cm.gray
else:
cm = matplotlib.cm.get_cmap(cpprefs.get_default_colormap())
cm.set_bad((0,0,0))
labels = numpy.ma.array(labels, mask=labels==0)
return self.subplot_imshow(x, y, labels, title, clear, cm,
normalize=False, vmin = None, vmax = None)