def find_normalization_params(pat_adc, pat_gt, label, pat_model):
    # Create the normalization object and load the model
    adc_norm = PiecewiseLinearNormalization(ADCModality())
    adc_norm.load_model(pat_model)

    # Read the ADC
    adc_mod = ADCModality()
    adc_mod.read_data_from_path(pat_adc)

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

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

    return adc_norm
示例#2
0
    # Remove a part of the string to have only the id
    nb_patient = id_patient_list[id_p].replace('Patient ', '')

    # Read the image data
    adc_mod = ADCModality()
    adc_mod.read_data_from_path(p_adc)

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

    # Read the normalization information
    pat_chg = id_patient_list[id_p].lower().replace(' ', '_') + '_norm.p'
    filename = os.path.join(path_piecewise, pat_chg)
    adc_norm = PiecewiseLinearNormalization.load_from_pickles(filename)

    # Normalize the data
    adc_mod = adc_norm.normalize(adc_mod)

    # Create an object to extract the data in a matrix format using
    # the ground-truth
    ise = IntensitySignalExtraction(adc_mod)

    # Get the data
    print 'Extract the signal intensity for the ROI'
    data = ise.transform(adc_mod, ground_truth=gt_mod, cat=label_gt[0])

    # Store the data
    print 'Store the matrix'
示例#3
0
# Generate the different path to be later treated
path_patients_list_adc = []
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 ADC data
    path_patients_list_adc.append(
        os.path.join(path_patients, id_patient, path_adc))
    # 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
adc_model = PiecewiseLinearNormalization(ADCModality())
for pat_adc, pat_gt in zip(path_patients_list_adc, path_patients_list_gt):
    # Read the ADC
    adc_mod = ADCModality()
    adc_mod.read_data_from_path(pat_adc)

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

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

# Define the path where to store the model
path_store_model = '/data/prostate/pre-processing/mp-mri-prostate/adc-model'
filename_model = os.path.join(path_store_model, 'piecewise_model.npy')