Пример #1
0
def gettingSolu(plate):
    global monOutput
    global loadingFolder
    
    print "current directory ", os.getcwd()
    
    #print os.getcwd()
    newFrameLot = None

    print plate
    listW = os.listdir('/media/lalil0u/New/workspace2/Tracking/data/raw/'+plate)
    for well in listW:
        well=well[:-5]
        print well
        filename = '/media/lalil0u/New/workspace2/Tracking/data/raw/'+plate+"/"+well+".hdf5"
        filenameT = '/media/lalil0u/New/workspace2/Tracking/data/TSinclMD/PL'+plate+"___P"+well+"___T00000.xml"

        monOutput+="plate = "+plate+",well = "+well+"\n"
        #ajout du frameLot et du tabF
        frameLotC, tabFC = test.gettingRaw(filename, filenameT, plate, well)
        if newFrameLot == None:
            newFrameLot = frameLotC 
        else: newFrameLot.addFrameLot(frameLotC)
        
    predictions = {}

    for well in listW:
        well=well[:-5]
        print well
        filenameD = '/media/lalil0u/New/workspace2/Tracking/data/CecogPredictions/'+plate+'/tracking_graph___P'+well+'.dot'
        predictions.update({well: lireDot(filenameD)})
    
    return newFrameLot, predictions
def gettingSolu(plate, well):
    global loadingFolder
    newFrameLot = None

    print "Loading data from ", plate, well
    filename = '/media/lalil0u/New/workspace2/Tracking/data/raw/'+plate+"/"+well+".hdf5"
    filenameT = '/media/lalil0u/New/workspace2/Tracking/data/TSinclMD/PL'+plate+"___P"+well+"___T00000.xml"

    #ajout du frameLot et du tabF
    frameLotC, tabFC = test.gettingRaw(filename, filenameT, plate, well)
    if newFrameLot == None:
        newFrameLot = frameLotC 
    else: newFrameLot.addFrameLot(frameLotC)
#    
    return newFrameLot
Пример #3
0
def gettingSolu(plate, phenoOnly=False):
    global monOutput
    global loadingFolder

    print "current directory ", os.getcwd()

    # print os.getcwd()
    newFrameLot = None

    print plate
    listW = os.listdir("/media/lalil0u/New/workspace2/Tracking/data/raw/" + plate)
    for well in listW:
        well = well[:-5]
        print well
        if phenoOnly:
            if well not in d_ctrl[plate]:
                print "------------------------PAS PRIS------------------------"
                continue

            else:
                print "CONTROL"

        filename = "/media/lalil0u/New/workspace2/Tracking/data/raw/" + plate + "/" + well + ".hdf5"
        filenameT = "/media/lalil0u/New/workspace2/Tracking/data/TSinclMD/PL" + plate + "___P" + well + "___T00000.xml"

        monOutput += "plate = " + plate + ",well = " + well + "\n"
        # ajout du frameLot et du tabF
        frameLotC, tabFC = test.gettingRaw(filename, filenameT, plate, well)
        if newFrameLot == None:
            newFrameLot = frameLotC
        else:
            newFrameLot.addFrameLot(frameLotC)

    predictions = {}

    return newFrameLot, predictions
Пример #4
0
def gettingSolu(plate, pheno_only=False):
    global monOutput
    global FEATURE_NUMBER
    global loadingFolder
    global first
    global ctrl; global pheno
    #tableau qui contiendra toutes les features de tlm pr voir lesquelles contiennent des NaN
    tabF= None
    
    print "current directory ", os.getcwd()
    fichier = open(loadingFolder+"featuresToDelete.pkl", 'r')
    f = pickle.load(fichier)
    fichier.close()
    
    #print os.getcwd()
    newFrameLot = None

    print plate
    listW = os.listdir('/media/lalil0u/New/workspace2/Tracking/data/raw/'+plate)
    for well in listW:
        well=well[:-5]
        print well
        if pheno_only:
            if well not in d_ctrl[plate]:
                if pheno>0:
                    print "------------------------PAS PRIS------------------------"
                    pheno-=1
                    continue
                else:
                    print "PHENO"
            else:
                if ctrl>0:
                    print "------------------------PAS PRIS------------------------"
                    ctrl-=1
                    continue
                else:
                    print "CONTROL"
                
        filename = '/media/lalil0u/New/workspace2/Tracking/data/raw/'+plate+"/"+well+".hdf5"
        filenameT = '/media/lalil0u/New/workspace2/Tracking/data/TSinclMD/PL'+plate+"___P"+well+"___T00000.xml"

        monOutput+="plate = "+plate+",well = "+well+"\n"
        #ajout du frameLot et du tabF
        frameLotC, tabFC = test.gettingRaw(filename, filenameT, plate, well)
        if newFrameLot == None:
            newFrameLot = frameLotC 
        else: newFrameLot.addFrameLot(frameLotC)
        tabF = tabFC if tabF == None else np.vstack((tabF, tabFC))
    
    #    print "final training set content :"
    #    count, total= newFrameLot.statisticsTraining2()
    #    print count, total
    if newFrameLot is None:
        return None, None
        
    c, f2 = treatments.whichAreNan(tabF)
    #print len(f2.keys()), len(f)
