Exemple #1
0
def show_fids(fids,
              data_dir,
              data_viewer,
              prefix='',
              flip_angle=None,
              weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = load(fid_filepath)
        fid_cutted = cut_fid(fid)
        if weighting:
            fid['fid'] = weight_signal(fid.index,
                                       fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
            fid_cutted['fid'] = weight_signal(fid_cutted.index,
                                              fid_cutted['fid'],
                                              lb=FID_EXP_WEIGHTING)
        electronic_gain_factor = 10**(-ds['gain'] / 20.)
        small_flip_angle_factor = 1 / np.sin(np.radians(flip_angle))
        fid *= electronic_gain_factor
        fid *= small_flip_angle_factor
        fid_cutted *= electronic_gain_factor
        fid_cutted *= small_flip_angle_factor
        data_viewer.add_object(fid, '{}{} FID'.format(prefix, ds['data']))
        data_viewer.add_object(fid_cutted,
                               '{}{} FID (cut)'.format(prefix, ds['data']))
Exemple #2
0
def process_water_fid(water_fid, data_dir, weighting=False):
    fid_filepath = os.path.join(data_dir, water_fid['data'])
    fid = load(fid_filepath)
    fid_cutted = fid[1350:]
    if weighting:
        fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING)
        fid_cutted['fid'] = weight_signal(fid_cutted.index,
                                          fid_cutted['fid'],
                                          lb=FID_EXP_WEIGHTING)
    electronic_gain_factor = 10**(-water_fid['gain'] / 20.)
    fid *= electronic_gain_factor
    fid_cutted *= electronic_gain_factor
    fid *= WATER_SIGNAL_CORRECTION_FACTOR
    fid_cutted *= WATER_SIGNAL_CORRECTION_FACTOR
    return (fid, fid_cutted)
Exemple #3
0
def show_fts(fids,
             data_dir,
             data_viewer,
             prefix='',
             flip_angle=None,
             auto_pc=False,
             weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = load(fid_filepath)
        fid = cut_fid(fid)
        fid *= 10**(-ds['gain'] / 20.)
        fid *= 1 / np.sin(np.radians(flip_angle))
        if weighting:
            fid['fid'] = weight_signal(fid.index,
                                       fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if auto_pc:
            pc_angle, ft['fft'] = auto_phase_correct(ft['fft'],
                                                     ft.index,
                                                     step=1.)
        else:
            pc_angle = ds['pc']
            ft['fft'] = phase_correct(ft['fft'], angle=ds['pc'])
        data_viewer.add_object(
            ft, '{}{} FT (pc={})'.format(prefix, ds['data'], pc_angle))
def compute(fids, data_dir, pc=False, weighting=False, arg='index'):
    values = []
    arguments = []
    res = 0.
    idx = 0
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index,
                                           step=3.)[1]
            res = integrate.simps(np.real(ft['fft']), ft.index)
        else:
            res = integrate.simps(np.abs(ft['fft']), ft.index)
        res *= 10 ** (-ds['gain'] / 20.)
        values.append(res)
        if arg == 'index':
            arguments.append(idx)
            idx += 1
        else:
            arguments.append(ds[arg])
    return pd.DataFrame(values, columns=['Pol'], index=arguments)
Exemple #5
0
def compute(fids, data_dir, pc=False, weighting=False, arg='index'):
    values = []
    arguments = []
    res = 0.
    idx = 0
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index,
                                       fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=3.)[1]
            res = integrate.simps(np.real(ft['fft']), ft.index)
        else:
            res = integrate.simps(np.abs(ft['fft']), ft.index)
        res *= 10**(-ds['gain'] / 20.)
        values.append(res)
        if arg == 'index':
            arguments.append(idx)
            idx += 1
        else:
            arguments.append(ds[arg])
    return pd.DataFrame(values, columns=['Pol'], index=arguments)
Exemple #6
0
def process_water_fid(water_fid, data_dir, weighting=False):
    fid_filepath = os.path.join(data_dir, water_fid['data'])
    fid = load(fid_filepath)
    fid_cutted = fid[1350:]
    if weighting:
        fid['fid'] = weight_signal(fid.index, fid['fid'],
                                   lb=FID_EXP_WEIGHTING)
        fid_cutted['fid'] = weight_signal(fid_cutted.index,
                                          fid_cutted['fid'],
                                          lb=FID_EXP_WEIGHTING)
    electronic_gain_factor = 10 ** (-water_fid['gain'] / 20.)
    fid *= electronic_gain_factor
    fid_cutted *= electronic_gain_factor
    fid *= WATER_SIGNAL_CORRECTION_FACTOR
    fid_cutted *= WATER_SIGNAL_CORRECTION_FACTOR
    return (fid, fid_cutted)
Exemple #7
0
def show_fids(fids, data_dir, data_viewer, prefix='',
              weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = load(fid_filepath)
        fid_cutted = cut_fid(fid)
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
            fid_cutted['fid'] = weight_signal(fid_cutted.index,
                                              fid_cutted['fid'],
                                              lb=FID_EXP_WEIGHTING)
        electronic_gain_factor = 10 ** (-ds['gain'] / 20.)
        fid *= electronic_gain_factor
        fid_cutted *= electronic_gain_factor
        data_viewer.add_object(fid, '{}{} FID'
                               .format(prefix, ds['data']))
        data_viewer.add_object(fid_cutted, '{}{} FID (cut)'
                               .format(prefix, ds['data']))
Exemple #8
0
def show_fts(fids, data_dir, data_viewer,
             pc=False, prefix='', weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        electronic_gain_factor = 10 ** (-ds['gain'] / 20.)
        fid *= electronic_gain_factor
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index,
                                           step=1.)[1]
        data_viewer.add_object(ft, '{}{} FT'.format(prefix, ds['data']))
Exemple #9
0
def show_fts(fids,
             data_dir,
             data_viewer,
             pc=False,
             prefix='',
             weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index,
                                       fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        electronic_gain_factor = 10**(-ds['gain'] / 20.)
        fid *= electronic_gain_factor
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1]
        data_viewer.add_object(ft, '{}{} FT'.format(prefix, ds['data']))
Exemple #10
0
def compute_mwdep(fids, data_dir, pc=False, weighting=False):
    values = []
    arguments = []
    res = 0.
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'], lb=5)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1]
            res = integrate.simps(np.real(ft['fft']), ft.index)
        else:
            res = integrate.simps(np.abs(ft['fft']), ft.index)
        res *= 10**(-ds['gain'] / 20.)
        values.append(res)
        arguments.append(np.sqrt(ds['P']))
    return pd.DataFrame(values, columns=['Pol'], index=arguments)
Exemple #11
0
def compute_pol(data_dir, fids, flip_angle=None, pc=False, weighting=False):
    values = []
    time = []
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index,
                                       fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index, step=1.)[1]
        ft['fft'] = np.real(ft['fft'])
        res = integrate.simps(ft['fft'], ft.index)
        res *= 10**(-ds['gain'] / 20.)
        res *= 1 / np.sin(np.radians(flip_angle))
        values.append(res)
        time.append(ds['t'])
    return pd.DataFrame(values, columns=['P'], index=time)
Exemple #12
0
def compute_mwdep(fids, data_dir, pc=False, weighting=False):
    values = []
    arguments = []
    res = 0.
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'], lb=5)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index,
                                           step=1.)[1]
            res = integrate.simps(np.real(ft['fft']), ft.index)
        else:
            res = integrate.simps(np.abs(ft['fft']), ft.index)
        res *= 10 ** (-ds['gain'] / 20.)
        values.append(res)
        arguments.append(np.sqrt(ds['P']))
    return pd.DataFrame(values, columns=['Pol'], index=arguments)
