コード例 #1
0
ファイル: watershed.py プロジェクト: constantinpape/mc_luigi
def wsdt_nominseg():
    ppl_parameter = PipelineParameter()
    ppl_parameter.useN5Backend = True
    ppl_parameter.read_input_file('./inputs.json')
    ppl_parameter.wsdtMinSeg = 0
    ppl_parameter.nThreads = 8
    ppl_parameter.wsdtInvert = True
    inp = ppl_parameter.inputs['data'][1]

    luigi.run(["--local-scheduler",
               "--pathToProbabilities", inp,
               "--keyToProbabilities", "data"],
              WsdtSegmentation)
コード例 #2
0
ファイル: workflow.py プロジェクト: constantinpape/mc_luigi
def mc():
    ppl_parameter = PipelineParameter()
    # read the json with paths to input files
    ppl_parameter.read_input_file('./inputs.json')
    inputs = ppl_parameter.inputs

    # set the parameters
    ppl_parameter.multicutWeightingScheme = "z"
    ppl_parameter.separateEdgeClassification = True
    ppl_parameter.multicutVerbose = False
    ppl_parameter.ignoreSegLabel = 0
    ppl_parameter.useN5Backend = True

    luigi.run([
        "--local-scheduler", "--pathToSeg", inputs["seg"][0],
        "--pathToClassifier", inputs["rf"]
    ], MulticutSegmentation)
コード例 #3
0
ファイル: workflow.py プロジェクト: constantinpape/mc_luigi
def learn_rf():
    ppl_parameter = PipelineParameter()
    ppl_parameter.read_input_file('./inputs.json')
    inputs = ppl_parameter.inputs
    ppl_parameter.separateEdgeClassification = True
    ppl_parameter.ignoreSegLabel = 0
    ppl_parameter.useN5Backend = True
    ppl_parameter.nTrees = 150

    luigi.run([
        "--local-scheduler", "--pathsToSeg",
        json.dumps(inputs["seg"]), "--pathsToGt",
        json.dumps(inputs["gt"])
    ], LearnClassifierFromGt)
コード例 #4
0
def region_features():
    ppl_parameter = PipelineParameter()
    ppl_parameter.read_input_file('./inputs.json')
    ppl_parameter.useN5Backend = True
    ppl_parameter.ignoreSegLabel = 0
    inputs = ppl_parameter.inputs
    inp = inputs['data'][0]
    seg = inputs["seg"]
    luigi.run(["--local-scheduler", "--pathToInput", inp, "--pathToSeg", seg],
              RegionFeatures)
コード例 #5
0
ファイル: watershed.py プロジェクト: constantinpape/mc_luigi
def wsdt_masked():
    ppl_parameter = PipelineParameter()
    ppl_parameter.useN5Backend = True
    ppl_parameter.read_input_file('./inputs.json')
    inp = ppl_parameter.inputs['data'][1]
    ppl_parameter.nThreads = 8
    ppl_parameter.wsdtInvert = True
    mask = ppl_parameter.inputs['mask']

    luigi.run(["--local-scheduler",
               "--pathToProbabilities", inp,
               "--keyToProbabilities", "data",
               "--pathToMask", mask],
              WsdtSegmentation)
コード例 #6
0
    def test_learnrf(self):
        ppl_parameter = PipelineParameter()
        ppl_parameter.read_input_file('./inputs.json')
        ppl_parameter.useN5Backend = True
        ppl_parameter.useSimpleFeatures = True
        ppl_parameter.ignoreSegLabel = 0
        inputs = ppl_parameter.inputs

        luigi.run([
            "--local-scheduler", "--pathsToSeg",
            json.dumps([inputs["seg"]]), "--pathsToGt",
            json.dumps([inputs["gt"]])
        ], LearnClassifierFromGt)
        self.assertTrue(os.path.exists(inputs["rf"]))
