Пример #1
0
def gamma_index(a, filename, ref_filename):
    img = itk.imread(filename)
    img_ref = itk.imread(ref_filename)
    gi = gt.gamma_index_3d_equal_geometry(img_ref,
                                          img,
                                          dta=3,
                                          dd=3,
                                          ddpercent=True)
    # itk.imwrite(gi, 'gi.mhd')
    spacing = img.GetSpacing()
    data = itk.GetArrayViewFromImage(gi)
    y = data[:, 0, 0]
    x = np.arange(len(y)) * spacing[2]
    # total
    max = y.max()
    print(f'Max gamma index {ref_filename} {filename}: {max}')
    # get shared axis if already exist
    ax = a.get_shared_x_axes().get_siblings(a)[0]
    if ax == a:
        ax = a.twinx()
    ax.plot(x,
            y,
            '--',
            alpha=0.5,
            label=f'G.I. {ref_filename} vs {filename} max={max:.2f}')
    ax.legend()
    if max > TOL:
        return False
    return True
Пример #2
0
def gamma_index(filename, ref_filename):
    img = itk.imread(filename)
    img_ref = itk.imread(ref_filename)
    gi = gt.gamma_index_3d_equal_geometry(img_ref, img, dta=3, dd=3, ddpercent=True)
    data = itk.GetArrayViewFromImage(gi)
    y = data[:, 0, 0]
    # total
    max = y.max()
    print(f'Max gamma index {ref_filename} {filename}: {max}')
    if max > TOL:
        return False
    return True
Пример #3
0
def gamma_index(filename, ref_filename):
    img = itk.imread(filename)
    img_ref = itk.imread(ref_filename)
    gi = gt.gamma_index_3d_equal_geometry(img_ref, img, dta=3, dd=3, ddpercent=True)
    data = itk.GetArrayViewFromImage(gi)
    # total
    indexThreshold = np.where(data > 0)
    index = np.where(data[indexThreshold] <= 1.0)
    percentageVoxelOk = index[0].size/indexThreshold[0].size*100
    print(f'%voxel passes gamma index {ref_filename} {filename}: {percentageVoxelOk}')
    if percentageVoxelOk < TOL:
        return False
    return True
Пример #4
0
def gamma_index(a, filename, ref_filename):
    img = itk.imread(filename)
    img_ref = itk.imread(ref_filename)
    gi = gt.gamma_index_3d_equal_geometry(img_ref,
                                          img,
                                          dta=3,
                                          dd=3,
                                          ddpercent=True)
    # itk.imwrite(gi, 'gi.mhd')
    spacing = img.GetSpacing()
    data = itk.GetArrayViewFromImage(gi)
    y = data[:, 0, 0]
    x = np.arange(len(y)) * spacing[2]
    # total
    max = np.amax(gi)
    if max == 0:
        percentageVoxelOk = 100
    else:
        indexThreshold = np.where(data > 0)
        index = np.where(data[indexThreshold] <= 1.0)
        percentageVoxelOk = index[0].size / indexThreshold[0].size * 100
    print(
        f'%voxel correct in gamma index {ref_filename} {filename}: {percentageVoxelOk}'
    )
    # get shared axis if already exist
    ax = a.get_shared_x_axes().get_siblings(a)[0]
    if ax == a:
        ax = a.twinx()
    ax.plot(
        x,
        y,
        '--',
        alpha=0.5,
        label=
        f'G.I. {ref_filename} vs {filename} %voxel ok ={percentageVoxelOk:.2f}'
    )
    ax.legend()
    if percentageVoxelOk < TOL:
        return False
    return True
Пример #5
0
def gamma_index(a, filename, ref_filename):
    img = itk.imread(filename)
    img_ref = itk.imread(ref_filename)
    gi = gt.gamma_index_3d_equal_geometry(img_ref, img, dta=1, dd=1, ddpercent=True)
    # itk.imwrite(gi, 'gi.mhd')
    spacing = img.GetSpacing()
    data = itk.GetArrayViewFromImage(gi)
    y = data[:, 0, 0]
    x = np.arange(len(y)) * spacing[2]

    L1 = x <= 160
    #    L1 =np.where( x<= 155);
    ytemp = np.array(y)
    y2 = ytemp[L1]
    x2 = x[L1]

    # total
    max = y2.max()
    print(f'- Test for {ref_filename} {filename}')
    print(f'  Max gamma index is {max:.2f}')
    # get shared axis if already exist
    ax = a.get_shared_x_axes().get_siblings(a)[0]
    if ax == a:
        ax = a.twinx()
    ax.plot(x2, y2, '--', alpha=0.5, label=f'G.I. {ref_filename} vs {filename} max={max:.2f}')
    ax.set_ylabel('Gamma')
    ax.legend()
    max = np.amax(gi)
    if max == 0:
        percentageVoxelOk = 100
    else:
        indexThreshold = np.where(data > 0)
        index = np.where(data[indexThreshold] <= 1.0)
        percentageVoxelOk = index[0].size / indexThreshold[0].size * 100
    print(f'  Voxels that passes gamma index 1%1mm: {percentageVoxelOk:.2f}%')
    if percentageVoxelOk < TOL:
        print(f'!!! test if FALSE !!! (tolerance is {TOL}%)')
        return False
    return True