Exemple #13
0
def show_fts(fids, data_dir, data_viewer, prefix='',
             flip_angle=None, auto_pc=False, weighting=False):
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = load(fid_filepath)
        fid = cut_fid(fid)
        fid *= 10 ** (-ds['gain'] / 20.)
        fid *= 1 / np.sin(np.radians(flip_angle))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if auto_pc:
            pc_angle, ft['fft'] = auto_phase_correct(
                ft['fft'], ft.index, step=1.)
        else:
            pc_angle = ds['pc']
            ft['fft'] = phase_correct(ft['fft'], angle=ds['pc'])
        data_viewer.add_object(ft, '{}{} FT (pc={})'
                               .format(prefix, ds['data'], pc_angle))
Exemple #14
0
def compute_pol(data_dir, fids, flip_angle=None, pc=False, weighting=False):
    values = []
    time = []
    for ds in fids:
        fid_filepath = os.path.join(data_dir, ds['data'])
        fid = cut_fid(load(fid_filepath))
        if weighting:
            fid['fid'] = weight_signal(fid.index, fid['fid'],
                                       lb=FID_EXP_WEIGHTING)
        ft = cut_fft(do_fft(fid))
        if pc:
            ft['fft'] = auto_phase_correct(ft['fft'], ft.index,
                                           step=1.)[1]
        ft['fft'] = np.real(ft['fft'])
        res = integrate.simps(ft['fft'], ft.index)
        res *= 10 ** (-ds['gain'] / 20.)
        res *= 1 / np.sin(np.radians(flip_angle))
        values.append(res)
        time.append(ds['t'])
    return pd.DataFrame(values, columns=['P'], index=time)
