Skip to content

Commit

Permalink
Fixed multi drift correction
Browse files Browse the repository at this point in the history
  • Loading branch information
outlace committed Jul 21, 2015
1 parent 3327e55 commit 36f5349
Show file tree
Hide file tree
Showing 8 changed files with 399 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.idea/*
1 change: 1 addition & 0 deletions Drift-Correction/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Drift-Correction/.idea/Drift-Correction.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Drift-Correction/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Drift-Correction/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Drift-Correction/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

349 changes: 349 additions & 0 deletions Drift-Correction/.idea/workspace.xml

Large diffs are not rendered by default.

Expand Up @@ -2,7 +2,7 @@
from ij import IJ
from ij.plugin.frame import RoiManager

print "Testing 123..."
print "'Multi Drift Correction' plugin; version 1.1; by Brandon Brown"

#converts microns (or whatever the physical dist is to pixels)
'''
Expand All @@ -24,7 +24,7 @@ def getPixelPos(x,y, imp):
cal = imp.getCalibration();
#print cal.pixelWidth
#print imp.width
nSlices = int(stack.getSize())
totSlices = 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)
Expand All @@ -33,28 +33,31 @@ def getPixelPos(x,y, imp):
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())
startSlice = pt1[2]
endSlice = pt2[2]
nSlices = (endSlice - startSlice)
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):
print "nSlices: %s" % (nSlices,)
for j in range(startSlice, totSlices+1):
IJ.setSlice(j)
offsetx += driftx
if j <= endSlice:
offsetx += driftx
IJ.run("Translate...", "interpolation=Bicubic slice y=0 x="+str(offsetx));

drifty = ycorrect/nSlices;
offsety = 0;
for k in range(startSlice,endSlice):
for k in range(startSlice, totSlices+1):
IJ.setSlice(k)
offsety += drifty
if k <= endSlice:
offsety += drifty
IJ.run("Translate...", "interpolation=Bicubic slice x=0 y="+str(offsety));


0 comments on commit 36f5349

Please sign in to comment.