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
449e8420
Commit
449e8420
authored
1 month ago
by
Kai Schleicher
Browse files
Options
Downloads
Patches
Plain Diff
Add and use function to measure shape features
parent
5f9d8db0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
2d_spots_in_fibers.py
+60
-1
60 additions, 1 deletion
2d_spots_in_fibers.py
with
60 additions
and
1 deletion
2d_spots_in_fibers.py
+
60
−
1
View file @
449e8420
...
@@ -349,6 +349,59 @@ def measure_intensity_sum(imp, rm):
...
@@ -349,6 +349,59 @@ def measure_intensity_sum(imp, rm):
return
label_id
,
sum_intensity
return
label_id
,
sum_intensity
def
measure_shape_parameters
(
imp
,
rm
):
"""
Measure theraw integrated intensity for all rois in target imp.
Parameters
----------
imp : ImagePlus
The image from which the intensity will be measured.
rm : RoiManager
The ROI Manager containing the regions of interest to be analyzed.
Returns
-------
label_id : list of str
A list of labels corresponding to each ROI.
area : list of int
A list of the areas for each ROI.
perimeter : list of int
A list of the perimeters for each ROI.
min_feret : list of int
A list of the min feret diameters for each ROI.
Notes
-----
The results are stored in a `ij.ResultsTable`,
from which the values are extracted.
Example
-------
>>>
label_id
,
area
,
perimeter
,
min_feret
=
measure_shape_parameters
(
imp
,
roi_manager
)
"""
rt_
=
ResultsTable
()
options
=
M
.
FERET
|
M
.
AREA
|
M
.
PERIMETER
an
=
Analyzer
(
imp
,
options
,
rt_
)
an
.
setPrecision
(
1
)
label_id
=
[]
area
=
[]
perimeter
=
[]
min_feret
=
[]
for
index
,
roi
in
enumerate
(
rm
.
getRoisAsArray
()):
imp
.
setRoi
(
roi
)
an
.
measure
()
label_id
.
append
(
roi
.
getName
())
area
.
append
(
int
(
rt_
.
getColumn
(
"
Area
"
)[
index
]))
perimeter
.
append
(
int
(
rt_
.
getColumn
(
"
MinFeret
"
)[
index
]))
min_feret
.
append
(
int
(
rt_
.
getColumn
(
"
Perim.
"
)[
index
]))
return
label_id
,
area
,
perimeter
,
min_feret
def
add_results_to_resultstable
(
results_table
,
column
,
values
):
def
add_results_to_resultstable
(
results_table
,
column
,
values
):
"""
Add values to the ResultsTable starting from row 0 of a given column.
"""
Add values to the ResultsTable starting from row 0 of a given column.
...
@@ -451,6 +504,12 @@ dapi_binary = convert_to_binary(dapi_channel, threshold)
...
@@ -451,6 +504,12 @@ dapi_binary = convert_to_binary(dapi_channel, threshold)
# detect spots and count them per fiber
# detect spots and count them per fiber
results_table
=
ResultsTable
()
results_table
=
ResultsTable
()
load_rois_from_zip
(
fiber_segmentation_roiset
,
rm
)
fiber_label_IDs
,
area
,
perimeter
,
min_feret
=
measure_shape_parameters
(
dapi_binary
,
rm
)
add_results_to_resultstable
(
results_table
,
"
fiber label ID
"
,
fiber_label_IDs
)
add_results_to_resultstable
(
results_table
,
"
Area
"
,
area
)
add_results_to_resultstable
(
results_table
,
"
Perimeter
"
,
perimeter
)
add_results_to_resultstable
(
results_table
,
"
Min. Feret
"
,
min_feret
)
for
index
,
channel
in
enumerate
(
processing_channels
):
for
index
,
channel
in
enumerate
(
processing_channels
):
channel
=
int
(
channel
)
channel
=
int
(
channel
)
quality_threshold
=
float
(
quality_thresholds
[
index
])
quality_threshold
=
float
(
quality_thresholds
[
index
])
...
@@ -462,7 +521,7 @@ for index, channel in enumerate(processing_channels):
...
@@ -462,7 +521,7 @@ for index, channel in enumerate(processing_channels):
dapi_negative_spots_binary
=
ImageCalculator
.
run
(
spots_binary_imp
,
dapi_positive_spots_binary
,
"
Subtract create
"
)
dapi_negative_spots_binary
=
ImageCalculator
.
run
(
spots_binary_imp
,
dapi_positive_spots_binary
,
"
Subtract create
"
)
load_rois_from_zip
(
fiber_segmentation_roiset
,
rm
)
load_rois_from_zip
(
fiber_segmentation_roiset
,
rm
)
fiber_label_IDs
,
n_spots_per_fiber
=
measure_intensity_sum
(
spots_binary_imp
,
rm
)
_
,
n_spots_per_fiber
=
measure_intensity_sum
(
spots_binary_imp
,
rm
)
_
,
n_dapi_positive_spots_per_fiber
=
measure_intensity_sum
(
dapi_positive_spots_binary
,
rm
)
_
,
n_dapi_positive_spots_per_fiber
=
measure_intensity_sum
(
dapi_positive_spots_binary
,
rm
)
_
,
n_dapi_negative_spots_per_fiber
=
measure_intensity_sum
(
dapi_negative_spots_binary
,
rm
)
_
,
n_dapi_negative_spots_per_fiber
=
measure_intensity_sum
(
dapi_negative_spots_binary
,
rm
)
...
...
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