Exemple #1
0
def volumeProcessing():
    knit_path = r't'  #   uint16, [256, 1014, 992]
    ds_path = r't'
    qs_path = r't'
    J_path = r't'
    orientation_path = r't'
    density_path = r''
    orientation_before_eJ_path = r''

    s = 1
    t = 2
    h = 16
    ed = 0.15
    eJ = -40

    nx = 32
    ny = 32
    nz = 6

    print 'load volume ..'
    v = load(knit_path).astype('float32')
    v = v.swapaxes(0, 1).swapaxes(1, 2)
    v = v[:, :, 0:215]
    print 'volume shape: ', v.shape

    # denoise
    print 'denoising using ed ..'
    v[v < ed * 65535.0] = 0.0

    # compute orientation
    print 'binarize ..'
    vo = v.copy()
    fiber = vo > 0.0
    background = np.logical_not(fiber)
    vo[fiber] = 0.0
    vo[background] = 1.0

    if not os.path.exists(ds_path):
        print 'compute ds and qs: ..'
        ds = generateDirections(nx, ny, nz)
        qs = computeFilters(h, s, t, ds)
        print 'dump ds and qs ..'
        dump(ds_path, ds)
        dump(qs_path, qs)
    else:
        print 'load ds and qs ..'
        ds = load(ds_path)
        qs = load(qs_path)

    print 'compute orientation ..'
    start = time_current()
    J_max, d_max = computeFiberOrientationFFT(vo, ds, qs)
    print 'time used: ', time_current() - start

    del vo, ds, qs

    background2 = J_max < eJ
    background = np.logical_or(background, background2)
    del background2

    print 'denoising using eJ ..'
    v[background] = 0.0
    d_max_before_denoise = d_max.copy()
    d_max[background] = 0.0

    del fiber, background

    print 'dump density, J, orientation ..'
    dump(density_path, v)
    dump(J_path, J_max)
    dump(orientation_path, d_max)
    dump(orientation_before_eJ_path, d_max_before_denoise)
Exemple #2
0
def volumeProcessing():
    silk_path = r'D:\Dataset\round2\silk\silk.dat'
    ds_path = r'D:\Dataset\round2\silk\ds.dat'
    qs_path = r'D:\Dataset\round2\silk\qs.dat'
    J_path = r'D:\Dataset\round2\silk\J.dat'
    orientation_path = r'D:\Dataset\round2\silk\silk_orientation.dat'
    density_path = r'D:\Dataset\round2\silk\silk_density.dat'

    s = 3
    t = 4
    h = 12
    ed = 0.4
    eJ = -6

    nx = 32
    ny = 32
    nz = 6

    print 'load volume ...'
    v = load(silk_path)

    v = v[:, :, 25:85]
    print 'volume shape: ', v.shape

    # denoise
    print 'denoising using ed ...'
    v[v < ed * 65535.0] = 0.0

    # fit
    print 'fit volume ...'
    vf = v.copy()
    fiber = vf > 0.0
    background = np.logical_not(fiber)
    vf[fiber] = 1.0
    vf[background] = 0.0

    m = poly2ndfitVolume(vf)
    X, Y, Z = generatePoly2ndSurfaceSimple(m, vf.shape[0], vf.shape[1])
    del vf

    # resample
    print 'resample volume ...'
    v = resampleVolume(v, Z)
    print 'volume shape after resampling: ', v.shape
    del X, Y, Z

    # compute orientation
    v = v[:, :, 22:62]
    print 'volume shape for computing orientation: ', v.shape

    # binarize volume for filtering
    # 0: fiber, 1: background
    print 'binarize ...'
    vo = v.copy()
    fiber = vo > 0.0
    background = np.logical_not(fiber)
    vo[fiber] = 0.0
    vo[background] = 1.0

    if not os.path.exists(ds_path):
        print 'compute ds and qs ...'
        ds = generateDirections(nx, ny, nz)
        qs = computeFilters(h, s, t, ds)
        print 'dump ds and qs ...'
        dump(ds_path, ds)
        dump(qs_path, qs)
    else:
        print 'load ds and qs ...'
        ds = load(ds_path)
        qs = load(qs_path)

    print 'compute orientation ...'
    start = time_current()
    J_max, d_max = computeFiberOrientationFFT(vo, ds, qs)
    print 'time used: ', time_current() - start

    del vo

    background2 = J_max < eJ
    background = np.logical_or(background, background2)

    print 'denoising using eJ ...'
    v[background] = 0.0
    d_max_before_denoise = d_max.copy()
    d_max[background] = 0.0

    print 'dump density, J, orientation ...'
    dump(density_path, v)
    dump(J_path, J_max)
    dump(orientation_path, d_max)
    dump(orientation_path + '_before_denoise', d_max_before_denoise)