コード例 #7
0
ファイル: watershed.py プロジェクト: constantinpape/boots
def ws_masked(path):
    ppl_params = PipelineParameter()
    ppl_params.wsdtInvert = True
    ppl_params.wsdtThreshold = .2
    ppl_params.wsdtMinSeg = 25
    ppl_params.wsdtSigSeeds = 2.6
    ppl_params.nThreads = 40

    # TODO in the long run, we need the scheduler to check for path and keys
    save_path = os.path.join(path, 'segmentation')
    save_key = 'watershed'

    luigi.run([
        "--local-scheduler", "--pathToProbabilities", path,
        "--keyToProbabilities", "affs_xy_rechunked", "--pathToMask", path,
        "--keyToMask", "min_filter_mask", "--savePath", save_path, "--saveKey",
        save_key
    ],
              main_task_cls=WsdtSegmentation)
コード例 #8
0
ファイル: test_rag.py プロジェクト: constantinpape/mc_luigi
    def test_rag(self):
        ppl_parameter = PipelineParameter()
        ppl_parameter.read_input_file('./inputs.json')
        ppl_parameter.useN5Backend = True
        ppl_parameter.ignoreSegLabel = 0
        inputs = ppl_parameter.inputs
        seg = inputs["seg"]
        luigi.run(["--local-scheduler",
                   "--pathToSeg", seg],
                  StackedRegionAdjacencyGraph)

        n_nodes_expected = z5py.File(seg, use_zarr_format=False)['data'][:].max() + 1
        rag_path = './cache/StackedRegionAdjacencyGraph_sampleA_watershed.h5'
        self.assertTrue(os.path.exists(rag_path))
        n_nodes = vigra.readHDF5(rag_path, 'numberOfNodes')
        self.assertEqual(n_nodes_expected, n_nodes)
コード例 #9
0
def inference(blockwise_inference=True):

    # PipelineParameter is a singleton class that stores most of the
    # relevant parameters for learning and inference
    ppl_parameter = PipelineParameter()

    # read the json with paths to input files
    ppl_parameter.read_input_file('./input_config_test.json')
    inputs = ppl_parameter.inputs
    check_inputs(inputs, check_rf=True)

    # set relevant pipeline parameter for inference
    ppl_parameter.separateEdgeClassification = True  # use seperate random forests for xy / z - edges
    # sub-block shapes for the block-wise multicut
    # -> chosen smaller than defaults due to small test data
    # use default values for larger data
    ppl_parameter.multicutBlockShape   = [15, 256, 256]
    ppl_parameter.multicutBlockOverlap = [2, 10, 10]

    # number of mergign levels in block-wise multicut
    # -> increase if the final multicut for merging the global reduced
    # problem takes too long for converging
    n_levels = 1

    if blockwise_inference:
        # TODO get central scheduler running
        luigi.run(
            ["--local-scheduler",
             "--pathToSeg", inputs["seg"],
             "--pathToClassifier", inputs["rf"],
             "--numberOfLevels", str(n_levels)],
            BlockwiseMulticutSegmentation
        )
    else:
        # TODO get central scheduler running
        luigi.run(
            ["--local-scheduler",
             "--pathToSeg", inputs["seg"],
             "--pathToClassifier", inputs["rf"]],
            MulticutSegmentation
        )
コード例 #10
0
def sub_solver_tests():

    # PipelineParameter is a singleton class that stores most of the
    # relevant parameters for learning and inference
    ppl_parameter = PipelineParameter()

    # read the json with paths to input files
    ppl_parameter.read_input_file('./input_config_test.json')
    inputs = ppl_parameter.inputs

    # set relevant pipeline parameter for inference
    ppl_parameter.separateEdgeClassification = True  # use seperate random forests for xy / z - edges
    # sub-block shapes for the block-wise multicut
    # -> chosen smaller than defaults due to small test data
    # use default values for larger data
    ppl_parameter.multicutBlockShape = [15, 256, 256]
    ppl_parameter.multicutBlockOverlap = [2, 10, 10]

    # TODO get central scheduler running
    luigi.run([
        "--local-scheduler", "--pathToSeg", inputs["seg"],
        "--pathToClassifier", inputs["rf"]
    ], TestSubSolver)
コード例 #11
0
def learning():

    # PipelineParameter is a singleton class that stores most of the
    # relevant parameters for learning and inference
    ppl_parameter = PipelineParameter()

    # read the json with paths to input files
    ppl_parameter.read_input_file('./input_config_train.json')
    inputs = ppl_parameter.inputs
    check_inputs(inputs)

    # set relevant pipeline parameter for learning
    ppl_parameter.separateEdgeClassification = True  # use seperate random forests for xy / z - edges
    ppl_parameter.nTrees = 100  # number of trees used in rf

    # TODO get central scheduler running
    luigi.run([
        "--local-scheduler",
        "--pathsToSeg", json.dumps([inputs["seg"]]),
        "--pathsToGt", json.dumps([inputs["gt"]])],
        LearnClassifierFromGt
    )
コード例 #12
0
ファイル: multicut.py プロジェクト: constantinpape/boots
def multicut(path, use_simple_feats=True):
    ppl_params = PipelineParameter()
    # TODO change to new input file syntax
    cache_folder = os.path.join('/data/papec/cache/',
                                'cache_' + str(md5(path.encode()).hexdigest()))
    inp_file = {
        'data': [path, path, path],
        'cache': cache_folder,
        'seg': path,
        'keys': {
            'data': ['gray', 'affs_xy_rechunked', 'affs_z_rechunked'],
            'seg': 'segmentation/watershed'
        }
    }
    ppl_params.read_input_file(inp_file)

    # TODO expose some of this as parameters
    ppl_params.nThreads = 40
    ppl_params.features = ['affinitiesXY', 'affinitiesZ']
    ppl_params.zAffinityDirection = 2
    ppl_params.separateEdgeClassification = True
    ppl_params.nFeatureChunks = 120
    ppl_params.ignoreSegLabel = 0

    ppl_params.useSimpleFeatures = use_simple_feats

    ppl_params.multicutWeightingScheme = 'xy'
    ppl_params.multicutWeight = 15
    ppl_params.multicutBeta = 0.5

    ppl_params.subSolverType = 'kl'
    ppl_params.globalSolverType = 'kl'

    n_levels = 2

    rf  = '/groups/saalfeld/saalfeldlab/sampleE/cremi_ABC_randomforests' if use_simple_feats \
        else '/groups/saalfeld/saalfeldlab/sampleE/cremi_ABC_randomforests_more_features'

    # dirty hack because gpu 2 does not find /groups/saalfeld/saalfeldlabe
    if not os.path.exists(rf):
        rf = '/groups/saalfeld/home/papec/cremi_ABC_randomforests_more_features'

    save_path = os.path.join(path,
                             'segmentations' if use_simple_feats else 'segs')
    print("saving multicut segmentation to", save_path)
    save_key = 'multicut' if use_simple_feats else 'multicut_more_features'

    luigi.run([
        '--local-scheduler', '--pathToSeg', path, '--keyToSeg', 'watershed',
        '--pathToClassifier', rf, '--numberOfLevels',
        str(n_levels)
    ],
              main_task_cls=BlockwiseMulticutSegmentation)
コード例 #13
0
ファイル: workflow.py プロジェクト: constantinpape/mc_luigi
def blockwise_mc():
    ppl_parameter = PipelineParameter()
    # read the json with paths to input files
    ppl_parameter.read_input_file('./inputs.json')
    inputs = ppl_parameter.inputs

    # set the parameters
    ppl_parameter.multicutWeightingScheme = "z"
    ppl_parameter.separateEdgeClassification = True
    ppl_parameter.multicutVerbose = False
    ppl_parameter.multicutBlockShape = [20, 256, 256]
    ppl_parameter.multicutBlockOverlap = [5, 50, 50]
    ppl_parameter.ignoreSegLabel = 0
    ppl_parameter.useN5Backend = True

    n_levels = 1
    luigi.run([
        "--local-scheduler", "--pathToSeg", inputs["seg"][0],
        "--pathToClassifier", inputs["rf"], "--numberOfLevels",
        str(n_levels)
    ], BlockwiseMulticutSegmentation)