コード例 #1
0
ファイル: FmultiMorph.py プロジェクト: mkreitze/graphMorph
quantifer = "small"

#Score matrix inits
crissCrossRecord=open(f"crissCross {quantifer}", "r")
sMs=[]
for line in crissCrossRecord:
    line=line.split(":")[2][:-2]
    sMs.append(libFBCAGen.convTextListToList(line))

## MAIN ## 

# Generates the images for the vertexs 
libFBCAGen.finalImage=1 #generate final level map?
libFBCAGen.useImages=1 #generate gifs? 
for n in range(0,len(sMs)):
    libFBCAGen.generateFBCA(sMs[n],d,CAMapInit,str(n)) #Generate the final L_g
libFBCAGen.finalImage=0 #generate final level map?
libFBCAGen.useImages=0 #generate gifs? 


# Then lets generate their morphs
for n in range(0,len(sMs)-1): #Incase we have multiple matrices we want to morph between
    for m in range(n+1,len(sMs)):
        behaviours=[]
        fPs=[]
        quantifer = f"fMorph ({n},{m}) - {quantiferRead}"
        l=0
        for x in numpy.arange(0,1+1e-8,float(1/morphRes)): #In this loop we generate all the L_gs for the morph
            sMCur = libFBCAGen.genMorphSM(sMs[n],sMs[m],x) #gets score matrix for this point in the morph
            fPs.append(fPrint())
            fPs[len(fPs)-1].fP = libFBCAGen.genFingerPrint(sMCur) #gets the FP
コード例 #2
0
libFBCAGen.CALength = 20  #Length of the generated image (for min use 5)
libFBCAGen.CAWidth = 20  #Width of the generated image (for min use 4)
libFBCAGen.useImages = 1  #checks if you want images This is annoying
libFBCAGen.numOfGens = 20  #number of generations
libFBCAGen.numOfStates = 2  #number of states (good until 10)
smallDelta = 1e-6
CAMapInit = []
borderLambdas = []
CAMapInit = libFBCAGen.initCA(CAMapInit)

##START
edgeRecord = open("morphEdges", "r")
#loops through files
for line in edgeRecord:
    splits = []
    sM1 = []
    sM2 = []
    lambdas = []
    levelMap = []
    splits = line.split("sMs")
    lambdas = convTextListToList(splits[0])
    sM1 = convTextListToList(splits[1])
    sM2 = convTextListToList(splits[2])
    for lamb in lambdas:
        sMCur = libFBCAGen.genMorphSM(sM1, sM2, lamb + smallDelta)
        levelMap = libFBCAGen.generateFBCA(sMCur, d, CAMapInit,
                                           str(lamb + smallDelta))
        sMCur = libFBCAGen.genMorphSM(sM1, sM2, lamb - smallDelta)
        levelMap = libFBCAGen.generateFBCA(sMCur, d, CAMapInit,
                                           str(lamb - smallDelta))
コード例 #3
0
ファイル: crisscrossFBCA.py プロジェクト: mkreitze/crissCross
libFBCAGen.useImages = 1  #generate gifs?
libFBCAGen.finalImage = 1  #generate final level map?
libFBCAGen.numOfGens = 20  #number of generations
libFBCAGen.random.seed(1)  #set to 1 for constant
d = []
d = os.getcwd() + "/"  #Get directory
#Score matrix inits
sM1 = [0.320205, 0.952292, 0.351335, 0.837774]
sM2 = [0.390741, 0.728013, 0.614486, 0.378596]
sMs = [sM1, sM2]
#generate first guys
libFBCAGen.numOfStates = int(len(sM1) / 2)
CAMapInit = []
CAMapInit = libFBCAGen.initCA(CAMapInit)  #Get L_0
for idx, curSM in enumerate(sMs):
    libFBCAGen.generateFBCA(curSM, d, CAMapInit,
                            str(idx))  #Generate the final L_g
#get ready for the increased dim
libFBCAGen.numOfStates = len(
    sM1
)  #number of states (its assumed the set of score matrices given are all the same dimension)
numOfSpots = len(sM1)
numOfStates = len(sMs)
quantifer = "test"
CAMapInit = []
CAMapInit = libFBCAGen.initCA(CAMapInit)  #Get L_0


# Generates crisscrossed matrices #
### Input: the score matrices used to crissCross, the configuration of score matrices, the iteration number,
### Output: a 2*n number of state score matrix crissCrossed
# Notes:
コード例 #4
0
import FBCAConsts
import libFBCAGen
# generate a text file
exFBCA = FBCAConsts.Fbca()
exFBCA.scoreMatrix = [0, 0.5, 0.2, 0.6]
exFBCA.levelMap = libFBCAGen.initCA(exFBCA)
exFBCA.g = 6
libFBCAGen.genText(exFBCA, fileName="readTextExample.txt")
# read from text
fileToReadFrom = "readTextExample.txt"
listOfFBCAs = libFBCAGen.readFBCA(fileToReadFrom)
print(listOfFBCAs[0].g)
print(listOfFBCAs[0].n)
print(listOfFBCAs[0].torusWidth)
print(listOfFBCAs[0].torusLength)
print(listOfFBCAs[0].scoreMatrix)
print(listOfFBCAs[0].neighbourhood)
libFBCAGen.generateFBCA(exFBCA, quantifer="/original", saveImages=True)
libFBCAGen.generateFBCA(listOfFBCAs[0], quantifer="/new", saveImages=True)
コード例 #5
0
ファイル: FgraphMorph.py プロジェクト: mkreitze/graphMorph
quantifer = "halfBig"

#Score matrix inits
crissCrossRecord=open(f"crissCross {quantifer}", "r")
sMs=[]
for line in crissCrossRecord:
    line=line.split(":")[2][:-2]
    sMs.append(libFBCAGen.convTextListToList(line))

## MAIN ## 

# Generates the images for the vertexs 
libFBCAGen.finalImage=1 #generate final level map?
libFBCAGen.useImages=1 #generate gifs? 
for n in range(0,len(sMs)):
    libFBCAGen.generateFBCA(sMs[n],d,CAMapInit,str(n)) #Generate the final L_g
libFBCAGen.finalImage=0 #generate final level map?
libFBCAGen.useImages=0 #generate gifs? 

# Figures out how many finger prints per morph

# Then lets generate their morphs and resulting fingerprints
fPs=[]
for n in range(0,len(sMs)-1): #Incase we have multiple matrices we want to morph between
    for m in range(n+1,len(sMs)):
        quantifer = f"fMorph ({n},{m}) - {quantiferRead}"
        l=0
        for x in numpy.arange(0,1+1e-8,float(1/morphRes)): #In this loop we generate all the L_gs for the morph
            sMCur = libFBCAGen.genMorphSM(sMs[n],sMs[m],x) #gets score matrix for this point in the morph
            fPs.append(fPrint())
            fPs[len(fPs)-1].fP = libFBCAGen.genFingerPrint(sMCur) #gets the FP
コード例 #6
0
libFBCAGen.finalImage = 0  #Keep 0
libFBCAGen.numOfGens = 20  #number of generations
libFBCAGen.numOfStates = 2  #number of states (good until 10)

## BORING INITS
d = []
d = os.getcwd() + "/"
curSide = ["Left", "Right", "Middle"]
CAMapInit = []
CAMapInit = libFBCAGen.initCA(CAMapInit)
borderLambdas = []

## MAIN ##
# Generates the inital L_g containers
lGLeft = lGContainer(0, sM1,
                     libFBCAGen.generateFBCA(sM1, d, CAMapInit, curSide[0]),
                     curSide[0])
lGRight = lGContainer(1, sM2,
                      libFBCAGen.generateFBCA(sM2, d, CAMapInit, curSide[1]),
                      curSide[1])
lGMid = lGContainer(
    0.5, libFBCAGen.genMorphSM(sM1, sM2, 0.5),
    libFBCAGen.generateFBCA(libFBCAGen.genMorphSM(sM1, sM2, 0.5), d, CAMapInit,
                            curSide[2]), curSide[2])

direction = 0
lastDifferentLambda = 0
##Goes left to right
for n in range(0, len(sMs)):  # because we may have many
    if n % 2 == 0:
        while (libFBCAGen.compareLs(lGRight, lGLeft) == 0):
コード例 #7
0
d = os.getcwd() + "/"
#defintions for FBCA generation
libFBCAGen.CALength = 20  #Length of the generated image (for min use 5)
libFBCAGen.CAWidth = 20  #Width of the generated image (for min use 4)
libFBCAGen.useImages = 1  #checks if you want images This is annoying
libFBCAGen.numOfGens = 20  #number of generations
libFBCAGen.numOfStates = 2  #number of states (good until 10)
CAMapInit = []
borderLambdas = []
CAMapInit = libFBCAGen.initCA(CAMapInit)

##START
morphRecord = open("morphPortrait record Two at 1000 rand(4)", "r")
#loops through files
sM1 = []
sM2 = []
lambdas = []
levelMap = []
splits = []
for idx, line in enumerate(morphRecord):
    if idx == 0:
        splits = line.split("sMs")
        sM1 = convTextListToList(splits[1])
        sM2 = convTextListToList(splits[2])
    else:
        splits = line.split(" ")
        lambdas.append(float(splits[len(splits) - 2]))
for lamb in lambdas:
    sMCur = libFBCAGen.genMorphSM(sM1, sM2, lamb)
    levelMap = libFBCAGen.generateFBCA(sMCur, d, CAMapInit, str(lamb))
コード例 #8
0
ファイル: genFBCAExample.py プロジェクト: mkreitze/libFBCAGen
import FBCAConsts
import libFBCAGen
exFBCA = FBCAConsts.Fbca()
exFBCA.scoreMatrix = [0, 0.5, 0.2, 0.6]
exFBCA.levelMap = libFBCAGen.initCA(exFBCA)
exFBCA.g = 6
exFBCA.levelMap = libFBCAGen.generateFBCA(exFBCA,
                                          saveFinalImage=True,
                                          saveImages=True,
                                          saveFinalText=True,
                                          quantifer="generateFBCAExample")