Exemple #3
0
def volumeProcessing():
    silk_path = r'D:\Dataset\round2\silk\silk.dat'
    ds_path = r'D:\Dataset\round2\silk\ds.dat'
    qs_path = r'D:\Dataset\round2\silk\qs.dat'
    J_path = r'D:\Dataset\round2\silk\J.dat'
    orientation_path = r'D:\Dataset\round2\silk\silk_orientation.dat'
    density_path = r'D:\Dataset\round2\silk\silk_density.dat'

    s = 3
    t = 4
    h = 12
    ed = 0.4
    eJ = -6

    nx = 32
    ny = 32
    nz = 6

    print 'load volume ...'
    v = load(silk_path)
    
    v = v[:,:,25:85]
    print 'volume shape: ', v.shape

    # denoise
    print 'denoising using ed ...'
    v[v < ed * 65535.0] = 0.0

    # fit
    print 'fit volume ...'
    vf = v.copy()
    fiber = vf > 0.0
    background = np.logical_not(fiber)
    vf[fiber] = 1.0
    vf[background] = 0.0

    m = poly2ndfitVolume(vf)
    X, Y, Z = generatePoly2ndSurfaceSimple(m, vf.shape[0], vf.shape[1])
    del vf

    # resample
    print 'resample volume ...'
    v = resampleVolume(v, Z)
    print 'volume shape after resampling: ', v.shape
    del X, Y, Z

    # compute orientation 
    v = v[:,:,22:62]
    print 'volume shape for computing orientation: ', v.shape

    # binarize volume for filtering
    # 0: fiber, 1: background
    print 'binarize ...'
    vo = v.copy()
    fiber = vo > 0.0
    background = np.logical_not(fiber)
    vo[fiber] = 0.0
    vo[background] = 1.0

    if not os.path.exists(ds_path):
        print 'compute ds and qs ...'
        ds = generateDirections(nx, ny, nz)
        qs = computeFilters(h, s, t, ds)
        print 'dump ds and qs ...'
        dump(ds_path, ds)
        dump(qs_path, qs)
    else:
        print 'load ds and qs ...'
        ds = load(ds_path)
        qs = load(qs_path)
    
    print 'compute orientation ...'
    start = time_current()    
    J_max, d_max = computeFiberOrientationFFT(vo, ds, qs)
    print 'time used: ', time_current() - start

    del vo

    background2 = J_max < eJ
    background = np.logical_or(background, background2)

    print 'denoising using eJ ...'
    v[background] = 0.0
    d_max_before_denoise = d_max.copy()
    d_max[background] = 0.0

    print 'dump density, J, orientation ...'
    dump(density_path, v)
    dump(J_path, J_max)
    dump(orientation_path, d_max)
    dump(orientation_path + '_before_denoise', d_max_before_denoise)
Exemple #4
0
def volumeProcessing():
    felt_path = r'' #   uint16, [508, 1013, 992]
    ds_path = r''
    qs_path = r''
    J_path = r''
    orientation_path = r''
    density_path = r''

    s = 1
    t = 2
    h = 16
    ed = 0.4
    eJ = -30

    nx = 32
    ny = 32
    nz = 6

    print 'load volume ..'
    v = load(felt_path).astype('float32')
    v = v.swapaxes(0, 1).swapaxes(1, 2)
    v = v[:,:,5:490]
    print 'volume shape: ', v.shape

    # denoise
    print 'denoising using ed ..'
    v[v < ed * 65535.0] = 0.0

    # compute orientation
    print 'binarize ..'
    vo = v.copy()
    fiber = vo > 0.0
    background = np.logical_not(fiber)
    vo[fiber] = 0.0
    vo[background] = 1.0

    if not os.path.exists(ds_path):
        print 'compute ds and qs: ..'
        ds = generateDirections(nx, ny, nz)
        qs = computeFilters(h, s, t, ds)
        print 'dump ds and qs ..'
        dump(ds_path, ds)
        dump(qs_path, qs)
    else:
        print 'load ds and qs ..'
        ds = load(ds_path)
        qs = load(qs_path)

    print 'compute orientation ..'
    start = time_current()
    J_max, d_max = computeFiberOrientationFFT(vo, ds, qs)
    print 'time used: ', time_current() - start

    del vo, ds, qs

    background2 = J_max < eJ
    background = np.logical_or(background, background2)
    del background2

    print 'denoising using eJ ..'
    v[background] = 0.0
    #d_max_before_denoise = d_max.copy()
    d_max[background] = 0.0
    
    del fiber, background

    print 'dump density, J, orientation ..'
    dump(density_path, v)
    dump(J_path, J_max)
    dumpLarge(orientation_path, d_max)