Commit 95998000 authored by aknecht2's avatar aknecht2

Added additional height calculation option -- from roi or height/width of the current image.

parent dcf1a91e
......@@ -1118,20 +1118,31 @@ class Image(object):
else:
return moments
def extractDimensions(self, potroi):
def extractDimsFromROI(self, roi):
roi = self._loadROI(roi)
plant = self.getBounds()
height = plant[0] - pot[0]
if self.conn:
self._addColumn("height")
self._addColumn("width")
self.conn.execute("update images set height=?,width=? where pegasusid=?", (height, self.x, self.dbid))
self.conn.commit()
return
else:
return [height, self.x]
def extractDimensions(self):
"""
:return: A list corresponding to the height and width of the image.
:rtype: list
Returns a list with the following form: [height, width]
"""
pot = self._loadROI(potroi)
plant = self.getBounds()
height = plant[0] - pot[0]
if self.conn:
self._addColumn("height")
self._addColumn("width")
self.conn.execute("update images set height=?,width=? where pegasusid=?", (height, self.x, self.dbid))
self.conn.execute("update images set height=?,width=? where pegasusid=?", (self.y, self.x, self.dbid))
self.conn.commit()
return
else:
......
......@@ -660,7 +660,7 @@ class ImageProcessor(Workflow):
exDep[type][clusternum[type]].append(jobname)
reqFile = derivedPath + "_" + self.workflow["extract"]["workflows"][type]["inputs"][0] + ".png"
exInput[type][clusternum[type]][reqFile] = {"file": reqFile, "transfer": save}
if "--dimensions" in self.workflow["extract"]["workflows"][type]["arguments"]:
if "--dimfromroi" in self.workflow["extract"]["workflows"][type]["arguments"]:
roiFile = derivedPath + "_" + self.workflow["extract"]["workflows"][type]["arguments"]["--dimensions"] + ".json"
exInput[type][clusternum[type]][roiFile] = {"file": roiFile, "transfer": save}
else:
......@@ -680,15 +680,15 @@ class ImageProcessor(Workflow):
arguments = self.workflow["extract"]["workflows"][type]["arguments"]
if "--input" in arguments:
del arguments["--input"]
if "--dimensions" in arguments:
del arguments["--dimensions"]
if "--dimfromroi" in arguments:
del arguments["--dimfromroi"]
if "histogram-bin" in self.workflow["extract"]:
if type in [imtype for key in self.workflow["extract"]["histogram-bin"]["--group"] for imtype in self.workflow["extract"]["histogram-bin"]["--group"][key]]:
arguments["--colors"] = ""
arguments["--db"] = "db"
arguments["--createdb"] = ""
arguments["--inputs"] = " ".join([x for x in exInput[type][q].keys() if ".png" in x])
arguments["--dimensions"] = " ".join([x for x in exInput[type][q].keys() if ".json" in x])
arguments["--dimfromroi"] = " ".join([x for x in exInput[type][q].keys() if ".json" in x])
self._addFile(type + str(q) + ".db", type, "output")
self._addJob(type + "_extract" + str(q), "ih-extract-multi", exInput[type][q], {"db": {"file": type + str(q) + ".db", "transfer": False}}, arguments, exDep[type][q], walltime = 240)
self._addJob(type + "_extract" + str(q), "ih-extract-multi", exInput[type][q], {"db": {"file": type + str(q) + ".db", "transfer": False}}, arguments, [], dax = self.exdax, walltime = 240)
......
......@@ -9,7 +9,8 @@ parser = argparse.ArgumentParser(description = "Extracts numerical information f
parser.add_argument("--input", dest="input", help="Path to processed image.", required = True)
parser.add_argument("--dbid", dest="dbid", help="Image Id, used for database writing", required = True)
parser.add_argument("--db", dest="db", help="Path to database to write", required = True)
parser.add_argument("--dimensions", dest="dimensions", default=None, help="Path to pot roi file.")
parser.add_argument("--dimensions", dest="dimensions", default=False, action="store_true", help="Extract dimensions.")
parser.add_argument("--dimfromroi", dest="dimfromroi", help="Path to roi file for modified dimensions extraction.")
parser.add_argument("--pixels", dest="pixels", default=False, action="store_true", help="Extract pixels.")
parser.add_argument("--colors", dest="colors", default=False, action="store_true", help="Extract color data.")
parser.add_argument("--channels", dest="channels", default=False, action="store_true", help="Extract channel data.")
......@@ -24,8 +25,10 @@ try:
plant.extractFinalPath()
if args.dimensions:
plant.extractDimensions(args.dimensions)
if args.dimfromroi:
plant.extractDimsFromROI(args.dimfromroi):
elif args.dimensions:
plant.extractDimensions()
if args.pixels:
plant.extractPixels()
......
......@@ -9,7 +9,8 @@ parser = argparse.ArgumentParser(description = "Extracts numerical information f
parser.add_argument("--inputs", dest="inputs", nargs="+", help="Path to processed image.", required = True)
parser.add_argument("--db", dest="db", help="Path to database to write", required = True)
parser.add_argument("--createdb", dest="createdb", default=False, action="store_true", help = "Create database file specified by db")
parser.add_argument("--dimensions", dest="dimensions", nargs="+", help="Path to pot roi file.")
parser.add_argument("--dimensions", dest="dimensions", default=False, action="store_true", help="Extract dimensions.")
parser.add_argument("--dimfromroi", dest="dimfromroi", nargs="+", help="Path to roi files fro modified dimensions extraction.")
parser.add_argument("--pixels", dest="pixels", default=False, action="store_true", help="Extract pixels.")
parser.add_argument("--colors", dest="colors", default=False, action="store_true", help="Extract color data.")
parser.add_argument("--channels", dest="channels", default=False, action="store_true", help="Extract channel data.")
......@@ -36,8 +37,10 @@ try:
plant.extractFinalPath()
if args.dimensions[i]:
plant.extractDimensions(args.dimensions[i])
if args.dimfromroi[i]:
plant.extractDimsFromROI(args.dimfromroi[i]):
elif args.dimensions:
plant.extractDimensions()
if args.pixels:
plant.extractPixels()
......
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