#    if len(f)<len(f2.keys()):
#        pdb.set_trace()
#        
    #if there are features with NaN entries in the predict data but not in the training data
    toZeros = filter(lambda x: x not in f, f2.keys())
    #pdb.set_trace()
    if toZeros !=[]:
        msg="WARNING WARNING WARNING, some features here have NaN entries, and this was not the case in the training set. They are put to 0"
        warnings.warn(msg)
        newFrameLot.zeros(toZeros)
    newFrameLot.clean(f)
    if first:
        FEATURE_NUMBER -=len(f)
    
    print "Feature number", FEATURE_NUMBER
    print "Getting all uplets now"
    print "TIME TIME TIME", time.clock()
    #ICI ON RECUPERE DONC LES SINGLETS ET DOUBLETS AVEC LA VALEUR DU TRAINING DANS CELL.TO SI ILS Y SONT, NONE SINON
    #POUR LE CENTRE ET LES FEATURES C'EST LA MOYENNE DES OBJETS DU SINGLET
    singlets, doublets = newFrameLot.getAllUplets()
    #pour l'instant je ne garde que le passage de l'image 0 a 1
    print "TIME TIME TIME after getting all uplets", time.clock()
    print "Joining uplets now"
    
    solutions = joining.j(singlets, doublets, FEATURE_NUMBER, training = False)
    print "TIME TIME TIME after joining", time.clock()
    
    return solutions, newFrameLot
Пример #5
0
def gettingSolu(loadingFolder, hdf5Folder = '/media/lalil0u/New/workspace2/Tracking/data/predict/', plate=None, wellL=None, training = False, first=True, xb_screen=False):
    global monOutput
    global FEATURE_NUMBER
    
    tabF = None
    #var pour indiquer si on prend un toy example ou pas
    #tableau qui contiendra toutes les features de tlm pr voir lesquelles contiennent des NaN
#    print "current directory ", os.getcwd()
    fichier = open(loadingFolder+"featuresToDelete.pkl", 'r')
    f = pickle.load(fichier)
    fichier.close()

    newFrameLot = None
        
    listP = os.listdir(hdf5Folder)
    if plate is not None:
        listP=[plate]
        
    for plate in listP:
        print plate
        listW = sorted(os.listdir(os.path.join(hdf5Folder, plate, 'hdf5')))
        if wellL is not None:
            listW = wellL
        for well in listW[:18]:
            well=well.split('_')[0]+'_'+well.split('_')[1][:2]
            if not xb_screen:
                filename = os.path.join(hdf5Folder, plate, 'hdf5', well+".hdf5")
            else:
                filename = os.path.join(hdf5Folder, plate, 'hdf5', well+".ch5")
            print well

                                
            if training:
                filenameT = '/media/lalil0u/New/workspace2/Tracking/data/trainingset/PL'+plate+"___P"+well+"___T00000.xml"
            else:
                filenameT = None
                
            monOutput+="plate = "+plate+",well = "+well+"\n"
            #ajout du frameLot et du tabF
            frameLotC, tabFC = gettingRaw(filename, filenameT, plate, well, name_primary_channel='primary__primary3')
            if newFrameLot == None:
                newFrameLot = frameLotC 
            else: newFrameLot.addFrameLot(frameLotC)
            tabF = tabFC if tabF == None else np.vstack((tabF, tabFC))
    
    #en ce qui concerne le nettoyage des NaN
    c, f2 = treatments.whichAreNan(tabF)
    print len(f2.keys()), len(f)
    #if there are features with NaN entries in the predict data but not in the training data
    toZeros = filter(lambda x: x not in f, f2.keys())
    if toZeros !=[]:
        print "Attention attention, some features here have NaN entries, and this was not the case in the training set. They are put to 0"
        newFrameLot.zeros(toZeros)
    
#    if f!= f2.keys():
#        featuresNames = imp.importFeaturesNames(filename)
#        print filter(lambda x: x not in f, f2.keys())
#        pdb.set_trace()
    newFrameLot.clean(f) ##np.delete(X, f, 1)
    if first:
        FEATURE_NUMBER -=len(f)

    #FEATURE_NUMBER -=len(bou)
    
    print FEATURE_NUMBER
    print "Getting all uplets now"
    print "TIME TIME TIME", time.clock()
    #ICI ON RECUPERE DONC LES SINGLETS ET DOUBLETS AVEC LA VALEUR DU TRAINING DANS CELL.TO SI ILS Y SONT, NONE SINON
    #POUR LE CENTRE ET LES FEATURES C'EST LA MOYENNE DES OBJETS DU SINGLET
    if training == False:
        singlets, doublets = newFrameLot.getAllUplets(loadingFolder)
    else:
        singlets, doublets = newFrameLot.getTrainingUplets()
    print "TIME TIME TIME after getting all uplets", time.clock()
    print "joining uplets now"

    solutions = j(singlets, doublets, FEATURE_NUMBER, training)
    print "TIME TIME TIME after joining", time.clock()
    print "normalization"
    
    fichier = open(loadingFolder+"minMax_data_all.pkl", "r")  
    minMax = pickle.load(fichier)
    fichier.close()
    solutions.normalisation(minMax)
    print "TIME TIME TIME after normalization", time.clock()
    
    return solutions