def checkPrevRun(): """ Checks for previous identical runs to prevent running identical sweeps""" path = "..\\Analysis\\"+sweep+"\\"+str(sys.argv[1])+"\\"+sys.argv[2]+"\\Analysis.csv" if not os.path.exists(path): csv.writer(open(path,'wb')) flag = 0 if os.path.exists(path): checkFile = csv.reader(open(path,'r')) for line in checkFile: param = [str(num) for num in scaffold._registeredParams["valueChange"].defaultValue] if param == line[:len(param)]: return True return False scaffold.registerParameter("default_", 'default') """ Default => no params are being swept """ scaffold.registerParameter("valueChange", valueChange) """Current parameter values swept.""" for i in range(len(keyChange)): print "Setting ", keyChange[i], " as ", params[keyChange[i]] print "\n" density = sys.argv[1] filename = sys.argv[2] outputs = ["renderRemovedBackgroundOutput.avi", "renderSeedImagesOutput.avi", "renderDiffsOutput.avi", "renderMasksOutput.avi", "renderMorphedImagesOutput.avi", "renderWatershedOutput.avi", "renderRegionsOutput.avi", "renderEllipsesOutput.avi", "renderTracksOutput.avi", "plotParticleDistanceOutput.png", "plotPIVFieldOutput.mp4", "plotDensityFieldOutput.avi", "plotVelocityFieldOutput.avi"] params["configFile"] = "..\\..\\Data\\July292011\\" + str(density) + "\Series" + str(filename) + "_Properties.xml" for key in outputs: filepath = "..\\Analysis\\"+sweep+"\\"+str(density) + "\\" + str(filename) + "\\" + key[:-4] +"\\" name = "_".join(valueChange).replace(".","") + key[-4:] params[key[:-4]] = filepath + name if not os.path.exists(filepath): os.makedirs(filepath) return params
from xml.dom import minidom import re import os import numpy as np import _regions import tables as tb __all__ = ['CONFIG_FILE', 'LOCAL_GROUP_PREFIX', 'ExtractUniqueId', 'ParseConfig', 'createImageArray', 'LoadImages', 'ComputeForegroundMasks' 'MASK_LOW_THRESH', 'MASK_HIGH_THRESH'] CONFIG_FILE = scaffold.registerParameter("configFile", "") """ The location of the configuration file for this image series. It should point to a _Properties.xml file. """ LOCAL_GROUP_PREFIX = scaffold.registerParameter("localGroupPrefix", "/data") """The prefix used for paths inside of the h5 file for this image sequence.""" class ExtractUniqueId(scaffold.Task): """ Extracts a unique ID from the configuration file. The ID is currently a combination of the start date and time. """
""" Tasks related to analyzing particle tracks for density calculations. :Edited: August 13, 2013 - contact([email protected]) """ import numpy as np from numpy.linalg import norm import math import tables as tb import images import scaffold import particles NUM_GRID_CELLS = scaffold.registerParameter("numGridCells_density", [20, 20]) """The number of rows and columns in the particle grid.""" def _griddedPath(task, path): return "{0}{1}_{2}".format(path, *task._param(NUM_GRID_CELLS)) class GridParticles(scaffold.Task): """ Creates an NxM grid and assigns a cell number to each particle at each frame, which is useful for local correlations and general optimizations. """ name = "Grid Particles" dependencies = [particles.FindParticlesViaMorph, images.ParseConfig] def isComplete(self): return self.context.hasNode(self._cellsPath)
return task._param(param).format(task.context.root._v_name) class _RenderTask(scaffold.Task): _outputParam = None def _render(self, images, mapping=lambda image: image): if self._outputParam is None: raise NotImplemented output = _formatOutput(self, self._outputParam) seq = im.ImageSeq(map(mapping, images)) seq.writeMovie(output) self.context.log("Rendered to {0}.", output) RENDER_MASKS_OUTPUT = scaffold.registerParameter("renderMasksOutput", "../videos/{0}-masks.avi") """The file path to render the output video of RenderForegroundMasks to.""" class RenderForegroundMasks(_RenderTask): name = "Render Foreground Masks" dependencies = [im.ComputeForegroundMasks] _outputParam = RENDER_MASKS_OUTPUT def run(self): images = self._import(im.ComputeForegroundMasks, "masks") self._render(images, im.binaryToGray) RENDER_DIFFS_OUTPUT = scaffold.registerParameter("renderDiffsOutput", "../videos/{0}-diffs.avi") """The file path to render the output video of RenderDifferences to."""
""" import cv import cv2 import numpy as np import math import tables as tb import images as im import scaffold import utils from scipy import stats from trackpy import tracking from matplotlib import pyplot as plt ELLIPSE_MIN_AREA = scaffold.registerParameter("ellipseMinArea", 4.0) """The minimum area required to identify an ellipse.""" ELLIPSE_MAX_AREA = scaffold.registerParameter("ellipseMaxArea", 200.0) """The maximum area required to identify an ellipse.""" EXPECTED_ELLIPSES_PER_FRAME = scaffold.registerParameter("expectedEllipsesPerFrame", 200) """The mean number of ellipses we expect to find. It's used to optimize memory allocation.""" class ParticleFinder(scaffold.Task): """Base class for all of the different ways to find particles.""" def _findEllipsesViaContours(self, masks): """Dumps the ellipses found in ``masks`` into the ellipse table. ``masks`` should be an iterable of binary images. """
""" Tasks related to analyzing particle tracks. """ import numpy as np from numpy.linalg import norm import math import tables as tb import images import scaffold import particles NUM_GRID_CELLS = scaffold.registerParameter("numGridCells", [20, 20]) """The number of rows and columns in the particle grid.""" def _griddedPath(task, path): return "{0}{1}_{2}".format(path, *task._param(NUM_GRID_CELLS)) class GridParticles(scaffold.Task): """ Creates an NxM grid and assigns a cell number to each particle at each frame, which is useful for local correlations and general optimizations. """ name = "Grid Particles" dependencies = [particles.TrackParticles, images.ParseConfig] def isComplete(self): return self.context.hasNode(self._cellsPath) def export(self):
Tasks related to processing an image sequence to idenfity and track particles. :Edited: August 13, 2013 - contact([email protected]) """ from subprocess import call import cv, cv2, math, scaffold, utils, sys import numpy as np import tables as tb import images as im from scipy import stats from trackpy import tracking from matplotlib import pyplot as plt ELLIPSE_TABLE_PATH = "ellipses" ELLIPSE_MIN_AREA = scaffold.registerParameter("ellipseMinArea", 4.0) """The minimum area required to identify an ellipse.""" ELLIPSE_MAX_AREA = scaffold.registerParameter("ellipseMaxArea", 200.0) """The maximum area required to identify an ellipse.""" EXPECTED_ELLIPSES_PER_FRAME = scaffold.registerParameter("expectedEllipsesPerFrame", 200) """The mean number of ellipses we expect to find. It's used to optimize memory allocation.""" class ParticleFinder(scaffold.Task): """Base class for all of the different ways to find particles.""" def _findEllipsesViaContours(self, masks): """Dumps the ellipses found in ``masks`` into the ellipse table. ``masks`` should be an iterable of binary images. """