Esempio n. 1
0
import os

import numpy as np

from protoclass.preprocessing import StandardTimeNormalization

path_root = '/data/prostate/pre-processing/lemaitre-2016-nov/norm-objects'

shift_patient = []

# We have to open each npy file
for root, dirs, files in os.walk(path_root):

    # Create the string for the file to read
    for f in files:
        filename = os.path.join(root, f)

        # Load the normalization object
        dce_norm = StandardTimeNormalization.load_from_pickles(filename)

        shift_patient.append(dce_norm.fit_params_['shift-int'])

# Stack the different array vetically
shift_patient = np.vstack(shift_patient)
shift_patient = np.max(shift_patient, axis=0)
Esempio n. 2
0
    # Load the testing data that correspond to the index of the LOPO
    # Create the object for the DCE
    dce_mod = DCEModality()
    dce_mod.read_data_from_path(path_patients_list_dce[idx_pat])
    print 'Read the DCE data for the current patient ...'

    # Create the corresponding ground-truth
    gt_mod = GTModality()
    gt_mod.read_data_from_path(label_gt,
                               path_patients_list_gt[idx_pat])
    print 'Read the GT data for the current patient ...'

    # Load the approproate normalization object
    filename_norm = (id_patient_list[idx_pat].lower().replace(' ', '_') +
                     '_norm.p')
    dce_norm = StandardTimeNormalization.load_from_pickles(
        os.path.join(path_norm, filename_norm))

    dce_mod = dce_norm.normalize(dce_mod)

    # Create the object to extrac data
    dce_ese = EnhancementSignalExtraction(DCEModality())

    # Concatenate the training data
    data = dce_ese.transform(dce_mod, gt_mod, label_gt[0])
    # Check that the path is existing
    if not os.path.exists(path_store):
        os.makedirs(path_store)
    pat_chg = (id_patient_list[idx_pat].lower().replace(' ', '_') +
               '_ese_' + '_dce.npy')
    filename = os.path.join(path_store, pat_chg)
    np.save(filename, data)
    brix_ext = BrixQuantificationExtraction(DCEModality())

    # Read the DCE
    print 'Read DCE images'
    dce_mod = DCEModality()
    dce_mod.read_data_from_path(p_dce)

    # Read the GT
    print 'Read GT images'
    gt_mod = GTModality()
    gt_mod.read_data_from_path(label_gt, p_gt)

    # Load the approproate normalization object
    filename_norm = (pat.lower().replace(' ', '_') +
                     '_norm.p')
    dce_norm = StandardTimeNormalization.load_from_pickles(
        os.path.join(path_norm, filename_norm))

    dce_mod = dce_norm.normalize(dce_mod)

    for idx in range(dce_mod.data_.shape[0]):
        dce_mod.data_[idx, :] += shift[idx]

    dce_mod.update_histogram()

    # Fit the parameters for Brix
    print 'Extract Brix'
    brix_ext.fit(dce_mod, ground_truth=gt_mod, cat=label_gt[0])

    # Extract the matrix
    print 'Extract the feature matrix'
    data = brix_ext.transform(dce_mod, ground_truth=gt_mod, cat=label_gt[0])
Esempio n. 4
0
import os

import numpy as np

from protoclass.preprocessing import StandardTimeNormalization

path_root = '/data/prostate/pre-processing/lemaitre-2016-nov/norm-objects'


shift_patient = []

# We have to open each npy file
for root, dirs, files in os.walk(path_root):

    # Create the string for the file to read
    for f in files:
        filename = os.path.join(root, f)

        # Load the normalization object
        dce_norm = StandardTimeNormalization.load_from_pickles(filename)

        shift_patient.append(dce_norm.fit_params_['shift-int'])

# Stack the different array vetically
shift_patient = np.vstack(shift_patient)
shift_patient = np.max(shift_patient, axis=0)