本文整理汇总了Python中ilastik.applets.batchProcessing.BatchProcessingApplet类的典型用法代码示例。如果您正苦于以下问题:Python BatchProcessingApplet类的具体用法?Python BatchProcessingApplet怎么用?Python BatchProcessingApplet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BatchProcessingApplet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super(DataConversionWorkflow, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
self._applets = []
# Instantiate DataSelection applet
self.dataSelectionApplet = DataSelectionApplet(
self,
"Input Data",
"Input Data",
supportIlastik05Import=True,
forceAxisOrder=None)
# Configure global DataSelection settings
role_names = ["Input Data"]
opDataSelection = self.dataSelectionApplet.topLevelOperator
opDataSelection.DatasetRoles.setValue( role_names )
# Instantiate DataExport applet
self.dataExportApplet = DataExportApplet(self, "Data Export")
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( ["Input"] )
# No special data pre/post processing necessary in this workflow,
# but this is where we'd hook it up if we needed it.
#
#self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
#self.dataExportApplet.prepare_lane_for_export = self.prepare_lane_for_export
#self.dataExportApplet.post_process_lane_export = self.post_process_lane_export
#self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
# Instantiate BatchProcessing applet
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# Expose our applets in a list (for the shell to use)
self._applets.append( self.dataSelectionApplet )
self._applets.append( self.dataExportApplet )
self._applets.append(self.batchProcessingApplet)
# Parse command-line arguments
# Command-line args are applied in onProjectLoaded(), below.
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( workflow_cmdline_args )
self._batch_input_args, unused_args = self.dataSelectionApplet.parse_known_cmdline_args( unused_args, role_names )
else:
unused_args = None
self._batch_input_args = None
self._data_export_args = None
if unused_args:
logger.warning("Unused command-line args: {}".format( unused_args ))
示例2: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super(NNClassificationWorkflow, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
# parser.add_argument('--print-labels-by-slice', help="Print the number of labels for each Z-slice of each image.", action="store_true")
# Parse the creation args: These were saved to the project file when this project was first created.
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
# Parse the cmdline args for the current session.
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
# self.print_labels_by_slice = parsed_args.print_labels_by_slice
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right.\n\n"\
"Power users: Optionally use the 'Prediction Mask' tab to supply a binary image that tells ilastik where it should avoid computations you don't need."
# Applets for training (interactive) workflow
self.dataSelectionApplet = self.createDataSelectionApplet()
opDataSelection = self.dataSelectionApplet.topLevelOperator
# see role constants, above
opDataSelection.DatasetRoles.setValue(NNClassificationWorkflow.ROLE_NAMES)
self.nnClassificationApplet = NNClassApplet(self, "NNClassApplet")
self.dataExportApplet = NNClassificationDataExportApplet(self, 'Data Export')
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect(opDataSelection.WorkingDirectory)
opDataExport.SelectionNames.setValue(self.EXPORT_NAMES)
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# Expose for shell
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.nnClassificationApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args(unused_args)
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args(unused_args)
else:
self._batch_input_args = None
self._batch_export_args = None
if unused_args:
logger.warn("Unused command-line args: {}".format(unused_args))
示例3: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_workflow, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super(WsdtWorkflow, self).__init__( shell, headless, workflow_cmdline_args, project_creation_workflow, graph=graph, *args, **kwargs)
self._applets = []
# -- DataSelection applet
#
self.dataSelectionApplet = DataSelectionApplet(self, "Input Data", "Input Data")
# Dataset inputs
opDataSelection = self.dataSelectionApplet.topLevelOperator
opDataSelection.DatasetRoles.setValue( self.ROLE_NAMES )
# -- Wsdt applet
#
self.wsdtApplet = WsdtApplet(self, "Watershed", "Wsdt Watershed")
# -- DataExport applet
#
self.dataExportApplet = DataExportApplet(self, "Data Export")
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( self.EXPORT_NAMES )
# -- BatchProcessing applet
#
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# -- Expose applets to shell
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.wsdtApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
# -- Parse command-line arguments
# (Command-line args are applied in onProjectLoaded(), below.)
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( workflow_cmdline_args )
self._batch_input_args, unused_args = self.dataSelectionApplet.parse_known_cmdline_args( unused_args, role_names )
else:
unused_args = None
self._batch_input_args = None
self._data_export_args = None
if unused_args:
logger.warning("Unused command-line args: {}".format( unused_args ))
示例4: __init__
#.........这里部分代码省略.........
opDataSelection.DatasetRoles.setValue( ['Raw Data', 'Prediction Maps'] )
if not self.fromBinary:
self.thresholdTwoLevelsApplet = ThresholdTwoLevelsApplet( self,
"Threshold and Size Filter",
"ThresholdTwoLevels" )
self.objectExtractionApplet = TrackingFeatureExtractionApplet(workflow=self, interactive=False,
name="Object Feature Computation")
opObjectExtraction = self.objectExtractionApplet.topLevelOperator
self.divisionDetectionApplet = self._createDivisionDetectionApplet(configConservation.selectedFeaturesDiv) # Might be None
if self.divisionDetectionApplet:
feature_dict_division = {}
feature_dict_division[config.features_division_name] = { name: {} for name in config.division_features }
opObjectExtraction.FeatureNamesDivision.setValue(feature_dict_division)
selected_features_div = {}
for plugin_name in list(config.selected_features_division.keys()):
selected_features_div[plugin_name] = { name: {} for name in config.selected_features_division[plugin_name] }
# FIXME: do not hard code this
for name in [ 'SquaredDistances_' + str(i) for i in range(config.n_best_successors) ]:
selected_features_div[config.features_division_name][name] = {}
opDivisionDetection = self.divisionDetectionApplet.topLevelOperator
opDivisionDetection.SelectedFeatures.setValue(configConservation.selectedFeaturesDiv)
opDivisionDetection.LabelNames.setValue(['Not Dividing', 'Dividing'])
opDivisionDetection.AllowDeleteLabels.setValue(False)
opDivisionDetection.AllowAddLabel.setValue(False)
opDivisionDetection.EnableLabelTransfer.setValue(False)
self.cellClassificationApplet = ObjectClassificationApplet(workflow=self,
name="Object Count Classification",
projectFileGroupName="CountClassification",
selectedFeatures=configConservation.selectedFeaturesObjectCount)
selected_features_objectcount = {}
for plugin_name in list(config.selected_features_objectcount.keys()):
selected_features_objectcount[plugin_name] = { name: {} for name in config.selected_features_objectcount[plugin_name] }
opCellClassification = self.cellClassificationApplet.topLevelOperator
opCellClassification.SelectedFeatures.setValue(configConservation.selectedFeaturesObjectCount)
opCellClassification.SuggestedLabelNames.setValue( ['False Detection',] + [str(1) + ' Object'] + [str(i) + ' Objects' for i in range(2,10) ] )
opCellClassification.AllowDeleteLastLabelOnly.setValue(True)
opCellClassification.EnableLabelTransfer.setValue(False)
self.trackingApplet = ConservationTrackingApplet( workflow=self )
self.default_export_filename = '{dataset_dir}/{nickname}-exported_data.csv'
self.dataExportApplet = TrackingBaseDataExportApplet(
self,
"Tracking Result Export",
default_export_filename=self.default_export_filename,
pluginExportFunc=self._pluginExportFunc,
)
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.SelectionNames.setValue( ['Object-Identities', 'Tracking-Result', 'Merger-Result'] )
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
# Extra configuration for object export table (as CSV table or HDF5 table)
opTracking = self.trackingApplet.topLevelOperator
self.dataExportApplet.set_exporting_operator(opTracking)
self.dataExportApplet.prepare_lane_for_export = self.prepare_lane_for_export
# configure export settings
# settings = {'file path': self.default_export_filename, 'compression': {}, 'file type': 'csv'}
# selected_features = ['Count', 'RegionCenter', 'RegionRadii', 'RegionAxes']
# opTracking.ExportSettings.setValue( (settings, selected_features) )
self._applets = []
self._applets.append(self.dataSelectionApplet)
if not self.fromBinary:
self._applets.append(self.thresholdTwoLevelsApplet)
self._applets.append(self.objectExtractionApplet)
if self.divisionDetectionApplet:
self._applets.append(self.divisionDetectionApplet)
self.batchProcessingApplet = BatchProcessingApplet(self, "Batch Processing", self.dataSelectionApplet, self.dataExportApplet)
self._applets.append(self.cellClassificationApplet)
self._applets.append(self.trackingApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
# Parse export and batch command-line arguments for headless mode
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( workflow_cmdline_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( workflow_cmdline_args )
else:
unused_args = None
self._data_export_args = None
self._batch_input_args = None
if unused_args:
logger.warning("Unused command-line args: {}".format( unused_args ))
示例5: ConservationTrackingWorkflowBase
#.........这里部分代码省略.........
self.trackingApplet = ConservationTrackingApplet( workflow=self )
self.default_export_filename = '{dataset_dir}/{nickname}-exported_data.csv'
self.dataExportApplet = TrackingBaseDataExportApplet(
self,
"Tracking Result Export",
default_export_filename=self.default_export_filename,
pluginExportFunc=self._pluginExportFunc,
)
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.SelectionNames.setValue( ['Object-Identities', 'Tracking-Result', 'Merger-Result'] )
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
# Extra configuration for object export table (as CSV table or HDF5 table)
opTracking = self.trackingApplet.topLevelOperator
self.dataExportApplet.set_exporting_operator(opTracking)
self.dataExportApplet.prepare_lane_for_export = self.prepare_lane_for_export
# configure export settings
# settings = {'file path': self.default_export_filename, 'compression': {}, 'file type': 'csv'}
# selected_features = ['Count', 'RegionCenter', 'RegionRadii', 'RegionAxes']
# opTracking.ExportSettings.setValue( (settings, selected_features) )
self._applets = []
self._applets.append(self.dataSelectionApplet)
if not self.fromBinary:
self._applets.append(self.thresholdTwoLevelsApplet)
self._applets.append(self.objectExtractionApplet)
if self.divisionDetectionApplet:
self._applets.append(self.divisionDetectionApplet)
self.batchProcessingApplet = BatchProcessingApplet(self, "Batch Processing", self.dataSelectionApplet, self.dataExportApplet)
self._applets.append(self.cellClassificationApplet)
self._applets.append(self.trackingApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
# Parse export and batch command-line arguments for headless mode
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( workflow_cmdline_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( workflow_cmdline_args )
else:
unused_args = None
self._data_export_args = None
self._batch_input_args = None
if unused_args:
logger.warning("Unused command-line args: {}".format( unused_args ))
@property
def applets(self):
return self._applets
def _createDivisionDetectionApplet(self,selectedFeatures=dict()):
return ObjectClassificationApplet(workflow=self,
name="Division Detection (optional)",
projectFileGroupName="DivisionDetection",
selectedFeatures=selectedFeatures)
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
示例6: DataConversionWorkflow
class DataConversionWorkflow(Workflow):
"""
Simple workflow for converting data between formats.
Has only two 'interactive' applets (Data Selection and Data Export), plus the BatchProcessing applet.
Supports headless mode. For example:
.. code-block::
python ilastik.py --headless
--new_project=NewTemporaryProject.ilp
--workflow=DataConversionWorkflow
--output_format="png sequence"
~/input1.h5
~/input2.h5
.. note:: Beware of issues related to absolute vs. relative paths.
Relative links are stored relative to the project file.
To avoid this issue entirely, either
(1) use only absolute filepaths
or (2) cd into your project file's directory before launching ilastik.
"""
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super(DataConversionWorkflow, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
self._applets = []
# Instantiate DataSelection applet
self.dataSelectionApplet = DataSelectionApplet(self,
"Input Data",
"Input Data",
supportIlastik05Import=True)
# Configure global DataSelection settings
role_names = ["Input Data"]
opDataSelection = self.dataSelectionApplet.topLevelOperator
opDataSelection.DatasetRoles.setValue( role_names )
# Instantiate DataExport applet
self.dataExportApplet = DataExportApplet(self, "Data Export")
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( ["Input"] )
# No special data pre/post processing necessary in this workflow,
# but this is where we'd hook it up if we needed it.
#
#self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
#self.dataExportApplet.prepare_lane_for_export = self.prepare_lane_for_export
#self.dataExportApplet.post_process_lane_export = self.post_process_lane_export
#self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
# Instantiate BatchProcessing applet
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# Expose our applets in a list (for the shell to use)
self._applets.append( self.dataSelectionApplet )
self._applets.append( self.dataExportApplet )
self._applets.append(self.batchProcessingApplet)
# Parse command-line arguments
# Command-line args are applied in onProjectLoaded(), below.
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( workflow_cmdline_args )
self._batch_input_args, unused_args = self.dataSelectionApplet.parse_known_cmdline_args( unused_args, role_names )
else:
unused_args = None
self._batch_input_args = None
self._data_export_args = None
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
@property
def applets(self):
"""
Overridden from Workflow base class.
"""
return self._applets
@property
def imageNameListSlot(self):
"""
Overridden from Workflow base class.
"""
return self.dataSelectionApplet.topLevelOperator.ImageName
def prepareForNewLane(self, laneIndex):
"""
Overridden from Workflow base class.
#.........这里部分代码省略.........
示例7: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_workflow, *args, **kwargs):
self.stored_classifier = None
# Create a graph to be shared by all operators
graph = Graph()
super(EdgeTrainingWithMulticutWorkflow, self).__init__( shell, headless, workflow_cmdline_args, project_creation_workflow, graph=graph, *args, **kwargs)
self._applets = []
# -- DataSelection applet
#
self.dataSelectionApplet = DataSelectionApplet(self, "Input Data", "Input Data", forceAxisOrder=['zyxc', 'yxc'])
# Dataset inputs
opDataSelection = self.dataSelectionApplet.topLevelOperator
opDataSelection.DatasetRoles.setValue( self.ROLE_NAMES )
# -- Watershed applet
#
self.wsdtApplet = WsdtApplet(self, "DT Watershed", "DT Watershed")
# -- Edge training AND Multicut applet
#
self.edgeTrainingWithMulticutApplet = EdgeTrainingWithMulticutApplet(self, "Training and Multicut", "Training and Multicut")
opEdgeTrainingWithMulticut = self.edgeTrainingWithMulticutApplet.topLevelOperator
DEFAULT_FEATURES = { self.ROLE_NAMES[self.DATA_ROLE_RAW]: ['standard_edge_mean'] }
opEdgeTrainingWithMulticut.FeatureNames.setValue( DEFAULT_FEATURES )
# -- DataExport applet
#
self.dataExportApplet = DataExportApplet(self, "Data Export")
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( self.EXPORT_NAMES )
# -- BatchProcessing applet
#
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# -- Expose applets to shell
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.wsdtApplet)
self._applets.append(self.edgeTrainingWithMulticutApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
# -- Parse command-line arguments
# (Command-line args are applied in onProjectLoaded(), below.)
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--retrain', help="Re-train the classifier based on labels stored in the project file, and re-save.", action="store_true")
self.parsed_workflow_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
if unused_args:
# Parse batch export/input args.
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( unused_args )
else:
unused_args = None
self._batch_input_args = None
self._data_export_args = None
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
if not self._headless:
shell.currentAppletChanged.connect( self.handle_applet_changed )
示例8: StructuredTrackingWorkflowBase
class StructuredTrackingWorkflowBase( Workflow ):
workflowName = "Structured Learning Tracking Workflow BASE"
@property
def applets(self):
return self._applets
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
def __init__( self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs ):
graph = kwargs['graph'] if 'graph' in kwargs else Graph()
if 'graph' in kwargs: del kwargs['graph']
super(StructuredTrackingWorkflowBase, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
data_instructions = 'Use the "Raw Data" tab to load your intensity image(s).\n\n'
if self.fromBinary:
data_instructions += 'Use the "Binary Image" tab to load your segmentation image(s).'
else:
data_instructions += 'Use the "Prediction Maps" tab to load your pixel-wise probability image(s).'
# Create applets
self.dataSelectionApplet = DataSelectionApplet(self,
"Input Data",
"Input Data",
batchDataGui=False,
forceAxisOrder=['txyzc'],
instructionText=data_instructions,
max_lanes=1)
opDataSelection = self.dataSelectionApplet.topLevelOperator
if self.fromBinary:
opDataSelection.DatasetRoles.setValue( ['Raw Data', 'Binary Image'] )
else:
opDataSelection.DatasetRoles.setValue( ['Raw Data', 'Prediction Maps'] )
if not self.fromBinary:
self.thresholdTwoLevelsApplet = ThresholdTwoLevelsApplet( self,"Threshold and Size Filter","ThresholdTwoLevels" )
self.divisionDetectionApplet = ObjectClassificationApplet(workflow=self,
name="Division Detection (optional)",
projectFileGroupName="DivisionDetection",
selectedFeatures=configStructured.selectedFeaturesDiv)
self.cellClassificationApplet = ObjectClassificationApplet(workflow=self,
name="Object Count Classification",
projectFileGroupName="CountClassification",
selectedFeatures=configStructured.selectedFeaturesObjectCount)
self.cropSelectionApplet = CropSelectionApplet(self,"Crop Selection","CropSelection")
self.trackingFeatureExtractionApplet = TrackingFeatureExtractionApplet(name="Object Feature Computation",workflow=self, interactive=False)
self.objectExtractionApplet = ObjectExtractionApplet(name="Object Feature Computation",workflow=self, interactive=False)
self.annotationsApplet = AnnotationsApplet( name="Training", workflow=self )
opAnnotations = self.annotationsApplet.topLevelOperator
# self.default_training_export_filename = '{dataset_dir}/{nickname}-training_exported_data.csv'
# self.dataExportAnnotationsApplet = TrackingBaseDataExportApplet(self, "Training Export",default_export_filename=self.default_training_export_filename)
# opDataExportAnnotations = self.dataExportAnnotationsApplet.topLevelOperator
# opDataExportAnnotations.SelectionNames.setValue( ['User Training for Tracking', 'Object Identities'] )
# opDataExportAnnotations.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
# self.dataExportAnnotationsApplet.set_exporting_operator(opAnnotations)
self.trackingApplet = StructuredTrackingApplet( name="Tracking - Structured Learning", workflow=self )
opStructuredTracking = self.trackingApplet.topLevelOperator
self.default_tracking_export_filename = '{dataset_dir}/{nickname}-tracking_exported_data.csv'
self.dataExportTrackingApplet = TrackingBaseDataExportApplet(self, "Tracking Result Export",default_export_filename=self.default_tracking_export_filename)
opDataExportTracking = self.dataExportTrackingApplet.topLevelOperator
opDataExportTracking.SelectionNames.setValue( ['Tracking-Result', 'Merger-Result', 'Object-Identities'] )
opDataExportTracking.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
self.dataExportTrackingApplet.set_exporting_operator(opStructuredTracking)
self.dataExportTrackingApplet.prepare_lane_for_export = self.prepare_lane_for_export
self.dataExportTrackingApplet.post_process_lane_export = self.post_process_lane_export
# configure export settings
settings = {'file path': self.default_tracking_export_filename, 'compression': {}, 'file type': 'h5'}
selected_features = ['Count', 'RegionCenter', 'RegionRadii', 'RegionAxes']
opStructuredTracking.ExportSettings.setValue( (settings, selected_features) )
self._applets = []
self._applets.append(self.dataSelectionApplet)
if not self.fromBinary:
self._applets.append(self.thresholdTwoLevelsApplet)
self._applets.append(self.trackingFeatureExtractionApplet)
self._applets.append(self.divisionDetectionApplet)
self.batchProcessingApplet = BatchProcessingApplet(self, "Batch Processing", self.dataSelectionApplet, self.dataExportTrackingApplet)
self._applets.append(self.cellClassificationApplet)
self._applets.append(self.cropSelectionApplet)
self._applets.append(self.objectExtractionApplet)
self._applets.append(self.annotationsApplet)
# self._applets.append(self.dataExportAnnotationsApplet)
self._applets.append(self.trackingApplet)
self._applets.append(self.dataExportTrackingApplet)
#.........这里部分代码省略.........
示例9: ObjectClassificationWorkflow
class ObjectClassificationWorkflow(Workflow):
workflowName = "Object Classification Workflow Base"
defaultAppletIndex = 1 # show DataSelection by default
def __init__(self, shell, headless,
workflow_cmdline_args,
project_creation_args,
*args, **kwargs):
graph = kwargs['graph'] if 'graph' in kwargs else Graph()
if 'graph' in kwargs:
del kwargs['graph']
super(ObjectClassificationWorkflow, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
self.stored_pixel_classifier = None
self.stored_object_classifier = None
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--fillmissing', help="use 'fill missing' applet with chosen detection method", choices=['classic', 'svm', 'none'], default='none')
parser.add_argument('--filter', help="pixel feature filter implementation.", choices=['Original', 'Refactored', 'Interpolated'], default='Original')
parser.add_argument('--nobatch', help="do not append batch applets", action='store_true', default=False)
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
self.fillMissing = parsed_creation_args.fillmissing
self.filter_implementation = parsed_creation_args.filter
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
if parsed_args.fillmissing != 'none' and parsed_creation_args.fillmissing != parsed_args.fillmissing:
logger.error( "Ignoring --fillmissing cmdline arg. Can't specify a different fillmissing setting after the project has already been created." )
if parsed_args.filter != 'Original' and parsed_creation_args.filter != parsed_args.filter:
logger.error( "Ignoring --filter cmdline arg. Can't specify a different filter setting after the project has already been created." )
self.batch = not parsed_args.nobatch
self._applets = []
self.pcApplet = None
self.projectMetadataApplet = ProjectMetadataApplet()
self._applets.append(self.projectMetadataApplet)
self.setupInputs()
if self.fillMissing != 'none':
self.fillMissingSlicesApplet = FillMissingSlicesApplet(
self, "Fill Missing Slices", "Fill Missing Slices", self.fillMissing)
self._applets.append(self.fillMissingSlicesApplet)
if isinstance(self, ObjectClassificationWorkflowPixel):
self.input_types = 'raw'
elif isinstance(self, ObjectClassificationWorkflowBinary):
self.input_types = 'raw+binary'
elif isinstance( self, ObjectClassificationWorkflowPrediction ):
self.input_types = 'raw+pmaps'
# our main applets
self.objectExtractionApplet = ObjectExtractionApplet(workflow=self, name = "Object Feature Selection")
self.objectClassificationApplet = ObjectClassificationApplet(workflow=self)
self.dataExportApplet = ObjectClassificationDataExportApplet(self, "Object Information Export")
self.dataExportApplet.set_exporting_operator(self.objectClassificationApplet.topLevelOperator)
# Customization hooks
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
#self.dataExportApplet.prepare_lane_for_export = self.prepare_lane_for_export
self.dataExportApplet.post_process_lane_export = self.post_process_lane_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( self.dataSelectionApplet.topLevelOperator.WorkingDirectory )
# See EXPORT_SELECTION_PREDICTIONS and EXPORT_SELECTION_PROBABILITIES, above
export_selection_names = ['Object Predictions',
'Object Probabilities',
'Blockwise Object Predictions',
'Blockwise Object Probabilities']
if self.input_types == 'raw':
# Re-configure to add the pixel probabilities option
# See EXPORT_SELECTION_PIXEL_PROBABILITIES, above
export_selection_names.append( 'Pixel Probabilities' )
opDataExport.SelectionNames.setValue( export_selection_names )
self._batch_export_args = None
self._batch_input_args = None
self._export_args = None
self.batchProcessingApplet = None
if self.batch:
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
if unused_args:
# Additional export args (specific to the object classification workflow)
export_arg_parser = argparse.ArgumentParser()
export_arg_parser.add_argument( "--table_filename", help="The location to export the object feature/prediction CSV file.", required=False )
export_arg_parser.add_argument( "--export_object_prediction_img", action="store_true" )
export_arg_parser.add_argument( "--export_object_probability_img", action="store_true" )
export_arg_parser.add_argument( "--export_pixel_probability_img", action="store_true" )
# TODO: Support this, too, someday?
#.........这里部分代码省略.........
示例10: PixelClassificationWorkflow
class PixelClassificationWorkflow(Workflow):
workflowName = "Pixel Classification"
workflowDescription = "This is obviously self-explanatory."
defaultAppletIndex = 1 # show DataSelection by default
DATA_ROLE_RAW = 0
DATA_ROLE_PREDICTION_MASK = 1
ROLE_NAMES = ['Raw Data', 'Prediction Mask']
EXPORT_NAMES = ['Probabilities', 'Simple Segmentation', 'Uncertainty', 'Features']
@property
def applets(self):
return self._applets
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super( PixelClassificationWorkflow, self ).__init__( shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs )
self.stored_classifer = None
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--filter', help="pixel feature filter implementation.", choices=['Original', 'Refactored', 'Interpolated'], default='Original')
parser.add_argument('--print-labels-by-slice', help="Print the number of labels for each Z-slice of each image.", action="store_true")
parser.add_argument('--label-search-value', help="If provided, only this value is considered when using --print-labels-by-slice", default=0, type=int)
parser.add_argument('--generate-random-labels', help="Add random labels to the project file.", action="store_true")
parser.add_argument('--random-label-value', help="The label value to use injecting random labels", default=1, type=int)
parser.add_argument('--random-label-count', help="The number of random labels to inject via --generate-random-labels", default=2000, type=int)
parser.add_argument('--retrain', help="Re-train the classifier based on labels stored in project file, and re-save.", action="store_true")
parser.add_argument('--tree-count', help='Number of trees for Vigra RF classifier.', type=int)
parser.add_argument('--variable-importance-path', help='Location of variable-importance table.', type=str)
parser.add_argument('--label-proportion', help='Proportion of feature-pixels used to train the classifier.', type=float)
# Parse the creation args: These were saved to the project file when this project was first created.
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
self.filter_implementation = parsed_creation_args.filter
# Parse the cmdline args for the current session.
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
self.print_labels_by_slice = parsed_args.print_labels_by_slice
self.label_search_value = parsed_args.label_search_value
self.generate_random_labels = parsed_args.generate_random_labels
self.random_label_value = parsed_args.random_label_value
self.random_label_count = parsed_args.random_label_count
self.retrain = parsed_args.retrain
self.tree_count = parsed_args.tree_count
self.variable_importance_path = parsed_args.variable_importance_path
self.label_proportion = parsed_args.label_proportion
if parsed_args.filter and parsed_args.filter != parsed_creation_args.filter:
logger.error("Ignoring new --filter setting. Filter implementation cannot be changed after initial project creation.")
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right.\n\n"\
"Power users: Optionally use the 'Prediction Mask' tab to supply a binary image that tells ilastik where it should avoid computations you don't need."
# Applets for training (interactive) workflow
self.projectMetadataApplet = ProjectMetadataApplet()
self.dataSelectionApplet = self.createDataSelectionApplet()
opDataSelection = self.dataSelectionApplet.topLevelOperator
# see role constants, above
opDataSelection.DatasetRoles.setValue( PixelClassificationWorkflow.ROLE_NAMES )
self.featureSelectionApplet = self.createFeatureSelectionApplet()
self.pcApplet = self.createPixelClassificationApplet()
opClassify = self.pcApplet.topLevelOperator
self.dataExportApplet = PixelClassificationDataExportApplet(self, "Prediction Export")
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.PmapColors.connect( opClassify.PmapColors )
opDataExport.LabelNames.connect( opClassify.LabelNames )
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( self.EXPORT_NAMES )
# Expose for shell
self._applets.append(self.projectMetadataApplet)
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.featureSelectionApplet)
self._applets.append(self.pcApplet)
self._applets.append(self.dataExportApplet)
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
#.........这里部分代码省略.........
示例11: NNClassificationWorkflow
class NNClassificationWorkflow(Workflow):
"""
Workflow for the Neural Network Classification Applet
"""
workflowName = "Neural Network Classification"
workflowDescription = "This is obviously self-explanatory."
defaultAppletIndex = 0 # show DataSelection by default
DATA_ROLE_RAW = 0
ROLE_NAMES = ['Raw Data']
EXPORT_NAMES = ['Probabilities']
@property
def applets(self):
"""
Return the list of applets that are owned by this workflow
"""
return self._applets
@property
def imageNameListSlot(self):
"""
Return the "image name list" slot, which lists the names of
all image lanes (i.e. files) currently loaded by the workflow
"""
return self.dataSelectionApplet.topLevelOperator.ImageName
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super(NNClassificationWorkflow, self).__init__(shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs)
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
# parser.add_argument('--print-labels-by-slice', help="Print the number of labels for each Z-slice of each image.", action="store_true")
# Parse the creation args: These were saved to the project file when this project was first created.
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
# Parse the cmdline args for the current session.
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
# self.print_labels_by_slice = parsed_args.print_labels_by_slice
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right.\n\n"\
"Power users: Optionally use the 'Prediction Mask' tab to supply a binary image that tells ilastik where it should avoid computations you don't need."
# Applets for training (interactive) workflow
self.dataSelectionApplet = self.createDataSelectionApplet()
opDataSelection = self.dataSelectionApplet.topLevelOperator
# see role constants, above
opDataSelection.DatasetRoles.setValue(NNClassificationWorkflow.ROLE_NAMES)
self.nnClassificationApplet = NNClassApplet(self, "NNClassApplet")
self.dataExportApplet = NNClassificationDataExportApplet(self, 'Data Export')
# Configure global DataExport settings
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect(opDataSelection.WorkingDirectory)
opDataExport.SelectionNames.setValue(self.EXPORT_NAMES)
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
# Expose for shell
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.nnClassificationApplet)
self._applets.append(self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args(unused_args)
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args(unused_args)
else:
self._batch_input_args = None
self._batch_export_args = None
if unused_args:
logger.warn("Unused command-line args: {}".format(unused_args))
def createDataSelectionApplet(self):
"""
Can be overridden by subclasses, if they want to use
special parameters to initialize the DataSelectionApplet.
"""
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right"
return DataSelectionApplet(self,
"Input Data",
"Input Data",
supportIlastik05Import=True,
instructionText=data_instructions)
def connectLane(self, laneIndex):
#.........这里部分代码省略.........
示例12: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, appendBatchOperators=True, *args, **kwargs):
graph = kwargs['graph'] if 'graph' in kwargs else Graph()
if 'graph' in kwargs: del kwargs['graph']
super( CountingWorkflow, self ).__init__( shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs )
self.stored_classifer = None
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument("--csv-export-file", help="Instead of exporting prediction density images, export total counts to the given csv path.")
self.parsed_counting_workflow_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
######################
# Interactive workflow
######################
self.projectMetadataApplet = ProjectMetadataApplet()
self.dataSelectionApplet = DataSelectionApplet(self,
"Input Data",
"Input Data" )
opDataSelection = self.dataSelectionApplet.topLevelOperator
role_names = ['Raw Data']
opDataSelection.DatasetRoles.setValue( role_names )
self.featureSelectionApplet = FeatureSelectionApplet(self,
"Feature Selection",
"FeatureSelections")
self.countingApplet = CountingApplet(workflow=self)
opCounting = self.countingApplet.topLevelOperator
self.dataExportApplet = CountingDataExportApplet(self, "Density Export", opCounting)
# Customization hooks
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_lane_export = self.post_process_lane_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.PmapColors.connect(opCounting.PmapColors)
opDataExport.LabelNames.connect(opCounting.LabelNames)
opDataExport.UpperBound.connect(opCounting.UpperBound)
opDataExport.WorkingDirectory.connect(opDataSelection.WorkingDirectory)
opDataExport.SelectionNames.setValue( ['Probabilities'] )
self._applets = []
self._applets.append(self.projectMetadataApplet)
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.featureSelectionApplet)
self._applets.append(self.countingApplet)
self._applets.append(self.dataExportApplet)
self._batch_input_args = None
self._batch_export_args = None
if appendBatchOperators:
self.batchProcessingApplet = BatchProcessingApplet( self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet )
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( unused_args )
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
示例13: CountingWorkflow
class CountingWorkflow(Workflow):
workflowName = "Cell Density Counting"
workflowDescription = "This is obviously self-explanatory."
defaultAppletIndex = 1 # show DataSelection by default
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, appendBatchOperators=True, *args, **kwargs):
graph = kwargs['graph'] if 'graph' in kwargs else Graph()
if 'graph' in kwargs: del kwargs['graph']
super( CountingWorkflow, self ).__init__( shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs )
self.stored_classifer = None
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument("--csv-export-file", help="Instead of exporting prediction density images, export total counts to the given csv path.")
self.parsed_counting_workflow_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
######################
# Interactive workflow
######################
self.projectMetadataApplet = ProjectMetadataApplet()
self.dataSelectionApplet = DataSelectionApplet(self,
"Input Data",
"Input Data" )
opDataSelection = self.dataSelectionApplet.topLevelOperator
role_names = ['Raw Data']
opDataSelection.DatasetRoles.setValue( role_names )
self.featureSelectionApplet = FeatureSelectionApplet(self,
"Feature Selection",
"FeatureSelections")
self.countingApplet = CountingApplet(workflow=self)
opCounting = self.countingApplet.topLevelOperator
self.dataExportApplet = CountingDataExportApplet(self, "Density Export", opCounting)
# Customization hooks
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_lane_export = self.post_process_lane_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.PmapColors.connect(opCounting.PmapColors)
opDataExport.LabelNames.connect(opCounting.LabelNames)
opDataExport.UpperBound.connect(opCounting.UpperBound)
opDataExport.WorkingDirectory.connect(opDataSelection.WorkingDirectory)
opDataExport.SelectionNames.setValue( ['Probabilities'] )
self._applets = []
self._applets.append(self.projectMetadataApplet)
self._applets.append(self.dataSelectionApplet)
self._applets.append(self.featureSelectionApplet)
self._applets.append(self.countingApplet)
self._applets.append(self.dataExportApplet)
self._batch_input_args = None
self._batch_export_args = None
if appendBatchOperators:
self.batchProcessingApplet = BatchProcessingApplet( self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet )
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( unused_args )
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
@property
def applets(self):
return self._applets
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
def prepareForNewLane(self, laneIndex):
"""
Overridden from Workflow base class.
Called immediately before a new lane is added to the workflow.
"""
# When the new lane is added, dirty notifications will propagate throughout the entire graph.
# This means the classifier will be marked 'dirty' even though it is still usable.
# Before that happens, let's store the classifier, so we can restore it at the end of connectLane(), below.
opCounting = self.countingApplet.topLevelOperator
if opCounting.classifier_cache.Output.ready() and \
not opCounting.classifier_cache._dirty:
self.stored_classifer = opCounting.classifier_cache.Output.value
else:
self.stored_classifer = None
def handleNewLanesAdded(self):
"""
Overridden from Workflow base class.
#.........这里部分代码省略.........
示例14: __init__
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, n_stages, *args, **kwargs):
"""
n_stages: How many iterations of feature selection and pixel classification should be inserted into the workflow.
All other params are just as in PixelClassificationWorkflow
"""
# Create a graph to be shared by all operators
graph = Graph()
super( NewAutocontextWorkflowBase, self ).__init__( shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs )
self.stored_classifers = []
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--retrain', help="Re-train the classifier based on labels stored in project file, and re-save.", action="store_true")
# Parse the creation args: These were saved to the project file when this project was first created.
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
# Parse the cmdline args for the current session.
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
self.retrain = parsed_args.retrain
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right.\n\n"\
"Power users: Optionally use the 'Prediction Mask' tab to supply a binary image that tells ilastik where it should avoid computations you don't need."
self.dataSelectionApplet = self.createDataSelectionApplet()
opDataSelection = self.dataSelectionApplet.topLevelOperator
# see role constants, above
role_names = ['Raw Data', 'Prediction Mask']
opDataSelection.DatasetRoles.setValue( role_names )
self.featureSelectionApplets = []
self.pcApplets = []
for i in range(n_stages):
self.featureSelectionApplets.append( self.createFeatureSelectionApplet(i) )
self.pcApplets.append( self.createPixelClassificationApplet(i) )
opFinalClassify = self.pcApplets[-1].topLevelOperator
# If *any* stage enters 'live update' mode, make sure they all enter live update mode.
def sync_freeze_predictions_settings( slot, *args ):
freeze_predictions = slot.value
for pcApplet in self.pcApplets:
pcApplet.topLevelOperator.FreezePredictions.setValue( freeze_predictions )
for pcApplet in self.pcApplets:
pcApplet.topLevelOperator.FreezePredictions.notifyDirty( sync_freeze_predictions_settings )
self.dataExportApplet = PixelClassificationDataExportApplet(self, "Prediction Export")
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.PmapColors.connect( opFinalClassify.PmapColors )
opDataExport.LabelNames.connect( opFinalClassify.LabelNames )
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
self.EXPORT_NAMES = []
for stage_index in reversed(list(range(n_stages))):
self.EXPORT_NAMES += ["{} Stage {}".format( name, stage_index+1 ) for name in self.EXPORT_NAMES_PER_STAGE]
# And finally, one last item for *all* probabilities from all stages.
self.EXPORT_NAMES += ["Probabilities All Stages"]
opDataExport.SelectionNames.setValue( self.EXPORT_NAMES )
# Expose for shell
self._applets.append(self.dataSelectionApplet)
self._applets += itertools.chain(*list(zip(self.featureSelectionApplets, self.pcApplets)))
self._applets.append(self.dataExportApplet)
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchProcessingApplet.parse_known_cmdline_args( unused_args )
else:
self._batch_input_args = None
self._batch_export_args = None
if unused_args:
logger.warning("Unused command-line args: {}".format( unused_args ))
示例15: NewAutocontextWorkflowBase
class NewAutocontextWorkflowBase(Workflow):
workflowName = "New Autocontext Base"
defaultAppletIndex = 0 # show DataSelection by default
DATA_ROLE_RAW = 0
DATA_ROLE_PREDICTION_MASK = 1
# First export names must match these for the export GUI, because we re-use the ordinary PC gui
# (See PixelClassificationDataExportGui.)
EXPORT_NAMES_PER_STAGE = ['Probabilities', 'Simple Segmentation', 'Uncertainty', 'Features', 'Labels', 'Input']
@property
def applets(self):
return self._applets
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
def __init__(self, shell, headless, workflow_cmdline_args, project_creation_args, n_stages, *args, **kwargs):
"""
n_stages: How many iterations of feature selection and pixel classification should be inserted into the workflow.
All other params are just as in PixelClassificationWorkflow
"""
# Create a graph to be shared by all operators
graph = Graph()
super( NewAutocontextWorkflowBase, self ).__init__( shell, headless, workflow_cmdline_args, project_creation_args, graph=graph, *args, **kwargs )
self.stored_classifers = []
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--retrain', help="Re-train the classifier based on labels stored in project file, and re-save.", action="store_true")
# Parse the creation args: These were saved to the project file when this project was first created.
parsed_creation_args, unused_args = parser.parse_known_args(project_creation_args)
# Parse the cmdline args for the current session.
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
self.retrain = parsed_args.retrain
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right.\n\n"\
"Power users: Optionally use the 'Prediction Mask' tab to supply a binary image that tells ilastik where it should avoid computations you don't need."
self.dataSelectionApplet = self.createDataSelectionApplet()
opDataSelection = self.dataSelectionApplet.topLevelOperator
# see role constants, above
role_names = ['Raw Data', 'Prediction Mask']
opDataSelection.DatasetRoles.setValue( role_names )
self.featureSelectionApplets = []
self.pcApplets = []
for i in range(n_stages):
self.featureSelectionApplets.append( self.createFeatureSelectionApplet(i) )
self.pcApplets.append( self.createPixelClassificationApplet(i) )
opFinalClassify = self.pcApplets[-1].topLevelOperator
# If *any* stage enters 'live update' mode, make sure they all enter live update mode.
def sync_freeze_predictions_settings( slot, *args ):
freeze_predictions = slot.value
for pcApplet in self.pcApplets:
pcApplet.topLevelOperator.FreezePredictions.setValue( freeze_predictions )
for pcApplet in self.pcApplets:
pcApplet.topLevelOperator.FreezePredictions.notifyDirty( sync_freeze_predictions_settings )
self.dataExportApplet = PixelClassificationDataExportApplet(self, "Prediction Export")
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.PmapColors.connect( opFinalClassify.PmapColors )
opDataExport.LabelNames.connect( opFinalClassify.LabelNames )
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
self.EXPORT_NAMES = []
for stage_index in reversed(list(range(n_stages))):
self.EXPORT_NAMES += ["{} Stage {}".format( name, stage_index+1 ) for name in self.EXPORT_NAMES_PER_STAGE]
# And finally, one last item for *all* probabilities from all stages.
self.EXPORT_NAMES += ["Probabilities All Stages"]
opDataExport.SelectionNames.setValue( self.EXPORT_NAMES )
# Expose for shell
self._applets.append(self.dataSelectionApplet)
self._applets += itertools.chain(*list(zip(self.featureSelectionApplets, self.pcApplets)))
self._applets.append(self.dataExportApplet)
self.dataExportApplet.prepare_for_entire_export = self.prepare_for_entire_export
self.dataExportApplet.post_process_entire_export = self.post_process_entire_export
self.batchProcessingApplet = BatchProcessingApplet(self,
"Batch Processing",
self.dataSelectionApplet,
self.dataExportApplet)
self._applets.append(self.batchProcessingApplet)
if unused_args:
# We parse the export setting args first. All remaining args are considered input files by the input applet.
self._batch_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
#.........这里部分代码省略.........