Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MIF
Workflow
LUT-creation
Commits
d329544f
Commit
d329544f
authored
Nov 27, 2018
by
Chris Evenhuis
Browse files
Added Roi and user defined plots
parent
43f793d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
lut-creation.py
View file @
d329544f
...
...
@@ -101,37 +101,54 @@ def find_root( f, x0s, v, *args ):
if
(
abs
(
f0
-
f1
)
<
1e-6
):
break
return
0.5
*
(
x0
+
x1
)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def
request_parameters
():
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
from
fiji.util.gui
import
GenericDialogPlus
Imax
,
Pm
,
a
,
b
=
7500
,
135
,
0.86
,
0.05
gdp
=
GenericDialogPlus
(
"Photo Inhibition Curve"
)
gdp
.
addNumericField
(
"Imax"
,
Imax
,
0
)
gdp
.
addNumericField
(
"Pm"
,
Pm
,
0
)
gdp
.
addNumericField
(
"alpha"
,
a
,
2
)
gdp
.
addNumericField
(
"beta"
,
b
,
2
)
## gdp.addCheckbox("Walk sub directories",False)
gdp
.
setSize
(
750
,
150
)
gdp
.
showDialog
()
Imax
=
gdp
.
getNextNumber
()
Pm
=
gdp
.
getNextNumber
()
a
=
gdp
.
getNextNumber
()
b
=
gdp
.
getNextNumber
()
return
[
Imax
,
Pm
,
a
,
b
]
if
(
True
):
rs
,
gs
,
bs
=
create_LUT
()
lut
=
LUT
(
int2byte
(
rs
),
int2byte
(
gs
),
int2byte
(
bs
)
)
#
rs,gs,bs = create_LUT()
#
lut = LUT( int2byte(rs),int2byte(gs),int2byte(bs) )
[
Imax
,
Pm
,
a
,
b
]
=
request_parameters
()
Imax
=
7500.
Pm
=
135.2
a
=
0.87
b
=
0.05
# create the ETR plot
I
=
[
Imax
*
i
/
200
for
i
in
range
(
201
)]
I
=
[
Imax
*
i
/
200
for
i
in
range
(
201
)]
# max intensity values
pmax
=
plat_max
(
Pm
,
a
,
b
)
pmax
=
plat_max
(
Pm
,
a
,
b
)
# find the max of the PI curve
print
(
pmax
)
# assemble the critical points
I2
=
pmax
[
0
]
I1
=
find_root
(
plat
,
[
0.
,
I2
],
0.5
*
pmax
[
1
],
Pm
,
a
,
b
)
I1
=
find_root
(
plat
,
[
0.
,
I2
],
0.5
0
*
pmax
[
1
],
Pm
,
a
,
b
)
I3
=
find_root
(
plat
,
[
I2
,
I2
*
2
],
0.95
*
pmax
[
1
],
Pm
,
a
,
b
)
I4
=
find_root
(
plat
,
[
I3
,
I3
*
2
],
0.5
*
pmax
[
1
],
Pm
,
a
,
b
)
I4
=
find_root
(
plat
,
[
I3
,
I3
*
2
],
0.50
*
pmax
[
1
],
Pm
,
a
,
b
)
Iarr
=
[
0.
,
I1
,
I2
,
I3
,
I4
,
Imax
]
<<<<<<<
HEAD
fs
=
[
0.
,
0.5
*
I1
/
I4
,
I1
/
I4
,
0.5
*
(
I1
+
I2
)
/
I4
,
I2
/
I4
,
0.5
*
(
I2
+
I3
)
/
I4
,
I3
/
I4
,
0.5
*
(
I3
+
I4
)
/
I4
,
1.
]
=======
print
(
I1
,
I2
,
I3
,
I4
)
# the transition points in the LUT
fs
=
[
0.
,
0.5
*
I1
/
I4
,
I1
/
I4
,
0.5
*
(
I1
+
I2
)
/
I4
,
I2
/
I4
,
I3
/
I4
,
I3
/
I4
,
0.5
*
(
I3
+
I4
)
/
I4
,
1.
]
>>>>>>>
345428
bc9fabd5f3d21977483345cd0aa9128604
print
(
fs
)
# create the LUT
rs
,
gs
,
bs
=
create_LUT
(
fi
=
fs
)
lut
=
LUT
(
int2byte
(
rs
),
int2byte
(
gs
),
int2byte
(
bs
)
)
# Make the plot of the ETR
xs
=
[
I1
,
I2
,
I3
,
I4
]
Vs
=
plat
(
I
,
Pm
,
a
,
b
)
plot
=
Plot
(
"Plat"
,
"Light"
,
"ETR"
,
I
,
Vs
)
...
...
@@ -139,24 +156,48 @@ if( True):
i
=
I
[
j
]
n
=
int
((
i
-
0
)
/
I4
*
256
)
n
=
min
(
max
(
0
,
n
),
255
)
#print(n)
plot
.
setColor
(
Color
(
rs
[
n
],
gs
[
n
],
bs
[
n
],
255
))
#plot.add("line",[i,i],[0,Vs[j]])
plot
.
add
(
"filled"
,[
I
[
j
-
1
],
I
[
j
]],[
Vs
[
j
-
1
],
Vs
[
j
]])
print
(
xs
)
plot
.
setColor
(
Color
(
0
,
0
,
0
))
plot
.
add
(
'circles'
,
xs
,
plat
(
xs
,
Pm
,
a
,
b
)
)
plot
.
show
()
ip
=
imp
.
getProcessor
().
duplicate
()
ip
.
setMinAndMax
(
0.
,
I1
)
# Measure the areas of the regions
from
ij.process
import
ImageStatistics
from
ij.plugin.frame
import
RoiManager
from
ij.plugin.filter
import
ThresholdToSelection
as
TS
mask
=
ip
.
createMask
()
print
(
type
(
mask
))
dfjk
roi
=
TS
().
convert
(
mask
)
#imp.setRoi(roi)
from
ij.measure
import
Measurements
,
ResultsTable
# set up the roi
ip
=
imp
.
getProcessor
().
duplicate
()
roim
=
RoiManager
.
getInstance
()
if
(
roim
is
None
):
roim
=
RoiManager
()
roim
.
reset
()
measure_int
=
Measurements
.
CENTROID
+
Measurements
.
ELLIPSE
+
Measurements
.
AREA
+
Measurements
.
SHAPE_DESCRIPTORS
rt
=
ResultsTable
()
photoclass
=
[
'unsufficent'
,
'sub-optimal'
,
'optimal'
,
'inhibited'
,
'critical'
]
Iarr
=
[
0.
,
I1
,
I2
,
I3
,
I4
,
Imax
]
for
i
in
range
(
len
(
photoclass
)):
rt
.
setValue
(
"class"
,
i
,
photoclass
[
i
])
ip
.
setThreshold
(
Iarr
[
i
],
Iarr
[
i
+
1
],
ip
.
NO_LUT_UPDATE
)
roi
=
TS
().
convert
(
ip
)
if
(
roi
is
not
None
):
roi
.
setName
(
photoclass
[
i
])
roim
.
addRoi
(
roi
)
ip
.
setRoi
(
roi
)
stats
=
ImageStatistics
.
getStatistics
(
ip
,
measure_int
,
imp
.
getCalibration
())
rt
.
setValue
(
"Area"
,
i
,
stats
.
area
)
rt
.
setValue
(
"Mean I"
,
i
,
stats
.
mean
)
rt
.
show
(
"Areas"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment