Beispiel #1
0
def find_normalization_params(pat_dce, pat_gt, label, pat_model):
    # Create the normalization object and load the model
    dce_norm = StandardTimeNormalization(DCEModality())
    dce_norm.load_model(pat_model)

    # Read the DCE
    dce_mod = DCEModality()
    dce_mod.read_data_from_path(pat_dce)

    # Read the GT
    gt_mod = GTModality()
    gt_mod.read_data_from_path(label, pat_gt)

    # Find the normalization parameters
    dce_norm.fit(dce_mod, ground_truth=gt_mod, cat=label[0])

    return dce_norm
Beispiel #2
0
from protoclass.data_management import DCEModality
from protoclass.data_management import GTModality

from protoclass.preprocessing import StandardTimeNormalization

# Define the path for the DCE
path_dce = '/data/prostate/experiments/Patient 383/DCE'

# Define the list of path for the GT
path_gt = ['/data/prostate/experiments/Patient 383/GT_inv/prostate']
# Define the associated list of label for the GT
label_gt = ['prostate']

# Read the DCE
dce_mod = DCEModality()
dce_mod.read_data_from_path(path_dce)

# Read the GT
gt_mod = GTModality()
gt_mod.read_data_from_path(label_gt, path_gt)

# Create the object to normalize the DCE data
dce_norm = StandardTimeNormalization(dce_mod)
# Fit the data to get the normalization parameters
dce_norm.partial_fit_model(dce_mod, ground_truth=gt_mod,
                           cat='prostate')

print dce_norm.model_

# Define the path for the DCE
Beispiel #3
0
                   if os.path.isdir(os.path.join(path_patients, name))]
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(os.path.join(path_patients, id_patient,
                                               path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append([os.path.join(path_patients, id_patient,
                                               path_gt)])

for p_dce, p_gt, pat in zip(path_patients_list_dce, path_patients_list_gt,
                            id_patient_list):

    print 'Processing #{}'.format(pat)

    # Create the Tofts Extractor
    tofts_ext = ToftsQuantificationExtraction(DCEModality(), T10, CA)

    # 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)

    # Fit the parameters for Tofts
    print 'Extract Tofts parameters'
    tofts_ext.fit(dce_mod, ground_truth=gt_mod, cat=label_gt[0], fit_aif=True)
Beispiel #4
0
]
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(
        os.path.join(path_patients, id_patient, path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append(
        [os.path.join(path_patients, id_patient, path_gt)])

for p_dce, p_gt, pat in zip(path_patients_list_dce, path_patients_list_gt,
                            id_patient_list):

    print 'Processing #{}'.format(pat)

    # Create the Tofts Extractor
    pun_ext = PUNQuantificationExtraction(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)

    # Fit the parameters for Brix
    print 'Extract Weibull'
    pun_ext.fit(dce_mod, ground_truth=gt_mod, cat=label_gt[0])
Beispiel #5
0
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(os.path.join(path_patients, id_patient,
                                              path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append([os.path.join(path_patients, id_patient, gt)
                                 for gt in path_gt])

# Load all the data once. Splitting into training and testing will be done at
# the cross-validation time
for idx_pat in range(len(id_patient_list)):
    print 'Read patient {}'.format(id_patient_list[idx_pat])

    # 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))
                   if os.path.isdir(os.path.join(path_patients, name))]
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(os.path.join(path_patients, id_patient,
                                               path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append([os.path.join(path_patients, id_patient,
                                               path_gt)])

for p_dce, p_gt, pat in zip(path_patients_list_dce, path_patients_list_gt,
                            id_patient_list):

    print 'Processing #{}'.format(pat)

    # Create the Tofts Extractor
    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)

    # Fit the parameters for Brix
    print 'Extract Brix'
    brix_ext.fit(dce_mod, ground_truth=gt_mod, cat=label_gt[0])
Beispiel #7
0
# Generate the different path to be later treated
path_patients_list_dce = []
path_patients_list_gt = []
# Create the generator
id_patient_list = (name for name in os.listdir(path_patients)
                   if os.path.isdir(os.path.join(path_patients, name)))
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(os.path.join(path_patients, id_patient,
                                               path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append([os.path.join(path_patients, id_patient,
                                               path_gt)])

# Create the model iteratively
dce_norm = StandardTimeNormalization(DCEModality())
for pat_dce, pat_gt in zip(path_patients_list_dce, path_patients_list_gt):
    # Read the DCE
    dce_mod = DCEModality()
    dce_mod.read_data_from_path(pat_dce)

    # Read the GT
    gt_mod = GTModality()
    gt_mod.read_data_from_path(label_gt, pat_gt)

    # Fit the model
    dce_norm.partial_fit_model(dce_mod, ground_truth=gt_mod,
                               cat=label_gt[0])

# Define the path where to store the model
path_store_model = '/data/prostate/pre-processing/lemaitre-2016-nov/model'
Beispiel #8
0
]
for id_patient in id_patient_list:
    # Append for the DCE data
    path_patients_list_dce.append(
        os.path.join(path_patients, id_patient, path_dce))
    # Append for the GT data - Note that we need a list of gt path
    path_patients_list_gt.append(
        [os.path.join(path_patients, id_patient, path_gt)])

for p_dce, p_gt, pat in zip(path_patients_list_dce, path_patients_list_gt,
                            id_patient_list):

    print 'Processing #{}'.format(pat)

    # Create the Tofts Extractor
    semi_ext = SemiQuantificationExtraction(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))