Commit b714356e by Edward Andò

first sketch of spam-passPhiField that does reg->grid and reg->labels, now ps,...

`first sketch of spam-passPhiField that does reg->grid and reg->labels, now ps, ldic and ddic assume -pfd which is now deprecated`
parent cb868cca
 ... ... @@ -134,48 +134,8 @@ if args.PHIFILE is not None: # If the read Phi-file contains multiple lines it's an F field! else: if args.PHIFILE_DIRECT: print("spam-ldic: Assuming loaded PhiFile is coherent with the current run.") PhiField = PhiFromFile["PhiField"] else: # We don't trust this completely, re-interpolate it onto the grid # Read the coordinates and values of the input F field fieldCoords = PhiFromFile["fieldCoords"] fieldValues = PhiFromFile["PhiField"] # Create the k-d tree of the coordinates of the input F field from scipy.spatial import KDTree nNeighbours = args.NEIGHBOURS fieldTree = KDTree(fieldCoords) # Loop over each point of the current grid for label in range(numberOfLabels): # if verbose: print "\nWorking on label {} {:0.2f}%".format( label, (label/float(numberofPoints))*100) # reset F to zero, since we'll be doing an additive interpolation at the bottom here PhiField[label][0:3, 0:3] = 0 # Calculate the distance of the point of the current grid to the points of the input F field distance, indices = fieldTree.query(labelPositions[label], k=nNeighbours) # Check if we've hit the same point in the two grids if numpy.any(distance == 0): # Copy F of that point to the F in the current grid point PhiField[label] = fieldValues[indices][numpy.where(distance == 0)].copy() # If not, consider the closest neighbours else: # Compute the "Inverse Distance Weighting" since the closest points should have the major influence weightSumInv = sum(1/distance) # Loop over each neighbour for neighbour in range(nNeighbours): # Calculate it's weight weightInv = (1/distance[neighbour])/float(weightSumInv) # Fill the F of the current grid point with the weighted F components of the ith nearest neighbour in the input F field PhiField[label][:-1] += fieldValues[indices[neighbour]][:-1]*weightInv print("spam-ldic: Assuming loaded PhiFile is coherent with the current run (i.e., labels are the same).") PhiField = PhiFromFile["PhiField"] def correlateOneLabel(label): ... ...
 ... ... @@ -238,55 +238,9 @@ for im2number in range(1, len(args.inFiles)): # If the read Phi-file contains multiple lines it's an F field! else: if args.PHIFILE_DIRECT: print("spam-ldic: Assuming loaded PhiFile is coherent with the current run.") PhiField = PhiFromFile["PhiField"] else: # We don't trust this completely, re-interpolate it onto the grid # Read the coordinates and values of the input F field fieldCoords = PhiFromFile["fieldCoords"] fieldValues = PhiFromFile["PhiField"] # Create the k-d tree of the coordinates of the input F field from scipy.spatial import KDTree nNeighbours = args.NEIGHBOURS fieldTree = KDTree(fieldCoords) # Loop over each point of the current grid for node in range(nodePositions.shape[0]): # if verbose: print "\nWorking on node {} {:0.2f}%".format( node, (node/float(numberofPoints))*100) # reset F to zero, since we'll be doing an additive interpolation at the bottom here PhiField[node][0:3, 0:3] = 0 # Calculate the distance of the point of the current grid to the points of the input F field distance, indices = fieldTree.query(nodePositions[node], k=nNeighbours) # Check if we've hit the same point in the two grids if numpy.any(distance == 0): # Copy F of that point to the F in the current grid point PhiField[node] = fieldValues[indices][numpy.where(distance == 0)].copy() # If not, consider the closest neighbours else: # Compute the "Inverse Distance Weighting" since the closest points should have the major influence weightSumInv = sum(1/distance) # Loop over each neighbour for neighbour in range(nNeighbours): # Calculate it's weight weightInv = (1/distance[neighbour])/float(weightSumInv) # Fill the F of the current grid point with the weighted F components of the ith nearest neighbour in the input F field PhiField[node][:-1] += fieldValues[indices[neighbour]][:-1]*weightInv ## Now recompute F to be only rigid, and calculate rigid-body translations for each point #if args.REGSUB: #regPhiRigid = spam.deformation.computeRigidPhi(regPhi.copy()) #for node in range(nodePositions.shape[0]): #rigidDisp[node] = spam.deformation.decomposePhi(regPhiRigid.copy(), #PhiCentre=regCentre, #PhiPoint=nodePositions[node])["t"] print("spam-ldic: Assuming loaded PhiFile is coherent with the current run.") PhiField = PhiFromFile["PhiField"] numberOfNodes = nodePositions.shape[0] ... ...
 ... ... @@ -138,13 +138,6 @@ if args.PHIFILE is not None: PhiField[node] = PhiInit.copy() PhiField[node][0:3, -1] = spam.deformation.decomposePhi(PhiInit.copy(), PhiCentre=PhiFromFile["fieldCoords"][0], PhiPoint=nodePositions[node])["t"] ## Now recompute F to be only rigid, and calculate rigid-body translations for each point #if args.REGSUB: #PhiInitRigid = spam.deformation.computeRigidPhi(PhiInit.copy()) #for node in range(nodePositions.shape[0]): #rigidDisp[node] = spam.deformation.decomposePhi(PhiInitRigid.copy(), #PhiCentre=regCentre, #PhiPoint=nodePositions[node])["t"] # If the read Phi-file contains multiple lines it's an F field! else: ... ... @@ -330,41 +323,14 @@ if args.TSV: comments='', header=TSVheader) #if args.REGSUB: #outMatrix = numpy.array([numpy.array(range(nodePositions.shape[0])), #nodePositions[:, 0], nodePositions[:, 1], nodePositions[:, 2], #PhiFieldMinusRigid[:, 0, 0], PhiFieldMinusRigid[:, 0, 1], PhiFieldMinusRigid[:, 0, 2], PhiFieldMinusRigid[:, 0, 3], #PhiFieldMinusRigid[:, 1, 0], PhiFieldMinusRigid[:, 1, 1], PhiFieldMinusRigid[:, 1, 2], PhiFieldMinusRigid[:, 1, 3], #PhiFieldMinusRigid[:, 2, 0], PhiFieldMinusRigid[:, 2, 1], PhiFieldMinusRigid[:, 2, 2], PhiFieldMinusRigid[:, 2, 3]]).T #if args.PS == 'on' or ( registrationSuccessful == False and args.PS == 'auto'): #outMatrix = numpy.hstack([outMatrix, numpy.array([PSCC]).T]) #if args.GRID_POINT: #outMatrix = numpy.hstack([outMatrix, numpy.array([subPixelReturns['error'], #subPixelReturns['iterations'], #subPixelReturns['returnStatus'], #subPixelReturns['deltaPhiNorm']]).T]) #numpy.savetxt(args.OUT_DIR+"/"+args.PREFIX+"-regsub.tsv", #outMatrix, #fmt='%.7f', #delimiter='\t', #newline='\n', #comments='', #header=TSVheader) if args.TIFF: if args.LAB1 == None: if nodesDim[0] != 1: tifffile.imsave(args.OUT_DIR+"/"+args.PREFIX+"-Zdisp.tif", PhiField[:, 0, -1].astype('
 ... ... @@ -143,22 +143,25 @@ TTK_modules_pb = ["mesh", "label", "filters", "measurements", "kalisphera", "DIC ### hey! If you're adding something to the list below, please ### also add it to the list in docs/source/scripts.rst ############################################################### scripts = ['scripts/spam-mmr', 'scripts/spam-reg', scripts = [ 'scripts/spam-ereg', 'scripts/spam-ereg-discrete', 'scripts/spam-ddic', 'scripts/spam-deformImageFromField', 'scripts/spam-discreteStrain', 'scripts/spam-gdic', 'scripts/spam-ldic', 'scripts/spam-imposeBCFromDVC', 'scripts/spam-ITKwatershed', 'scripts/spam-mmr', 'scripts/spam-mmr-graphical', 'scripts/spam-moveLabels', 'scripts/spam-passPhiField', 'scripts/spam-pixelSearch', 'scripts/spam-pixelSearchPropagate', 'scripts/spam-gdic', "scripts/spam-ddic", "scripts/spam-ldic", "scripts/spam-ereg", "scripts/spam-ereg-discrete", "scripts/spam-deformImageFromField", "scripts/spam-mmr-graphical", "scripts/spam-moveLabels", "scripts/spam-discreteStrain", "scripts/spam-regularStrain", "scripts/spam-ITKwatershed", "scripts/imposeBCFromDVC"] 'scripts/spam-reg', 'scripts/spam-regularStrain' ] EXTRA_CFLAGS = ["-fopenmp", "-std=c++14", "-O3", "-lgmp"] ... ...