#################################################    
### 
###  show pipeline effects one by one
###
################################################

print "Performing LASSO.",
behaviors = ['AngleVelocity', 'Eigenworm3', 'Eigenworm2']
fig = plt.figure('Lasso 1',(2*6.8, 1.7*len(behaviors)))
outer_grid = gridspec.GridSpec(2, 1, hspace=0.25, wspace=0.25)

results = {'LASSO':{}}
results['LASSO'] = dr.runLasso(data, pars, testIndices, trainingsIndices, plot=0, behaviors = behaviors)
# calculate how much more neurons contribute
tmpDict = dr.scoreModelProgression(data, results, testIndices, trainingsIndices, pars, fitmethod = 'LASSO', behaviors = behaviors)
for tmpKey in tmpDict.keys():
    results['LASSO'][tmpKey].update(tmpDict[tmpKey])
print 'Done with Lasso. Plotting...'
print results
gridloc = outer_grid[0]
plotSingleLinearFit(fig, gridloc , pars, results['LASSO'], data, trainingsIndices, testIndices, behaviors)

plt.show()
   

#es
#################################################    
### 
###   plot velocity versus cms velocity
###
#
##############################################
if lasso:
    print "Performing LASSO.",
    for kindex, key in enumerate(keyList):
        print key
        splits = resultDict[key]['Training']
        resultDict[key]['LASSO'] = dr.runLasso(dataSets[key],
                                               pars,
                                               splits,
                                               plot=1,
                                               behaviors=behaviors)
        # calculate how much more neurons contribute
        tmpDict = dr.scoreModelProgression(dataSets[key],
                                           resultDict[key],
                                           splits,
                                           pars,
                                           fitmethod='LASSO',
                                           behaviors=behaviors)
        for tmpKey in tmpDict.keys():
            resultDict[key]['LASSO'][tmpKey].update(tmpDict[tmpKey])

        tmpDict = dr.reorganizeLinModel(dataSets[key],
                                        resultDict[key],
                                        splits,
                                        pars,
                                        fitmethod='LASSO',
                                        behaviors=behaviors)
        for tmpKey in tmpDict.keys():
            resultDict[key]['LASSO'][tmpKey] = tmpDict[tmpKey]

    mp.plotLinearModelResults(dataSets,