Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit d6b891ea authored by Edward Andò's avatar Edward Andò
Browse files

adding spam-ereg-discrete, improvements to spam-ddic debug mode

parent 57506705
Pipeline #47958 failed with stages
in 4 minutes and 49 seconds
......@@ -340,6 +340,8 @@ if mpiRank == boss or not mpi:
# Get the next label off the queue
label, labelDilateCurrent = q.get()
if args.DEBUG: print("\n\n\nWorking on label:", label, "\n")
if args.DEBUG: print("Position (ZYX):", centresOfMass[label])
grainOK = False
getLabel = ltk.getLabel(lab1, label,
extractCube=False,
......@@ -426,19 +428,19 @@ if mpiRank == boss or not mpi:
print("r before pixel search:\n", spam.deformation.decomposePhi(PhiField[label])['r'])
plt.subplot(1,5,1)
plt.title("ref label")
plt.imshow(maskette1[maskette1.shape[0]//2])
plt.imshow(maskette1[:,:,maskette1.shape[2]//2])
plt.subplot(1,5,2)
plt.title("ref image")
plt.imshow(imagette1[imagette1.shape[0]//2])
plt.imshow(imagette1[:,:,imagette1.shape[2]//2])
plt.subplot(1,5,3)
plt.title("ref image deformed (no disp)")
plt.imshow(imagette1def[imagette1def.shape[0]//2])
plt.imshow(imagette1def[:,:,imagette1def.shape[2]//2])
plt.subplot(1,5,4)
plt.title("ref image deformed (no disp) + mask")
plt.imshow(imagette1toCorrelate[imagette1toCorrelate.shape[0]//2])
plt.imshow(imagette1toCorrelate[:,:,imagette1toCorrelate.shape[2]//2])
plt.subplot(1,5,5)
plt.title("def image search range")
plt.imshow(imagette2[imagette2.shape[0]//2])
plt.imshow(imagette2[:,:,imagette2.shape[2]//2])
plt.show()
pixelSearchReturns = spam.DIC.correlate.pixelSearch(imagette1toCorrelate,
......@@ -476,6 +478,8 @@ if mpiRank == boss or not mpi:
PhiTemp = PhiField[label].copy()
PhiTemp[0:3, -1] -= labelDisplacementInt
#PhiTemp[0:3,0:3] = numpy.linalg.inv(PhiField[label][0:3,0:3])
if args.DEBUG: print("Starting lk iterations with Phi - int(disp):\n", PhiTemp)
if args.DEBUG: print("\nStarting lk iterations with int(disp):\n", labelDisplacementInt)
if not mpi:
returns = spam.DIC.correlate.register(imagette1,
......
......@@ -131,6 +131,7 @@ scripts = ['scripts/spam-mmr',
"scripts/spam-ddic",
"scripts/spam-ldic",
"scripts/spam-ereg",
"scripts/spam-ereg-discrete",
"scripts/spam-deformImageFromField",
"scripts/spam-mmr-graphical",
"scripts/spam-moveGrains",
......
......@@ -476,31 +476,31 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
if imShowProgressNewFig: plt.figure()
else: plt.clf()
plt.subplot(3,3,1)
plt.imshow(im1crop[im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im1crop[im1crop.shape[0]//2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,2)
plt.imshow(im2def[crop2][im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im2def[crop2][im1crop.shape[0]//2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,3)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[im1crop.shape[0] // 2, :, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[im1crop.shape[0]//2, :, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
#if imShowProgress == "Y" or imShowProgress == "y":
#if imShowProgressNewFig: plt.figure()
#else: plt.clf()
plt.subplot(3,3,4)
plt.imshow(im1crop[:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im1crop[:, im1crop.shape[1]//2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,5)
plt.imshow(im2def[crop2][:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im2def[crop2][:, im1crop.shape[1]//2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,6)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, im1crop.shape[1] // 2, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, im1crop.shape[1]//2, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
#if imShowProgress == "X" or imShowProgress == "x":
#if imShowProgressNewFig: plt.figure()
#else: plt.clf()
plt.subplot(3,3,7)
plt.imshow(im1crop[:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im1crop[:, :, im1crop.shape[2]//2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,8)
plt.imshow(im2def[crop2][:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.imshow(im2def[crop2][:, :, im1crop.shape[2]//2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,9)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, :, im1crop.shape[2] // 2], cmap='coolwarm', vmin=vmin, vmax=vmax)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, :, im1crop.shape[2]//2], cmap='coolwarm', vmin=vmin, vmax=vmax)
plt.title('Iteration Number = {}'.format(iterations))
plt.pause(0.5)
plt.pause(0.1)
iterations += 1
......
......@@ -71,7 +71,7 @@ def ldicParser(parser):
type=int,
default=1,
dest='PHIFILE_BIN_RATIO',
help="Ratio of binning level between loaded F file and current calculation. If the input F file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
help="Ratio of binning level between loaded Phi file and current calculation. If the input Phi file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
parser.add_argument('-glt',
'--grey-low-threshold',
......@@ -312,7 +312,7 @@ def ldicParser(parser):
# 2018-03-24 check for 2D without loading images
# try:
# except BaseException:
# print("DICregularGrid: Input TIFF files need to be writeable in order to guess their dimensionality")
# print("DICregularGrid: Input TIFPhi files need to be writeable in order to guess their dimensionality")
# exit()
# 2019-03-21 EA: better check for dimensions, doesn't depend on writability of files
import tifffile
......@@ -532,7 +532,7 @@ def ddicParser(parser):
type=int,
default=1,
dest='PHIFILE_BIN_RATIO',
help="Ratio of binning level between loaded F file and current calculation. If the input F file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
help="Ratio of binning level between loaded Phi file and current calculation. If the input Phi file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
parser.add_argument('-pfd',
'--phiFile-direct',
......@@ -836,7 +836,7 @@ def multiModalRegistrationParser(parser):
# type=int,
# default=1,
# dest='PHIFILE_BIN_RATIO',
# help="Ratio of binning level between loaded F file and current calculation. If the input F file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
# help="Ratio of binning level between loaded Phi file and current calculation. If the input Phi file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
# parser.add_argument('-tra',
# '--translation',
......@@ -943,7 +943,7 @@ def gdicParser(parser):
type=int,
default=1,
dest='PHIFILE_BIN_RATIO',
help="Ratio of binning level between loaded F file and current calculation. If the input F file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
help="Ratio of binning level between loaded Phi file and current calculation. If the input Phi file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
# parser.add_argument('-glt',
# '--grey-low-threshold',
......@@ -1304,7 +1304,7 @@ def discreteStrainsCalcParser(parser):
help='Load a labelled image and compute radii? Only necessary if -tri is activated')
parser.add_argument('-rst',
'--return-stats-threshold',
'--return-status-threshold',
type=int,
default=None,
dest='RETURN_STAT_THRESHOLD',
......@@ -1380,6 +1380,98 @@ def discreteStrainsCalcParser(parser):
return args
def eregDiscreteParser(parser):
parser.add_argument('im1',
metavar='im1',
type=argparse.FileType('r'),
help="Greyscale image of reference state for correlation")
parser.add_argument('lab1',
metavar='lab1',
type=argparse.FileType('r'),
help="Labelled image of reference state for correlation")
parser.add_argument('im2',
metavar='im2',
type=argparse.FileType('r'),
help="Greyscale image of deformed state for correlation")
parser.add_argument('-mar',
'--margin',
type=int,
default=5,
dest='margin',
help="Margin in pixels. Default = 5")
parser.add_argument('-rst',
'--return-status-threshold',
type=int,
default=2,
dest='RETURN_STAT_THRESHOLD',
help='Skip labels already correlated with at least this return status (requires -pf obviously). Default = 2')
parser.add_argument('-ld',
'--label-dilate',
type=int,
default=1,
dest='LABEL_DILATE',
help="Number of times to dilate labels. Default = 1")
parser.add_argument('-pf',
'-phiFile',
dest='PHIFILE',
default=None,
type=argparse.FileType('r'),
help="Path to TSV file containing initial Phi guess for each label. Default = None")
parser.add_argument('-nomask',
'--no-mask',
action="store_false",
dest='MASK',
help='Don\'t mask each label\'s image')
parser.add_argument('-od',
'--out-dir',
type=str,
default=None,
dest='OUT_DIR',
help="Output directory, default is the dirname of input file")
parser.add_argument('-pre',
'--prefix',
type=str,
default=None,
dest='PREFIX',
help="Prefix for output files (without extension). Default is basename of input file")
args = parser.parse_args()
# If we have no out dir specified, deliver on our default promise -- this can't be done inline before since parser.parse_args() has not been run at that stage.
if args.OUT_DIR is None:
args.OUT_DIR = os.path.dirname(args.im1.name)
# However if we have no dir, notice this and make it the current directory.
if args.OUT_DIR == "":
args.OUT_DIR = "./"
else:
# Check existence of output directory
try:
if args.OUT_DIR:
os.makedirs(args.OUT_DIR)
else:
args.DIR_out = os.path.dirname(args.im1.name)
except OSError:
if not os.path.isdir(args.OUT_DIR):
raise
# Output file name prefix
if args.PREFIX is None:
args.PREFIX = os.path.splitext(os.path.basename(args.im1.name))[0] + "-" + os.path.splitext(os.path.basename(args.im2.name))[0]
return args
def moveGrainsParser(parser):
parser.add_argument('LabFile',
metavar='LabFile',
......@@ -1403,7 +1495,7 @@ def moveGrainsParser(parser):
type=str,
default=None,
dest='PREFIX',
help='Prefix for output TIFF file (without extension). Default is basename of input file')
help='Prefix for output TIFPhi file (without extension). Default is basename of input file')
parser.add_argument('-com',
'--apply-phi-centre-of-mass',
......@@ -1509,7 +1601,7 @@ def ITKwatershedParser(parser):
parser.add_argument('inFile',
metavar='inFile',
type=argparse.FileType('r'),
help='Path to binary TIFF file to be watershedded')
help='Path to binary TIFPhi file to be watershedded')
parser.add_argument('-ld',
'--label-dilate',
......@@ -1523,7 +1615,7 @@ def ITKwatershedParser(parser):
type=str,
default=None,
dest='MARKER_FILE',
help='Path to labelled TIFF file to use as markers')
help='Path to labelled TIFPhi file to use as markers')
parser.add_argument('-pre',
'--prefix',
......@@ -1720,7 +1812,7 @@ def deformImageFromFieldParser(parser):
parser.add_argument('inFile',
metavar='inFile',
type=argparse.FileType('r'),
help='Path to TIFF file containing the image to deform')
help='Path to TIFPhi file containing the image to deform')
parser.add_argument('-a',
'-triangulation-alpha-value',
......@@ -1748,7 +1840,7 @@ def deformImageFromFieldParser(parser):
type=int,
default=1,
dest='PHIFILE_BIN_RATIO',
help="Ratio of binning level between loaded F file and current calculation. If the input F file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
help="Ratio of binning level between loaded Phi file and current calculation. If the input Phi file has been obtained on a 500x500x500 image and now the calculation is on 1000x1000x1000, this should be 2. Default = 1")
parser.add_argument('-od',
'--out-dir',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment