if fidLine[0] == "#": temp = fidLine.split() #print np.shape(temp) areas[count] = float(temp[8]) CS[count] = float(temp[6]) count = count + 1 fid.close() legend.append(line.rstrip()) peakTime.append(np.argmin(areas)) areasAll.append(areas) zPos, numContours, contours = IT.readContourFile(workingDir + region + '/' + line.rstrip() + '/' + line.rstrip() + '_' + contraction.rstrip()) cRest.append(contours[0]) cCont.append(contours[np.argmin(areas)]) print np.size(cRest), np.shape(cCont) f, ax1 = plt.subplots(1, 1) flib = 1 #Going to try flipping 6905_07 -> [1:3] #it flipped it back, cause of the landmark numbering lol ax1.plot(cRest[flib][:, 0], cRest[flib][:, 1] * -1, 'ob') ax1.plot(cCont[flib][:, 0], cCont[flib][:, 1] * -1, 'or')
workingDir = './../imageToolsTestSpace/' #we will have a control file that has all of the contour groups we are planning to use activeContours = open(workingDir + 'ContourList').readlines() #read in the contraction map CMap = np.loadtxt(workingDir + 'contractionMap') #set up infromation arrays contourData = [] contourInformation = [] #loop through activeContours for line in activeContours: print 'Opening contour:', line.rstrip() zPos, numContours, contours = IT.readContourFile(workingDir + line.rstrip() + '/Results.txt') #store the zPos and numContous in contourInformation contourInformation = contourInformation + [[zPos, numContours]] contourData = contourData + [contours] contractionMatrix, endtime = IT.createContractionMatrix( activeContours, contourInformation, contourData, CMap) #lets make a nxm spatial array for the first time point, where n=(x,y,z) and m are the nodes cMshape = np.shape(contractionMatrix) # fititng parameters for host mesh fitting host_mesh_pad = 10.0 # host mesh padding around slave points host_elem_type = 'quad333' # quadrilateral cubic host elements host_elems = [1, 1, 3] # a single element host mesh
import numpy as np import matplotlib.pyplot as plt import imageTools as IT from fieldwork.field.tools import fitting_tools plt.switch_backend('TkAgg') print '\nRunning script registerZeroPositionToSpiral...' workingDir = './../imageToolsTestSpace/' filename='6948_02' #import the xyzPositions for corresponding spiral contour spiralContour=np.loadtxt(workingDir+filename+'/CorrespondingSpiral/spiralControlPoints') #import zero position contour from results zPos,numContours,contours=IT.readContourFile(workingDir+filename+'/Results.txt') #Ditch it all but keep the first contour deformContour=contours[0] xOpt,transformedContour=fitting_tools.fitTranslation(deformContour, spiralContour, xtol=1e-5, maxfev=0, sample=None, verbose=0, outputErrors=0) #plot for sanity check fig=plt.figure() ax = fig.add_subplot(111) ax.scatter(spiralContour[:,0],spiralContour[:,1]*-1,facecolors='g', edgecolors='g') ax.scatter(deformContour[:,0],deformContour[:,1]*-1,facecolors='r', edgecolors='r') #ax.scatter(transformedContour[:,0],transformedContour[:,1]*-1,facecolors='b', edgecolors='b') ax.axis('equal') for i in range(np.shape(spiralContour)[0]): print spiralContour[i,0]