-
Notifications
You must be signed in to change notification settings - Fork 0
/
fiji_snippets.py
131 lines (101 loc) · 3.01 KB
/
fiji_snippets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
########################################################
# Accessory jython code for protein_quantification.ijm
#
# -runs macro
# -gets image from processed image
# -calculate RawIntDen
# -IJ Results window does not work in --headless mode
#
# --USAGE---
# -run from command line:
#
# --doesn't work --headless because it loses windows
#
#
########################################################
from ij import IJ
from java.io import File
from ij.macro import MacroRunner
from ij import WindowManager as WM
import os
import os.path
import time
print "jython code works from the command line!"
macropath = "/Users/joshtitlow/Downloads/protein_quantification.ijm"
macrofile = File(macropath)
mr = MacroRunner(macrofile)
print mr
my_file = "/Users/joshtitlow/tmp/AdultBrain_smFISH/test/test.tif"
while not os.path.exists(my_file):
time.sleep(10)
mask_signal = WM.getImage('mask_signal')
ip = mask_signal.getProcessor().convertToFloat()
pixels = ip.getPixels()
RawIntDen = sum(pixels)
print RawIntDen
print "macro worked"
#if os.path.isfile(my_file):
# print "file ready"
#else:
# print "file does not exist"
#my_file = "/Users/joshtitlow/tmp/AdultBrain_smFISH/test.csv"
#value = os.path.isfile(my_file)
#print value
#while value != "True":
#
#macropath = "/Users/joshtitlow/src_FIJI_macros/py_macro.ijm"
#macrofile = File(macropath)
#mr = MacroRunner(macrofile)
#print "done"
#mask_signal = WM.getImage('mask_signal')
#ip = mask_signal.getProcessor().convertToFloat()
#pixels = ip.getPixels()
#RawIntDen = sum(pixels)
#print RawIntDen
#macropath = "/Users/joshtitlow/Downloads/protein_quantification.ijm"
#macrofile = File(macropath)
#mr = MacroRunner(macrofile)
#mask_signal = WM.getImage('mask_signal')
#ip = mask_signal.getProcessor().convertToFloat()
#pixels = ip.getPixels()
#RawIntDen = sum(pixels)
#print RawIntDen
#ip = mask_signal.getProcessor().convertToFloat()
#ip.type()
#import os
#my_file = "/Users/joshtitlow/tmp/AdultBrain_smFISH/test.csv"
#value = os.path.isfile(my_file)
#print value
#while value != "True":
#
#print "done"
#else:
# print "false"
#while count<10:
# count = count+1
# print "count = ",count
#print "Good Bye!"
#invert_mask_signal = IJ.getImage(invert_mask_signal)
#mask_vol = IJ.getImage(mask_vol)
#inv_mask_vol = IJ.getImage(inv_mask_volsk_vol)
#from ij import IJ
#image = "file1.r3d"
#imp = IJ.getImage("file1.r3d")
#ip = imp.getProcessor().convertToFloat()
#pixels = ip.getPixels()
#RawIntDen = sum(pixels)
#print RawIntDen
# Grab currently active image
#imp = IJ.getImage()
#IJ.run(imp, "Median...", "radius=2");
#imp = IJ.openImage("http://imagej.net/images/blobs.gif")
#ip = imp.getProcessor().convertToFloat()
#pixels = ip.getPixels()
#RawIntDen = sum(pixels)
#print RawIntDen
# Compute the mean value (sum of all divided by number of pixels)
#format = 506*506
#print "Total # of pixels = ", format
#print "IJ # of pixels = ", imp.width * imp.height
#print "# of missing pixels = ", format - len(pixels)
#print "# of 0 intensity pixels = ", sum(x == 0 for x in pixels)