In [1]:
%load_ext autoreload
%autoreload 2

from matplotlib.pyplot import imshow
import matplotlib.pyplot as plt

%matplotlib inline
import numpy as np
import sys
sys.path.append('../')
import gp


/home/d/nolearn/local/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Using gpu device 0: GeForce GTX TITAN (CNMeM is disabled, CuDNN 4007)
/home/d/nolearn/local/lib/python2.7/site-packages/theano/tensor/signal/downsample.py:6: UserWarning: downsample module has been moved to the theano.tensor.signal.pool module.
  "downsample module has been moved to the theano.tensor.signal.pool module.")

In [2]:
import cPickle as pickle
import os

In [3]:
# load CREMI A
input_image = []
input_prob = []
input_gold = []
input_rhoana = []
test_slices = range(5)# + range(25+20,50) + range(50+20,75)
for z in test_slices:
    image, prob, gold, rhoana = gp.Util.read_cremi_section(os.path.expanduser('~/data/CREMIGP/TEST/'), z)
    input_image.append(image)
    input_prob.append(255.-prob)
    input_gold.append(gold)
    input_rhoana.append(rhoana)    

original_mean_VI, original_median_VI, original_VI_s = gp.Legacy.VI(input_gold, input_rhoana)

In [4]:
best_vis = []
for z in range(len(input_rhoana)):
    fixed = gp.Util.propagate_max_overlap(input_rhoana[z], input_gold[z])
    fixed = gp.Util.relabel(fixed)
    best_vis.append(gp.Util.vi(fixed.astype(np.uint64),input_gold[z].astype(np.uint64)))

In [6]:
original_median_VI


Out[6]:
1.7453761377647545

In [5]:
best_vi = np.median(best_vis)
print best_vi


1.45485772678

In [8]:
A_simuser_gp_vi_per_slice, A_simuser_gp_merge_vis, A_simuser_gp_split_vis,A_gp_simuser_allvis = gp.Stats.analyze_users(['C_simuserGP'], 
                                                                                         input_gold, input_rhoana,
                                                                                         filename='/home/d/PAPERGFX/C_gpsimuser.pdf',
                                                                                         DATADIR='/home/d/CREMISTUDY/',
                                                                                         data='cremiC',
                                                                                         clampX=4000, clampY=1,
                                                                                                                       hideYlabels=False,
                                                                                         skipoutput=False)


No. users 1
Avg. correction time 0.0
Avg. corrections 4332.0
Avg. accepted 1531.0

In [9]:
A_auto_gp_vi_per_slice, A_auto_gp_merge_vis, A_auto_gp_split_vis,A_gp_auto_allvis = gp.Stats.analyze_users(['C_autoGP'], 
                                                                                         input_gold, input_rhoana,
                                                                                         filename='/home/d/PAPERGFX/C_gpauto.pdf',
                                                                                         DATADIR='/home/d/CREMISTUDY/',
                                                                                         data='cremiC',
                                                                                                           hline=512,
                                                                                         clampX=4000, clampY=1,
                                                                                                                       hideYlabels=False,
                                                                                         skipoutput=False)


No. users 1
Avg. correction time 0.0
Avg. corrections 2204.0
Avg. accepted 2204.0

In [10]:
A_simuser_fp_vi_per_slice, A_simuser_fp_merge_vis, A_simuser_fp_split_vis,A_fp_simuser_allvis = gp.Stats.analyze_users(['C_simuserFP'], 
                                                                                         input_gold, input_rhoana,
                                                                                         filename='/home/d/PAPERGFX/C_fpsimuser.pdf',
                                                                                         DATADIR='/home/d/CREMISTUDY/',
                                                                                         data='cremiC',
                                                                                         clampX=4000, clampY=1,
                                                                                                                       hideYlabels=False,
                                                                                         skipoutput=False)


No. users 1
Avg. correction time 0.0
Avg. corrections 2694.0
Avg. accepted 670.0

In [11]:
A_auto_fp_vi_per_slice, A_auto_fp_merge_vis, A_auto_fp_split_vis,A_fp_auto_allvis = gp.Stats.analyze_users(['C_autoFP'], 
                                                                                         input_gold, input_rhoana,
                                                                                         filename='/home/d/PAPERGFX/C_fpauto.pdf',
                                                                                         DATADIR='/home/d/CREMISTUDY/',
                                                                                         data='cremiC',
#                                                                                                            hline=448,
                                                                                         clampX=4000, clampY=1,
                                                                                                                       hideYlabels=False,
                                                                                         skipoutput=False)


No. users 1
Avg. correction time 0.0
Avg. corrections 2632.0
Avg. accepted 2632.0

In [25]:
import matplotlib.gridspec as gridspec
left, width = .25, .5
bottom, height = .25, .5
right = left + width
top = bottom + height
fig = plt.figure(1, figsize=(40,20))
clamper=4500

c_gold = input_gold
c_rhoana = input_rhoana

# fig.suptitle('Focused Proofreading', y=1.05, fontsize=64, fontweight='bold')
gs = gridspec.GridSpec(2,3,width_ratios=[.15,1,1])
gs.update(wspace=0.2, hspace=0.1)
a = plt.subplot(gs[0])
a.axis('off')
plt.text(-.5, .85, 
         'Focused\nProofreading', 
         ha='left', va='top', rotation='90',
         fontsize=56, fontweight='normal')

plt.subplot(gs[1])
gp.Stats.analyze_users(['C_autoFP'], c_gold, c_rhoana, returnplt=True, vilabel=True, hideYlabels=False, showlegend=True,clampX=clamper,
                       DATADIR='/home/d/CREMISTUDY/',data='cremiC')
