-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
from ij import IJ | ||
from ij.plugin.frame import RoiManager | ||
|
||
print "Testing 123..." | ||
|
||
#converts microns (or whatever the physical dist is to pixels) | ||
''' | ||
def getPixelPos(x,y, imp): | ||
point = [0,0] | ||
point[0] = (x / cal.piXelW) | ||
point[1] = (imp.height * (y / 100)) | ||
return point | ||
''' | ||
rm = RoiManager.getInstance() #get the open ROI manager instance | ||
ra = rm.getRoisAsArray() #get all the ROIs in an array | ||
#print r1.getPosition() | ||
imp = IJ.getImage() #get current image | ||
stack = imp.getStack() #get current | ||
rm = RoiManager.getInstance() | ||
ra = rm.getRoisAsArray() | ||
nRois = len(ra) | ||
proc = IJ.getProcessor() #get the image processor | ||
cal = imp.getCalibration(); | ||
#print cal.pixelWidth | ||
#print imp.width | ||
nSlices = int(stack.getSize()) | ||
#print stack.getSize() | ||
#print r1.getFloatPolygon().xpoints[0] #get xpoint | ||
#first convert our ROIs to something more useful, a tuple containing the point (x,y) and the Z position => (x,y,z) | ||
for i in range(0, nRois-1): | ||
roi1 = rm.getRoi(i) | ||
roi2 = rm.getRoi(i+1) | ||
pt1 = (roi1.getFloatPolygon().xpoints[0],roi1.getFloatPolygon().ypoints[0],roi1.getPosition()) | ||
pt2 = (roi2.getFloatPolygon().xpoints[0],roi2.getFloatPolygon().ypoints[0],roi2.getPosition()) | ||
xcorrect = (pt1[0]-pt2[0]); | ||
ycorrect = (pt1[1]-pt2[1]); | ||
print "Point pair: " | ||
print pt1 | ||
print pt2 | ||
|
||
IJ.setSlice(pt1[2]) #set starting slice | ||
driftx = xcorrect/nSlices; | ||
offsetx = 0; | ||
startSlice = pt1[2] | ||
endSlice = pt2[2] | ||
print "startSlice: %s ;endSlice: %s" % (startSlice, endSlice) | ||
for j in range(startSlice,endSlice): | ||
IJ.setSlice(j) | ||
offsetx += driftx | ||
IJ.run("Translate...", "interpolation=Bicubic slice y=0 x="+str(offsetx)); | ||
|
||
drifty = ycorrect/nSlices; | ||
offsety = 0; | ||
for k in range(startSlice,endSlice): | ||
IJ.setSlice(k) | ||
offsety += drifty | ||
IJ.run("Translate...", "interpolation=Bicubic slice x=0 y="+str(offsety)); | ||
|
||
|