Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
myosoft-imcf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
imcf
myosoft-imcf
Commits
e3e5ee76
Commit
e3e5ee76
authored
1 month ago
by
Kai Schleicher
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused function and imports
parent
fa02df72
No related branches found
No related tags found
1 merge request
!2
Initial commit
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
2d_spots_in_fibers.py
+37
-21
37 additions, 21 deletions
2d_spots_in_fibers.py
with
37 additions
and
21 deletions
2d_spots_in_fibers.py
+
37
−
21
View file @
e3e5ee76
#@ OpService ops
#@ CommandService command
#@ RoiManager rm
#@ File (label="select image", description="select your input image", style=file) path_to_image
#@ Integer (label="select image file series", description="leave 1 if not needed", value=1, min=1, max=20, stepSize=1, persist=false, style=slider) series_number
#@ File (label="Fiber Segmentation", description="select the Fiber Segmentation RoiSet .zip file", style=file) fiber_segmentation_roiset
...
...
@@ -19,6 +20,8 @@ from ij import IJ
from
ij.plugin
import
ImageCalculator
from
ij.plugin.frame
import
RoiManager
from
ij.measure
import
ResultsTable
from
ij.measure
import
Measurements
as
M
from
ij.plugin.filter
import
Analyzer
# Bio-Formats imports
from
loci.plugins
import
BF
from
loci.common
import
Region
...
...
@@ -332,37 +335,50 @@ def convert_labelimage_to_binary(label_imp, scale_binary=True):
return
binary_imp
# TODO: test simpler way using IJ roi measure
def
measure_intensity_sum
(
label_imp
,
target_imp
):
"""
Measure the sum intensity for each label in a label image on another target image.
Uses imglib2 and ops for this and works with both 2D and 3D label images
.
def
measure_intensity_sum
(
imp
,
rm
):
"""
Measure theraw integrated intensity for all rois in target imp
.
Parameters
----------
label_
imp : ImagePlus
the input label image
target_imp : ImagePlus
t
he
target image in which to measure
imp : ImagePlus
The image from which the intensity will be measured.
rm : RoiManager
T
he
ROI Manager containing the regions of interest to be analyzed.
Returns
-------
array
label id and corresponding sum intensity [label_id, sum_intensity]
label_id : list of str
A list of labels corresponding to each ROI.
sum_intensity : list of int
A list of summed integrated intensities for each ROI.
Notes
-----
The results are stored in a `ij.ResultsTable`,
from which the raw integrated density values are extracted.
Example
-------
>>>
labels
,
intensities
=
measure_intensity_sum
(
image
,
roi_manager
)
"""
rt_
=
ResultsTable
()
options
=
M
.
INTEGRATED_DENSITY
an
=
Analyzer
(
imp
,
options
,
rt_
)
an
.
setPrecision
(
0
)
label_id
=
[]
sum_intensity
=
[]
target_img
=
ImageJFunctions
.
wrap
(
target_imp
)
# convert ImagePlus to img to use ops/region measurements on it
regions
=
convert_labelimage_to_imglib2regions
(
label_imp
)
for
region
in
regions
:
label_id
.
append
(
region
.
getLabel
()
+
1
)
# region.getlabel() starts counting from 0. So the label with int 1 has the index 0.
input
=
Regions
.
sample
(
region
,
target_img
)
# returns an iterableInterval
sum
=
ops
.
stats
().
sum
(
input
).
getRealDouble
()
sum_intensity
.
append
(
sum
)
# other measurements see https://forum.image.sc/t/can-i-get-to-measurements-using-imagej-ops/4448/5
result
=
[
label_id
,
sum_intensity
]
for
index
,
roi
in
enumerate
(
rm
.
getRoisAsArray
()):
imp
.
setRoi
(
roi
)
an
.
measure
()
label_id
.
append
(
roi
.
getName
())
sum_intensity
.
append
(
int
(
rt_
.
getColumn
(
"
RawIntDen
"
)[
index
]))
return
result
return
label_id
,
sum_intensity
def
add_results_to_resultstable
(
results_table
,
column
,
values
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment