Exemplo n.º 1
0
def OneKfold(i=0, datadict=None):

    k = settings.options.kfolds

    modelloc = TrainModel(idfold=i)
    (train_set, test_set, valid_set) = GetSetupKfolds(settings.options.dbfile,
                                                      k, i)

    sumscore = 0
    sumscorefloat = 0
    for idtest in test_set:
        baseloc = '%s/%03d/%03d' % (settings.options.outdir, k, i)
        imgloc = '%s/%s' % (settings.options.rootlocation,
                            datadict[idtest]['image'])
        segloc = '%s/%s' % (settings.options.rootlocation,
                            datadict[idtest]['label'])
        outloc = '%s/label-%04d.nii.gz' % (baseloc, idtest)
        if settings.options.numepochs > 0 and (
                settings.options.makepredictions
                or settings.options.makedropoutmap):

            if settings.options.makepredictions:
                predseg, predfloat = PredictModel(model=modelloc,
                                                  image=imgloc,
                                                  outdir=outloc)
            else:
                predseg, predfloat = PredictDropout(model=modelloc,
                                                    image=imgloc,
                                                    outdir=outloc,
                                                    seg=segloc)
Exemplo n.º 2
0
import settings

from settings import process_options, perform_setup
(options, args) = process_options()

IMG_DTYPE, SEG_DTYPE, _globalnpfile, _globalexpectedpixel, _nx, _ny = perform_setup(
    options)
print('database file: %s ' % settings._globalnpfile)

from setupmodel import GetDataDictionary, BuildDB
from trainmodel import TrainModel
from predictmodel import PredictModel
from kfolds import OneKfold, Kfold

if options.builddb:
    BuildDB()
if options.kfolds > 1:
    if options.idfold > -1:
        databaseinfo = GetDataDictionary(options.dbfile)
        OneKfold(i=options.idfold, datadict=databaseinfo)
    else:
        Kfold()
if options.trainmodel and options.kfolds == 1:  # no kfolds, i.e. k=1
    TrainModel()
if options.predictmodel:
    PredictModel()
if ((not options.builddb) and (not options.trainmodel)
        and (not options.predictmodel) and (options.kfolds == 1)):
    print("parser error")
Exemplo n.º 3
0
import settings

from settings import process_options, perform_setup
(options, args) = process_options()

IMG_DTYPE, SEG_DTYPE, _globalnpfile, _globalexpectedpixel, _nx, _ny = perform_setup(
    options)
print('database file: %s ' % settings._globalnpfile)

from setupmodel import GetDataDictionary, BuildDB
from trainmodel import TrainModel
from predictmodel import PredictModel
from kfolds import OneKfold, Kfold

if options.builddb:
    BuildDB()
if options.kfolds > 1:
    if options.idfold > -1:
        databaseinfo = GetDataDictionary(options.dbfile)
        OneKfold(i=options.idfold, datadict=databaseinfo)
    else:
        Kfold()
if options.trainmodel and options.kfolds == 1:  # no kfolds, i.e. k=1
    TrainModel()
if options.predictmodel:
    segloc = options.predictimage.replace("volume", "segmentation")
    PredictModel(seg=segloc)
if ((not options.builddb) and (not options.trainmodel)
        and (not options.predictmodel) and (options.kfolds == 1)):
    print("parser error")