plt.title('Automatic', y=1.02)
plt.subplot(gs[2])
gp.Stats.analyze_users(['C_simuserFP'], c_gold, c_rhoana, returnplt=True,clampX=clamper,DATADIR='/home/d/CREMISTUDY/',data='cremiC')
plt.title('Oracle', y=1.02)
a = plt.subplot(gs[3])
a.axis('off')
plt.text(-.5, .85, 
         'Guided\nProofreading', 
         ha='left', va='top', rotation='90',
         fontsize=56, fontweight='normal')
plt.subplot(gs[4])

gp.Stats.analyze_users(['C_autoGP'], c_gold, c_rhoana, hline=521,returnplt=True, vilabel=True,
                       clampX=clamper,hideYlabels=False,clabel=True,hideXlabels=False,DATADIR='/home/d/CREMISTUDY/',data='cremiC')
plt.subplot(gs[5])
gp.Stats.analyze_users(['C_simuserGP'], c_gold, c_rhoana, returnplt=True,clampX=clamper,hideXlabels=False,clabel=True,data='cremiC',
                      DATADIR='/home/d/CREMISTUDY/')

# plt.tight_layout(pad=0.01, w_pad=0.01, h_pad=.5)

# gp.Stats.analyze_users(GP_USERS, gold, rhoana, clampX=700,
#                                                                     filename='/home/d/PAPERGFX/gpusers.pdf')
# plt.subplot(212)
# gp.Stats.analyze_users(GP_USERS, gold, rhoana, clampX=700,
#                                                                     filename='/home/d/PAPERGFX/gpusers.pdf')

plt.savefig('/home/d/PAPERGFX/cremiCtrails.pdf')



In [31]:
def bigboxplot(objects, data, clampY=True, filename=None):
#     plt.subplots()

    y_pos = range(1,len(objects)+1)

    fig = plt.figure(figsize=(20,14))
    ax = plt.gca()
    ax.axvline(x=1.5,ymax=1, color='lightblue', linewidth=2)
    ax.axvline(x=3.5,ymax=1, color='lightblue', linewidth=2)    
    ax.axvline(x=6.5,ymax=1, color='lightblue', linewidth=2)    
    ax.axvline(x=8.5,ymax=1, color='lightblue', linewidth=2)    
    plt.axhline(np.median(data[0]), color='gray', linewidth=2, linestyle=':', label='Initial Segmentation')
    plt.axhline(y=best_vi, color='gray', linestyle='--', linewidth=2, label='Best Possible')

    bp = plt.boxplot(data, whis=10)
    plt.setp(bp['whiskers'],linewidth=3,linestyle='-',color='black')
    plt.setp(bp['fliers'],linewidth=3)
    plt.setp(bp['means'],linewidth=3)
    plt.setp(bp['medians'],linewidth=3
            ,color='black')
    plt.setp(bp['boxes'],linewidth=3,color='black')
    plt.setp(bp['caps'],linewidth=3)

    plt.text(2.5, 1.99, 
             'Automatic', 
             ha='center', va='top',
             fontsize=28, fontweight='normal')    
#     plt.text(5, .75, 
#              'F. Choice Novice', 
#              ha='center', va='top',
#              fontsize=28, fontweight='normal')   
    
#     plt.text(7.5, .75, 
#              'F. Choice Expert', 
#              ha='center', va='top',
#              fontsize=28, fontweight='normal')   
    

    plt.text(4.5, 1.99, 
             'Oracle', 
             ha='center', va='top',
             fontsize=28, fontweight='normal')    
    
    ax.set_aspect(7)
    ax.arrow(2, 1.87, 0, .03, head_width=0.2, head_length=0.03, fc='k', ec='k', linewidth=3)
    legend = ax.legend(loc='upper right')
    plt.ylabel('Variation of Information')
    if clampY:
        plt.ylim([1.35,1.96])
#     plt.yticks(np.arange(min(x), max(x)+1, 1.0))
    font = {'family' : 'sans-serif',
            'weight' : 'normal',
            'size'   : 28}

    plt.rc('font', **font)
    plt.rc('legend',**{'fontsize':24})
    plt.xticks(y_pos, objects)
    plt.yticks(np.arange(1.35, 1.96, 0.1))
    if filename:
        plt.savefig(filename)
        
    plt.savefig('/home/d/PAPERGFX/cremiCboxplot.pdf')
    plt.show()

objects = ['Initial\nSegmentation',
           'Focused\nProofreading',
           'Guided\nProofreading',        
           'Focused\nProofreading',
           'Guided\nProofreading']
objects = ['Initial\nSegmentation',
           'FP',
           'GP',           
           'FP',
           'GP']

data = [original_VI_s, 
        [], 
        A_gp_auto_allvis[0][448], 
        A_simuser_fp_split_vis[-1],
        A_gp_simuser_allvis[0][-1]]
bigboxplot(objects, data)



In [38]:
A=A_gp_auto_allvis[0][521]
print np.median(A), np.std(A)


1.56828422023 0.0811431151556

In [39]:
A=A_gp_simuser_allvis[0][-1]
print np.median(A), np.std(A)


1.46553869816 0.0622581105713

In [40]:
A=A_simuser_fp_split_vis[-1]
print np.median(A), np.std(A)


1.44975515122 0.0559164111936

In [41]:
A=A_auto_fp_split_vis[-1]
print np.median(A), np.std(A)
4.81096677085/1.56828422023


4.81096677085 0.0305024899402
Out[41]:
3.067662550442826

In [37]:
original_median_VI


Out[37]:
1.7453761377647545

In [42]:
np.std(original_VI_s)


Out[42]:
0.085587337328573265

In [ ]: