Example #1
0
def main(tableName, showPlot):
    image = IJ.getImage();
    roi = image.getRoi()
    if not roi:
        center = image.getWidth() / 2, image.getHeight() / 2
    else:
        center = roi.getXBase(), roi.getYBase();
    table = ResultsTable.getResultsTable(tableName)
    vectors = getVectorsFromTable(table, center)
    radialVelocity = calculateRadialVelocityPerTime(vectors, center)
    radialVelocityAndDistanceByTrack(table, center)
    stats = Tools.getStatistics(radialVelocity)
    median = calculateMedian(radialVelocity)
    rt = ResultsTable.getResultsTable(TABLE_NAME)
    if not rt:
        rt = ResultsTable()
    row = rt.getCounter()
    rt.setValue("label", row, tableName)
    rt.setValue("x", row, center[0])
    rt.setValue("y", row, center[1])
    rt.setValue("mean", row, stats.mean)
    rt.setValue("stdDev", row, stats.stdDev)
    rt.setValue("min", row, stats.min)
    rt.setValue("median", row, median)
    rt.setValue("max", row, stats.max)
    rt.show(TABLE_NAME)
    if showPlot:
        plot(radialVelocity, center)
Example #2
0
def calculateMedian(aList):
    ranks = Tools.rank(aList)
    if len(ranks) % 2 == 0:
        higherIndex = int(len(ranks)/2) 
        lowerIndex = higherIndex-1
        return (aList[lowerIndex] + aList[higherIndex]) / 2.0
    else:
        return aList[ranks[int(len(ranks)/2)]]
  #filelist = os.listdir(filedir)
  for root, directories, filenames in os.walk(filedir):
    print directories
    for filename in filenames:	
      if filename.lower().endswith('.lif'):
        print filedir
        print "..." + filename
        filebase = splitext(filename)[0]
        imps = getImps(os.path.join(filedir, filename))
        printInfo(imps)	
        for (counter, item) in enumerate(imps):
          #outimp = zproj(item)
          outimp = makeComposite(item)
          #outimp.show()
          #outname = filedir + filebase + "/" + "s" + str(counter) + ".tif"
          subname = ijtool.split(item.getTitle(), " - ")[1]
          #outname = filedir + filebase + "/" + subname + "_ZP.tif"
          outdir = os.path.join(filedir, "processed")
          outname = os.path.join(outdir, filebase + "_" + subname + "_" + str(counter) + "_Composite")
          print outname
          if not os.path.isdir(outdir):
            os.mkdir(outdir)
          fs = FileSaver(outimp)
          fs.saveAsTiffStack(outname+".tif")
          fs.saveAsJpeg(outname+".jpg")
          

#outimp = zproject(filepath)
#outimp.show()

Example #4
0
strPath = strImgRoot + strRel
umPerPx = 0.0368365
strUmPerPx = str(umPerPx)

strCal = "channels=1 slices=1 frames=1 unit=micron pixel_width="
strCal += strUmPerPx
strCal += " pixel_height="
strCal += strUmPerPx
strCal += "  voxel_depth=1.0000000 frame=[0 sec] origin=0,0"

# print strPath

for file in os.listdir(strPath):
  print file
  sFile = os.path.join(strPath, file)
  imp = IJ.openImage(sFile)
  imp.show()
  IJ.run(imp, "Properties...", strCal)
  IJ.run("16-bit")
  imp.show()
  strRpt = Tools.split(imp.getTitle(), ".")[0] + "-ij.csv"
  strCmd = "min=200 max=999999 top/bottom=5 lo=0.25 med=0.50 hi=0.75 log=0 path="
  strCmd += strRptPath + " report=" + strRpt
  IJ.run("Analyze Line", strCmd)
  IJ.selectWindow(imp.getTitle())
  strImgOut =  strPngPath + Tools.split(imp.getTitle(), ".")[0] + ".png"
  IJ.saveAs("PNG", strImgOut)
  IJ.run("Close")


import os

strGitHome = os.environ['GIT_HOME']
strImgDir = "/OSImageAnalysis/ImageJ/Analyze_Line/std/"
umPerPx = 0.0368365

# should not need to change below here...
strImage = strGitHome + strImgDir + "line.tif"
strUmPerPx = str(umPerPx)
strRptPath = strGitHome + strImgDir

strCal = "channels=1 slices=1 frames=1 unit=micron pixel_width="
strCal += strUmPerPx
strCal += " pixel_height="
strCal += strUmPerPx
strCal += "  voxel_depth=1.0000000 frame=[0 sec] origin=0,0"

imp = IJ.openImage(strImage)
IJ.run(imp, "Properties...", strCal)
imp.show()
IJ.run("16-bit")
imp.show()

strRpt = Tools.split(imp.getTitle(), ".")[0] + "-ij.csv"
strCmd = "min=200 max=999999 top/bottom=5 lo=0.25 med=0.50 hi=0.75 log=0 path="
strCmd += strRptPath + " report=" + strRpt

IJ.run("Analyze Line", strCmd)