Пример #1
0
from CommonUtil.FileReaders import *
from CommonUtil.FileDataManager import *
from CommonUtil.PlotsManager import *
from CommonUtil.WorkDirsManager import *
from Networks.Metrics import *
from Networks.Networks import *
import numpy as np

BATCH_SIZE = 1

FORMATOUTIMAGES = 'nifti'

IMODEL = 'Unet3D'

#MAIN
workDirsManager = WorkDirsManager(BASEDIR)
RawMasksDataPath= workDirsManager.getNameNewPath(workDirsManager.getNameTestingDataPath(), 'RawMasks')
TestingDataPath = workDirsManager.getNameNewPath(workDirsManager.getNameTestingDataPath(), 'ProcVolsData')
PredictMasksPath= workDirsManager.getNameNewPath(BASEDIR, 'Predictions')
ModelsPath      = workDirsManager.getNameModelsPath()


print('-' * 30)
print('Loading saved weights...')
print('-' * 30)

model = DICTAVAILNETWORKS3D[IMODEL].getModel(IMAGES_DEPTHZ, IMAGES_HEIGHT, IMAGES_WIDTH)
model.summary()

weightsPath = ModelsPath + '/bestModel.hdf5'
model.load_weights(weightsPath)
# Last update: 09/02/2018
########################################################################################

from CommonUtil.Constants import *
from CommonUtil.FileReaders import *
from CommonUtil.FileDataManager import *
from CommonUtil.PlotsManager import *
from CommonUtil.WorkDirsManager import *
from Networks.Metrics import *
from Networks.Networks import *
from glob import glob
import numpy as np
import os

#MAIN
workDirsManager = WorkDirsManager(BASEDIR)
InputDICOMfilesPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameTestingDataPath(), 'RawMasks')
OutputDICOMfilesPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameTestingDataPath(), 'RawMasks')
ModelsPath = workDirsManager.getNameModelsPath()

# LOADING DATA
# ----------------------------------------------
print('-' * 30)
print('Loading data...')
print('-' * 30)

listInputDICOMFiles = sorted(glob(InputDICOMfilesPath + '/av*.dcm'))

for inputDICOMfile in listInputDICOMFiles:
Пример #3
0
# Medical Informatics
#
# created on 09/02/2018
# Last update: 09/02/2018
########################################################################################

from CommonUtil.Constants import *
from CommonUtil.WorkDirsManager import *
from CommonUtil.PlotsManager import *
from CommonUtil.ErrorMessages import *
import sys

TYPEDATA = 'training'

# MAIN
workDirsManager = WorkDirsManager(BASEDIR)
DataPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameTrainingDataPath(), 'ProcSlicesData')

# Get the file list:
listImagesFiles = sorted(glob(DataPath + '/slicesImages*.npy'))
listMasksFiles = sorted(glob(DataPath + '/slicesMasks*.npy'))

for imageFile, maskFile in zip(listImagesFiles, listMasksFiles):

    images_array = np.load(imageFile).astype(FORMATIMAGEDATA)
    masks_array = np.load(maskFile).astype(FORMATMASKDATA)

    print('Number training images: %s' % (images_array.shape[0]))

    PlotsManager.plot_image_mask_2D(images_array, masks_array)
Пример #4
0
from keras.preprocessing import image as Kpreprocessing
import time

NBEPOCHS = 500
BATCH_SIZE = 1
LEARN_RATE = 1.0e-05

IMODEL = 'Unet3D'
IOPTIMIZER = 'Adam'

USE_DATAAUGMENTATION = False

USE_RESTARTMODEL = False

#MAIN
workDirsManager = WorkDirsManager(BASEDIR)
TrainingDataPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameTrainingDataPath(), 'ProcVolsData')
ValidationDataPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameValidationDataPath(), 'ProcVolsData')
TestingDataPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameTestingDataPath(), 'ProcVolsData')
ModelsPath = workDirsManager.getNameModelsPath()

# LOADING DATA
# ----------------------------------------------
print('-' * 30)
print('Loading data...')
print('-' * 30)

listTrainImagesFiles = sorted(glob(TrainingDataPath + '/volsImages*.npy'))
# Last update: 09/02/2018
########################################################################################

from CommonUtil.Constants import *
from CommonUtil.FileDataManager import *
from CommonUtil.PlotsManager import *
from CommonUtil.WorkDirsManager import *
from Networks.Metrics import *
from Networks.Networks import *

BATCH_SIZE = 12

IMODEL = 'Unet2D'

#MAIN
workDirsManager = WorkDirsManager(BASEDIR)
TestingDataPath = workDirsManager.getNameTestingDataPath()
ModelsPath      = workDirsManager.getNameModelsPath()


# LOADING DATA
# ----------------------------------------------
print('-' * 30)
print('Loading data...')
print('-' * 30)

listTestImagesFiles = sorted(glob(TestingDataPath + 'images*.npy'))
listTestMasksFiles  = sorted(glob(TestingDataPath + 'masks*.npy' ))

(xTest, yTest) = FileDataManager.loadDataListFiles2D(listTestImagesFiles, listTestMasksFiles)
Пример #6
0
# Medical Informatics
#
# created on 09/02/2018
# Last update: 09/02/2018
########################################################################################

from CommonUtil.Constants import *
from CommonUtil.WorkDirsManager import *
from CommonUtil.PlotsManager import *
from CommonUtil.ErrorMessages import *
import sys

TYPEDATA = 'testing'

# MAIN
workDirsManager = WorkDirsManager(BASEDIR)
DataPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameDataPath(TYPEDATA), 'ProcVolsData')
OutFilesPath = workDirsManager.getNameNewPath(
    workDirsManager.getNameDataPath(TYPEDATA), 'VisualCases')

# Get the file list:
listImagesFiles = sorted(glob(DataPath + '/volsImages*.npy'))
listMasksFiles = sorted(glob(DataPath + '/volsMasks*.npy'))

for imageFile, maskFile in zip(listImagesFiles, listMasksFiles):

    images_array = np.load(imageFile).astype(FORMATIMAGEDATA)
    masks_array = np.load(maskFile).astype(FORMATMASKDATA)

    print('Number training images: %s' % (images_array.shape[0]))