Example #1
0
import Evaluation as E

import DP1 as TD
import scipy.io as io

all_dice = np.array([])

with np.load(
        '/home/xvt131/Biomediq/Functions/Adhish_copy/Exp101/cheat.npz') as f:
    param_values = [f['arr_%d' % i] for i in range(len(f.files))]
lasagne.layers.set_all_param_values(output, param_values)
Dice = []
for img in DP.get_paths("/home/xvt131/Biomediq/Data/kneeData/Validating-Rand"):

    A, B, C = TD.get_indeces(img)
    B1 = B.reshape(np.prod(B.shape))
    batch = 5000
    num_batches = A.shape[0] / batch
    Sha = B.shape

    preds = np.zeros(shape=(len(B1), NC))
    for i in range(num_batches):
        idx = range(i * batch, (i + 1) * batch)
        K = A[idx]
        M, N, O = TD.Patch_gen(K, 29, C)
        preds[idx] = f_eval(M, N, O)
    if num_batches * batch < A.shape[0]:
        tot = num_batches * batch
        K = A[tot:]
        M, N, O = TD.Patch_gen(K, 29, C)
Example #2
0
f_vali = theano.function([input_var, input2_var, input3_var, target_var], [costV])


from confusionmatrix import ConfusionMatrix
batch_size = 10
num_epochs = 175

train_acc= []
valid_acc = []

cur_loss = 0
loss = []
valid_loss = []

	Train = DP.get_paths("/home/xvt131/Biomediq/Validating-Rand")
Test = DP.get_paths("/home/xvt131/Biomediq/Validating-Rand")
import gc
for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(2)
    confusion_train = ConfusionMatrix(2)
    
    for im in Train:
        
        XY, XZ, YZ, Y_train  = DP.Patch_triplanar_para(im, PS)
        num_samples_train = Y_train.shape[0]
        num_batches_train = num_samples_train // batch_size
        for i in range(num_batches_train):
            idx = range(i*batch_size, (i+1)*batch_size)
Example #3
0
f_vali = theano.function([input_var, target_var], [costV])

from confusionmatrix import ConfusionMatrix

batch_size = 100
num_epochs = 10

train_acc = []
valid_acc = []

cur_loss = 0
loss = []
valid_loss = []

Train = DP.get_paths("/home/xvt131/Biomediq/Validating-Rand")
Test = DP.get_paths("/home/xvt131/Biomediq/Validating-Rand")
import gc
for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(2)
    confusion_train = ConfusionMatrix(2)

    for im in Train:

        XY, XZ, Y_train = DP.Patch_3D_para(im, PS, P2)
        num_samples_train = Y_train.shape[0]
        num_batches_train = num_samples_train // batch_size
        for i in range(num_batches_train):
            idx = range(i * batch_size, (i + 1) * batch_size)
Example #4
0
f_vali = theano.function([ input2_var, target_var], [costV])

from confusionmatrix import ConfusionMatrix

batch_size = 10
num_epochs = 5

train_acc= []
valid_acc = []

cur_loss = 0
loss = []
valid_loss = []

Train = DP.get_paths("/home/xvt131/Functions/Adhish_copy/Training-Rand")
Test = DP.get_paths("/home/xvt131/Functions/Adhish_copy/Validating-Rand")

for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(classes)
    confusion_train = ConfusionMatrix(classes)
    B = np.array([])
    Pos = np.empty((0, 1,3))
   
    for im in Train:
        Scan, Y_train, Post  = DP.Sampling(im)
        B = np.int32(np.append(B, Y_train))
        Pos = np.float32(np.vstack((Pos, Post)))
Example #5
0
f_vali = theano.function([input_var, input2_var, input3_var, target_var],
                         [costV])

import Evaluation as E

import DP1 as TD
import scipy.io as io

all_dice = np.array([])

with np.load('/home/xvt131/Functions/Adhish_copy/Exp101/AD.npz') as f:
    param_values = [f['arr_%d' % i] for i in range(len(f.files))]
lasagne.layers.set_all_param_values(output, param_values)
Dice = []
for img in DP.get_paths("/home/xvt131/Functions/Adhish_copy/Validating-Rand"):

    A, B, C = TD.get_indeces(img)
    B1 = B.reshape(np.prod(B.shape))
    batch = 12000
    num_batches = A.shape[0] / batch
    Sha = B.shape

    preds = np.zeros(shape=(A.shape[0], NC))
    for i in range(num_batches):
        idx = range(i * batch, (i + 1) * batch)
        K = A[idx]
        M, N, O = TD.Patch_gen(K, 29, C)
        preds[idx] = f_eval(M, N, O)
    if num_batches * batch < A.shape[0]:
        tot = num_batches * batch
Example #6
0
f_train = theano.function([input_var, input2_var, target_var], [cost],
                          updates=updates)

import Evaluation as E
import DP1 as TD
import scipy.io as io

with np.load(
        "/home/xvt131/Biomediq/Functions/Adhish_copy/Exp101/3dpop.npz") as f:
    param_values = [f['arr_%d' % i] for i in range(len(f.files))]
lasagne.layers.set_all_param_values(output, param_values)
Dice = []
for img in DP.get_paths("/home/xvt131/Biomediq/Data/kneeData/Validating-Rand"):

    A, B, C = TD.get_indeces(img)
    B1 = B.reshape(np.prod(B.shape))
    batch = 10000
    num_batches = A.shape[0] / batch
    Sha = B.shape
    print Sha
    preds = np.zeros(shape=(A.shape[0], NC))
    for i in range(num_batches):
        idx = range(i * batch, (i + 1) * batch)
        K = A[idx]
        M, N = TD.Patch_gen_three(K, PS, PS2, C)
        preds[idx] = f_eval(M, N)
    if num_batches * batch < A.shape[0]:
        tot = num_batches * batch
        K = A[tot:]
        M, N = TD.Patch_gen_three(K, PS, PS2, C)
Example #7
0
f_vali = theano.function([input_var, input2_var, input3_var, target_var],
                         [costV])

from confusionmatrix import ConfusionMatrix

batch_size = 500
num_epochs = 25

train_acc = []
valid_acc = []

cur_loss = 0
loss = []
valid_loss = []

Train = DP.get_paths("/home/xvt131/Functions/Adhish_copy/all_train")
Test = DP.get_paths("/home/xvt131/Functions/Adhish_copy/Validating-Rand")
import gc
for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(2)
    confusion_train = ConfusionMatrix(2)

    for im in Train:

        XY, XZ, YZ, Y_train = DP.Patch_triplanar_para(im, PS)
        num_samples_train = Y_train.shape[0]
        num_batches_train = num_samples_train // batch_size
        for i in range(num_batches_train):
            idx = range(i * batch_size, (i + 1) * batch_size)
Example #8
0
f_train = theano.function([input_var, input2_var, target_var], [cost],
                          updates=updates)

from confusionmatrix import ConfusionMatrix

batch_size = 100
num_epochs = 100

train_acc = []
valid_loss = []
valid_acc = []
train_loss = []
cur_loss = 0
loss = []

Train = DP.get_paths("/home/xvt131/Biomediq/Data/kneeData/allTrain")
Test = DP.get_paths("/home/xvt131/Biomediq/Data/kneeData/Validating-Rand")

for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(2)
    confusion_train = ConfusionMatrix(2)
    # Train = np.random.choice(Train_all, 5)

    for im in Train:
        X_train, XX, Y_train = DP.Patch_3D_para(im, PS, PS2)
        num_samples_train = Y_train.shape[0]
        num_batches_train = num_samples_train // batch_size

        for i in range(num_batches_train):
Example #9
0
                          [cost],
                          updates=updates)

from confusionmatrix import ConfusionMatrix

batch_size = 100
num_epochs = 50

train_acc, train_loss = [], []
valid_acc, valid_loss = [], []
test_acc, test_loss = [], []
cur_loss = 0
loss = []
valid_loss = []

Train = DP.get_paths("/home/xvt131/Functions/Adhish_copy/Training-Rand")
Test = DP.get_paths("/home/xvt131/Functions/Adhish_copy/Validating-Rand")

for epoch in range(num_epochs):
    cur_loss = 0
    val_loss = 0
    confusion_valid = ConfusionMatrix(2)
    confusion_train = ConfusionMatrix(2)

    for im in Train:
        XY, XZ, YZ, Y_train = DP.Patch_gen_mix(im)
        num_samples_train = Y_train.shape[0]
        num_batches_train = num_samples_train // batch_size
        for i in range(num_batches_train):
            idx = range(i * batch_size, (i + 1) * batch_size)
            xy_batch = XY[idx]