Skip to content
Snippets Groups Projects
Commit e3e5ee76 authored by Kai Schleicher's avatar Kai Schleicher
Browse files

Remove unused function and imports

parent fa02df72
No related branches found
No related tags found
1 merge request!2Initial commit
#@ 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
the target image in which to measure
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
-------
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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment