本文整理汇总了Python中ilastik.applets.dataSelection.DataSelectionApplet.parse_known_cmdline_args方法的典型用法代码示例。如果您正苦于以下问题:Python DataSelectionApplet.parse_known_cmdline_args方法的具体用法?Python DataSelectionApplet.parse_known_cmdline_args怎么用?Python DataSelectionApplet.parse_known_cmdline_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilastik.applets.dataSelection.DataSelectionApplet
的用法示例。
在下文中一共展示了DataSelectionApplet.parse_known_cmdline_args方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onProjectLoaded
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
def onProjectLoaded(self, projectManager):
"""
Overridden from Workflow base class. Called by the Project Manager.
If the user provided command-line arguments, apply them to the workflow operators.
Currently, we support command-line configuration of:
- DataSelection
- Preprocessing, in which case preprocessing is immediately executed
"""
# If input data files were provided on the command line, configure the DataSelection applet now.
# (Otherwise, we assume the project already had a dataset selected.)
input_data_args, unused_args = DataSelectionApplet.parse_known_cmdline_args(self.workflow_cmdline_args, DATA_ROLES)
if input_data_args.raw_data:
self.dataSelectionApplet.configure_operator_with_parsed_args(input_data_args)
#
# Parse the remaining cmd-line arguments
#
filter_indexes = { 'bright-lines' : OpFilter.HESSIAN_BRIGHT,
'dark-lines' : OpFilter.HESSIAN_DARK,
'step-edges' : OpFilter.STEP_EDGES,
'original' : OpFilter.RAW,
'inverted' : OpFilter.RAW_INVERTED }
parser = argparse.ArgumentParser()
parser.add_argument('--run-preprocessing', action='store_true')
parser.add_argument('--preprocessing-sigma', type=float, required=False)
parser.add_argument('--preprocessing-filter', required=False, type=str.lower,
choices=filter_indexes.keys())
parsed_args, unused_args = parser.parse_known_args(unused_args)
if unused_args:
logger.warn("Did not use the following command-line arguments: {}".format(unused_args))
# Execute pre-processing.
if parsed_args.run_preprocessing:
if len(self.preprocessingApplet.topLevelOperator) != 1:
raise RuntimeError("Can't run preprocessing on a project with no images.")
opPreprocessing = self.preprocessingApplet.topLevelOperator.getLane(0) # Carving has only one 'lane'
# If user provided parameters, override the defaults.
if parsed_args.preprocessing_sigma is not None:
opPreprocessing.Sigma.setValue(parsed_args.preprocessing_sigma)
if parsed_args.preprocessing_filter:
filter_index = filter_indexes[parsed_args.preprocessing_filter]
opPreprocessing.Filter.setValue(filter_index)
logger.info("Running Preprocessing...")
opPreprocessing.PreprocessedData[:].wait()
logger.info("FINISHED Preprocessing...")
logger.info("Saving project...")
self._shell.projectManager.saveProject()
logger.info("Done saving.")
示例2: parse_known_cmdline_args
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
def parse_known_cmdline_args(self, cmdline_args):
# We use the same parser as the DataSelectionApplet
role_names = self.dataSelectionApplet.topLevelOperator.DatasetRoles.value
parsed_args, unused_args = DataSelectionApplet.parse_known_cmdline_args(cmdline_args, role_names)
return parsed_args, unused_args
示例3: PixelClassificationWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
#.........这里部分代码省略.........
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._batch_input_args = None
self._batch_export_args = None
self.batchInputApplet = None
self.batchResultsApplet = None
if appendBatchOperators:
# Create applets for batch workflow
self.batchInputApplet = DataSelectionApplet(self, "Batch Prediction Input Selections", "Batch Inputs", supportIlastik05Import=False, batchDataGui=True)
self.batchResultsApplet = PixelClassificationDataExportApplet(self, "Batch Prediction Output Locations", isBatch=True)
# Expose in shell
self._applets.append(self.batchInputApplet)
self._applets.append(self.batchResultsApplet)
# Connect batch workflow (NOT lane-based)
self._initBatchWorkflow()
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.batchResultsApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchInputApplet.parse_known_cmdline_args( unused_args )
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
def connectLane(self, laneIndex):
# Get a handle to each operator
opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opTrainingFeatures = self.featureSelectionApplet.topLevelOperator.getLane(laneIndex)
opClassify = self.pcApplet.topLevelOperator.getLane(laneIndex)
opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
# Input Image -> Feature Op
# and -> Classification Op (for display)
opTrainingFeatures.InputImage.connect( opData.Image )
opClassify.InputImages.connect( opData.Image )
if ilastik_config.getboolean('ilastik', 'debug'):
opClassify.PredictionMasks.connect( opData.ImageGroup[self.DATA_ROLE_PREDICTION_MASK] )
# Feature Images -> Classification Op (for training, prediction)
opClassify.FeatureImages.connect( opTrainingFeatures.OutputImage )
opClassify.CachedFeatureImages.connect( opTrainingFeatures.CachedOutputImage )
# Training flags -> Classification Op (for GUI restrictions)
opClassify.LabelsAllowedFlags.connect( opData.AllowLabels )
# Data Export connections
opDataExport.RawData.connect( opData.ImageGroup[self.DATA_ROLE_RAW] )
opDataExport.RawDatasetInfo.connect( opData.DatasetGroup[self.DATA_ROLE_RAW] )
opDataExport.ConstraintDataset.connect( opData.ImageGroup[self.DATA_ROLE_RAW] )
opDataExport.Inputs.resize( len(self.EXPORT_NAMES) )
示例4: DataConversionWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
class DataConversionWorkflow(Workflow):
"""
Simple workflow for converting data between formats. Has only two applets: Data Selection and Data Export.
Also supports a command-line interface for headless mode.
For example:
.. code-block:: bash
python ilastik.py --headless --new_project=NewTemporaryProject.ilp --workflow=DataConversionWorkflow --output_format="png sequence" ~/input1.h5 ~/input2.h5
Or if you have an existing project with input files already selected and configured:
.. code-block:: bash
python ilastik.py --headless --project=MyProject.ilp --output_format=jpeg
.. 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 = []
# Create applets
self.dataSelectionApplet = DataSelectionApplet(self,
"Input Data",
"Input Data",
supportIlastik05Import=True,
batchDataGui=False,
force5d=False)
opDataSelection = self.dataSelectionApplet.topLevelOperator
role_names = ["Input Data"]
opDataSelection.DatasetRoles.setValue( role_names )
self.dataExportApplet = DataExportApplet(self, "Data Export")
opDataExport = self.dataExportApplet.topLevelOperator
opDataExport.WorkingDirectory.connect( opDataSelection.WorkingDirectory )
opDataExport.SelectionNames.setValue( ["Input"] )
self._applets.append( self.dataSelectionApplet )
self._applets.append( self.dataExportApplet )
# Parse command-line arguments
# Command-line args are applied in onProjectLoaded(), below.
self._workflow_cmdline_args = workflow_cmdline_args
self._data_input_args = None
self._data_export_args = None
if workflow_cmdline_args:
self._data_export_args, unused_args = self.dataExportApplet.parse_known_cmdline_args( unused_args )
self._data_input_args, unused_args = self.dataSelectionApplet.parse_known_cmdline_args( workflow_cmdline_args, role_names )
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
def onProjectLoaded(self, projectManager):
"""
Overridden from Workflow base class. Called by the Project Manager.
If the user provided command-line arguments, use them to configure
the workflow inputs and output settings.
"""
# Configure the batch data selection operator.
if self._data_input_args and self._data_input_args.input_files:
self.dataSelectionApplet.configure_operator_with_parsed_args( self._data_input_args )
# Configure the data export operator.
if self._data_export_args:
self.dataExportApplet.configure_operator_with_parsed_args( self._data_export_args )
if self._headless and self._data_input_args and self._data_export_args:
# Now run the export and report progress....
opDataExport = self.dataExportApplet.topLevelOperator
for i, opExportDataLaneView in enumerate(opDataExport):
logger.info( "Exporting file #{} to {}".format(i, opExportDataLaneView.ExportPath.value) )
sys.stdout.write( "Result #{}/{} Progress: ".format( i, len( opDataExport ) ) )
def print_progress( progress ):
sys.stdout.write( "{} ".format( progress ) )
# If the operator provides a progress signal, use it.
slotProgressSignal = opExportDataLaneView.progressSignal
slotProgressSignal.subscribe( print_progress )
opExportDataLaneView.run_export()
# Finished.
sys.stdout.write("\n")
def connectLane(self, laneIndex):
opDataSelectionView = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opDataExportView = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
#.........这里部分代码省略.........
示例5: WsdtWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
class WsdtWorkflow(Workflow):
workflowName = "Watershed Over Distance Transform"
workflowDescription = "A bare-bones workflow for using the WSDT applet"
defaultAppletIndex = 0 # show DataSelection by default
DATA_ROLE_RAW = 0
DATA_ROLE_PROBABILITIES = 1
ROLE_NAMES = ['Raw Data', 'Probabilities']
EXPORT_NAMES = ['Watershed']
@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_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 ))
def connectLane(self, laneIndex):
"""
Override from base class.
"""
opDataSelection = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opWsdt = self.wsdtApplet.topLevelOperator.getLane(laneIndex)
opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
# watershed inputs
opWsdt.RawData.connect( opDataSelection.ImageGroup[self.DATA_ROLE_RAW] )
opWsdt.Input.connect( opDataSelection.ImageGroup[self.DATA_ROLE_PROBABILITIES] )
# DataExport inputs
opDataExport.RawData.connect( opDataSelection.ImageGroup[self.DATA_ROLE_RAW] )
opDataExport.RawDatasetInfo.connect( opDataSelection.DatasetGroup[self.DATA_ROLE_RAW] )
opDataExport.Inputs.resize( len(self.EXPORT_NAMES) )
opDataExport.Inputs[0].connect( opWsdt.Superpixels )
for slot in opDataExport.Inputs:
assert slot.partner is not None
def onProjectLoaded(self, projectManager):
"""
Overridden from Workflow base class. Called by the Project Manager.
If the user provided command-line arguments, use them to configure
the workflow inputs and output settings.
"""
# Configure the data export operator.
#.........这里部分代码省略.........
示例6: DataConversionWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
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: ObjectClassificationWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
#.........这里部分代码省略.........
self.blockwiseObjectClassificationApplet = BlockwiseObjectClassificationApplet(
self, "Blockwise Object Classification", "Blockwise Object Classification")
self._applets.append(self.blockwiseObjectClassificationApplet)
self.batchExportApplet = ObjectClassificationDataExportApplet(
self, "Batch Object Prediction Export", isBatch=True)
opBatchDataExport = self.batchExportApplet.topLevelOperator
opBatchDataExport.WorkingDirectory.connect( self.dataSelectionApplet.topLevelOperator.WorkingDirectory )
self._applets.append(self.dataSelectionAppletBatch)
self._applets.append(self.batchExportApplet)
self._initBatchWorkflow()
self._batch_export_args = None
self._batch_input_args = None
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" )
# TODO: Support this, too, someday?
#export_arg_parser.add_argument( "--export_object_label_img", action="store_true" )
if self.input_types == 'raw':
export_arg_parser.add_argument( "--export_pixel_probability_img", action="store_true" )
self._export_args, unused_args = export_arg_parser.parse_known_args(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.batchExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.dataSelectionAppletBatch.parse_known_cmdline_args( unused_args )
if unused_args:
warnings.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 connectLane(self, laneIndex):
rawslot, binaryslot = self.connectInputs(laneIndex)
opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opObjExtraction = self.objectExtractionApplet.topLevelOperator.getLane(laneIndex)
opObjClassification = self.objectClassificationApplet.topLevelOperator.getLane(laneIndex)
opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
opObjExtraction.RawImage.connect(rawslot)
opObjExtraction.BinaryImage.connect(binaryslot)
opObjClassification.RawImages.connect(rawslot)
opObjClassification.LabelsAllowedFlags.connect(opData.AllowLabels)
opObjClassification.BinaryImages.connect(binaryslot)
opObjClassification.SegmentationImages.connect(opObjExtraction.LabelImage)
opObjClassification.ObjectFeatures.connect(opObjExtraction.RegionFeatures)
opObjClassification.ComputedFeatureNames.connect(opObjExtraction.ComputedFeatureNames)
示例8: ObjectClassificationWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
#.........这里部分代码省略.........
else:
assert False, "Unknown object classification subclass type."
self.blockwiseObjectClassificationApplet = BlockwiseObjectClassificationApplet(
self, "Blockwise Object Classification", "Blockwise Object Classification")
self._applets.append(self.blockwiseObjectClassificationApplet)
self.batchExportApplet = ObjectClassificationDataExportApplet(
self, "Batch Object Prediction Export", isBatch=True)
opBatchDataExport = self.batchExportApplet.topLevelOperator
opBatchDataExport.WorkingDirectory.connect( self.dataSelectionApplet.topLevelOperator.WorkingDirectory )
self._applets.append(self.dataSelectionAppletBatch)
self._applets.append(self.batchExportApplet)
self._initBatchWorkflow()
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" )
# TODO: Support this, too, someday?
#export_arg_parser.add_argument( "--export_object_label_img", action="store_true" )
if self.input_types == 'raw':
export_arg_parser.add_argument( "--export_pixel_probability_img", action="store_true" )
self._export_args, unused_args = export_arg_parser.parse_known_args(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.batchExportApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.dataSelectionAppletBatch.parse_known_cmdline_args( unused_args )
if unused_args:
warnings.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 connectLane(self, laneIndex):
rawslot, binaryslot = self.connectInputs(laneIndex)
opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opObjExtraction = self.objectExtractionApplet.topLevelOperator.getLane(laneIndex)
opObjClassification = self.objectClassificationApplet.topLevelOperator.getLane(laneIndex)
opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
opObjExtraction.RawImage.connect(rawslot)
opObjExtraction.BinaryImage.connect(binaryslot)
opObjClassification.RawImages.connect(rawslot)
opObjClassification.LabelsAllowedFlags.connect(opData.AllowLabels)
opObjClassification.BinaryImages.connect(binaryslot)
opObjClassification.SegmentationImages.connect(opObjExtraction.LabelImage)
opObjClassification.ObjectFeatures.connect(opObjExtraction.RegionFeatures)
opObjClassification.ComputedFeatureNames.connect(opObjExtraction.ComputedFeatureNames)
示例9: PixelClassificationWorkflow
# 需要导入模块: from ilastik.applets.dataSelection import DataSelectionApplet [as 别名]
# 或者: from ilastik.applets.dataSelection.DataSelectionApplet import parse_known_cmdline_args [as 别名]
class PixelClassificationWorkflow(Workflow):
workflowName = "Pixel Classification"
workflowDescription = "This is obviously self-explanoratory."
defaultAppletIndex = 1 # show DataSelection by default
@property
def applets(self):
return self._applets
@property
def imageNameListSlot(self):
return self.dataSelectionApplet.topLevelOperator.ImageName
def __init__(self, shell, headless, workflow_cmdline_args, appendBatchOperators=True, *args, **kwargs):
# Create a graph to be shared by all operators
graph = Graph()
super( PixelClassificationWorkflow, self ).__init__( shell, headless, graph=graph, *args, **kwargs )
self._applets = []
self._workflow_cmdline_args = workflow_cmdline_args
data_instructions = "Select your input data using the 'Raw Data' tab shown on the right"
# Parse workflow-specific command-line args
parser = argparse.ArgumentParser()
parser.add_argument('--filter', help="pixel feature filter implementation.", choices=['Original', 'Refactored', 'Interpolated'], default='Original')
parsed_args, unused_args = parser.parse_known_args(workflow_cmdline_args)
self.filter_implementation = parsed_args.filter
# Applets for training (interactive) workflow
self.projectMetadataApplet = ProjectMetadataApplet()
self.dataSelectionApplet = DataSelectionApplet( self,
"Input Data",
"Input Data",
supportIlastik05Import=True,
batchDataGui=False,
instructionText=data_instructions )
opDataSelection = self.dataSelectionApplet.topLevelOperator
opDataSelection.DatasetRoles.setValue( ['Raw Data'] )
self.featureSelectionApplet = FeatureSelectionApplet(self, "Feature Selection", "FeatureSelections", self.filter_implementation)
self.pcApplet = PixelClassificationApplet(self, "PixelClassification")
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 )
# 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._batch_input_args = None
self._batch_export_args = None
self.batchInputApplet = None
self.batchResultsApplet = None
if appendBatchOperators:
# Create applets for batch workflow
self.batchInputApplet = DataSelectionApplet(self, "Batch Prediction Input Selections", "Batch Inputs", supportIlastik05Import=False, batchDataGui=True)
self.batchResultsApplet = PixelClassificationDataExportApplet(self, "Batch Prediction Output Locations", isBatch=True)
# Expose in shell
self._applets.append(self.batchInputApplet)
self._applets.append(self.batchResultsApplet)
# Connect batch workflow (NOT lane-based)
self._initBatchWorkflow()
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.batchResultsApplet.parse_known_cmdline_args( unused_args )
self._batch_input_args, unused_args = self.batchInputApplet.parse_known_cmdline_args( unused_args )
if unused_args:
logger.warn("Unused command-line args: {}".format( unused_args ))
def connectLane(self, laneIndex):
# Get a handle to each operator
opData = self.dataSelectionApplet.topLevelOperator.getLane(laneIndex)
opTrainingFeatures = self.featureSelectionApplet.topLevelOperator.getLane(laneIndex)
opClassify = self.pcApplet.topLevelOperator.getLane(laneIndex)
opDataExport = self.dataExportApplet.topLevelOperator.getLane(laneIndex)
# Input Image -> Feature Op
# and -> Classification Op (for display)
opTrainingFeatures.InputImage.connect( opData.Image )
opClassify.InputImages.connect( opData.Image )
# Feature Images -> Classification Op (for training, prediction)
opClassify.FeatureImages.connect( opTrainingFeatures.OutputImage )
opClassify.CachedFeatureImages.connect( opTrainingFeatures.CachedOutputImage )
# Training flags -> Classification Op (for GUI restrictions)
#.........这里部分代码省略.........