コード例 #1
0
        np.inf, delta_3_bounds[1], 8 * 10e-2
    ])

    res_robust = least_squares(_loss_gaussian_citrate_4_dof,
                               popt_default,
                               loss='huber',
                               f_scale=1.,
                               bounds=param_bounds,
                               args=(ppm_interp, f(ppm_interp)))

    return res_robust.x


path_mrsi = '/data/prostate/experiments/Patient 1036/MRSI/CSI_SE_3D_140ms_16c.rda'

rda_mod = RDAModality(1250.)
rda_mod.read_data_from_path(path_mrsi)

phase_correction = MRSIPhaseCorrection(rda_mod)
rda_mod = phase_correction.transform(rda_mod)

freq_correction = MRSIFrequencyCorrection(rda_mod)
rda_mod = freq_correction.fit(rda_mod).transform(rda_mod)

baseline_correction = MRSIBaselineCorrection(rda_mod)
rda_mod = baseline_correction.fit(rda_mod).transform(rda_mod)

# x = 0
# y = 0
# z = 0
コード例 #2
0
ファイル: freq_alignment.py プロジェクト: I2Cvb/prostate
import numpy as np

from protoclass.data_management import RDAModality
from protoclass.preprocessing import MRSIPhaseCorrection

from fdasrsf import srsf_align

path_mrsi = '/data/prostate/experiments/Patient 1036/MRSI/CSI_SE_3D_140ms_16c.rda'

rda_mod = RDAModality(1250.)
rda_mod.read_data_from_path(path_mrsi)

phase_correction = MRSIPhaseCorrection(rda_mod)
rda_mod = phase_correction.transform(rda_mod)

# Get the data
data = np.reshape(rda_mod.data_, (rda_mod.data_.shape[0],
                                  rda_mod.data_.shape[1] *
                                  rda_mod.data_.shape[2] *
                                  rda_mod.data_.shape[3]))

# Apply the curve alignment using the FDS-SRSF
out = srsf_align(np.real(data), rda_mod.bandwidth_ppm, smoothdata=False)
コード例 #3
0
        os.path.join(path_patients, id_patient, path_mrsi))
    # 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)])

# List where to store the different minimum
for id_p, (p_mrsi, p_gt) in enumerate(
        zip(path_patients_list_mrsi, path_patients_list_gt)):

    print 'Processing {}'.format(id_patient_list[id_p])

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

    # Read the image data
    rda_mod = RDAModality(1250.)
    rda_mod.read_data_from_path(os.path.join(p_mrsi, filename_mrsi))

    # Correct the phase
    phase_correction = MRSIPhaseCorrection(rda_mod)
    rda_mod = phase_correction.transform(rda_mod)

    # Correct the frequency shift
    freq_correction = MRSIFrequencyCorrection(rda_mod)
    rda_mod = freq_correction.fit(rda_mod).transform(rda_mod)

    # Correct the baseline
    baseline_correction = MRSIBaselineCorrection(rda_mod)
    rda_mod = baseline_correction.fit(rda_mod).transform(rda_mod)

    # Read the GT
コード例 #4
0
ファイル: resampling_mrsi.py プロジェクト: I2Cvb/prostate
from matplotlib.collections import PolyCollection
from matplotlib.colors import colorConverter
import matplotlib.pyplot as plt

from protoclass.data_management import T2WModality
from protoclass.data_management import RDAModality

path_rda = '/data/prostate/experiments/Patient 996/MRSI/CSI_SE_3D_140ms_16c.rda'
path_t2w = '/data/prostate/experiments/Patient 996/T2W'

# Read the ground-truth
t2w_mod = T2WModality()
t2w_mod.read_data_from_path(path_t2w)

# Read the rda
rda_mod = RDAModality(1250.)
rda_mod.read_data_from_path(path_rda)

# Get the sitk image from the T2W
# We need to convert from numpy array to ITK
# Our convention was Y, X, Z
# We need to convert it in Z, Y, X which will be converted in X, Y, Z by ITK
t2w_img = sitk.GetImageFromArray(np.swapaxes(
    np.swapaxes(t2w_mod.data_, 0, 1), 0, 2))
# Put all the spatial information
t2w_img.SetDirection(t2w_mod.metadata_['direction'])
t2w_img.SetOrigin(t2w_mod.metadata_['origin'])
t2w_img.SetSpacing(t2w_mod.metadata_['spacing'])

# Get the sitk image from the rda
rda_fake = np.random.randint(0, 255, size=(16, 16, 16))