Exemple #15
0
        fid *= electronic_gain_factor
        fid *= small_flip_angle_factor
        fid_cutted *= electronic_gain_factor
        fid_cutted *= small_flip_angle_factor
        data_viewer.add_object(fid, '{}{} FID'.format(prefix, ds['data']))
        data_viewer.add_object(fid_cutted,
                               '{}{} FID (cut)'.format(prefix, ds['data']))


if __name__ == '__main__':
    common.configure_logging()
    dv = data_viewer()

    fid_file = 'ise14.dat'
    fid = load(os.path.join(data2013_dir, fid_file))
    fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING)
    dv.add_object(fid, 'FID: ' + os.path.basename(fid_file))
    fid_cutted = cut_fid(fid)
    dv.add_object(fid_cutted, 'FID[50:]: ' + os.path.basename(fid_file))
    ft = do_fft(fid_cutted)
    ft_cut = cut_fft(ft)
    dv.add_object(ft_cut, "FFT cut: " + os.path.basename(fid_file))

    theta, ft_phase_corrected = auto_phase_correct(ft_cut['fft'],
                                                   ft_cut.index,
                                                   step=0.5)
    integr = integrate.simps(np.imag(ft_phase_corrected), ft_cut.index)
    df_pc = pd.DataFrame(ft_phase_corrected,
                         index=ft_cut.index,
                         columns=['fft'])
    dv.add_object(df_pc, 'sample, pc={}, I(Im)={}'.format(theta, integr))
Exemple #16
0
        fid *= small_flip_angle_factor
        fid_cutted *= electronic_gain_factor
        fid_cutted *= small_flip_angle_factor
        data_viewer.add_object(fid, '{}{} FID'
                               .format(prefix, ds['data']))
        data_viewer.add_object(fid_cutted, '{}{} FID (cut)'
                               .format(prefix, ds['data']))


if __name__ == '__main__':
    common.configure_logging()
    dv = data_viewer()

    fid_file = 'ise14.dat'
    fid = load(os.path.join(data2013_dir, fid_file))
    fid['fid'] = weight_signal(fid.index, fid['fid'], lb=FID_EXP_WEIGHTING)
    dv.add_object(fid, 'FID: ' + os.path.basename(fid_file))
    fid_cutted = cut_fid(fid)
    dv.add_object(fid_cutted, 'FID[50:]: ' + os.path.basename(fid_file))
    ft = do_fft(fid_cutted)
    ft_cut = cut_fft(ft)
    dv.add_object(ft_cut, "FFT cut: " + os.path.basename(fid_file))

    theta, ft_phase_corrected = auto_phase_correct(
        ft_cut['fft'], ft_cut.index, step=0.5)
    integr = integrate.simps(np.imag(ft_phase_corrected),
                             ft_cut.index)
    df_pc = pd.DataFrame(ft_phase_corrected, index=ft_cut.index,
                         columns=['fft'])
    dv.add_object(df_pc, 'sample, pc={}, I(Im)={}'
                  .format(theta, integr))