Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
86a3447
Add method for associating label images using 3DImageJSuite
lguerard Mar 11, 2025
97084b6
Fix the filtering of objects to use the calibrated method
lguerard Mar 11, 2025
408131c
Use the morpholibj package to 2D dilate labels
lguerard Mar 11, 2025
c542b19
Format imports
lguerard Mar 11, 2025
886613a
Add method to write results to CSV
lguerard Mar 11, 2025
831d771
Add methods for 3D Maxima Finder and 3D Watershed
lguerard Mar 11, 2025
4dc4504
Add processing library to do basic methods
lguerard Mar 11, 2025
6fa4d69
Add methods to get different metadata using bioformats
lguerard Mar 13, 2025
0bdd98e
Update method to support NaN (discarding them) and rounding results
lguerard Mar 13, 2025
34d5880
Add method to save in different file format
lguerard Mar 13, 2025
15bc0c4
Add method to pad a string
lguerard Mar 13, 2025
6189088
Add methods to find imaris and convert an image to IMS
lguerard Mar 13, 2025
272df1f
Add missing imports and formatting
lguerard Mar 13, 2025
c1a9332
Add methods to get different metadata from OMERO
lguerard Mar 13, 2025
05e6a2e
Add method to delete annotation from OMERO
lguerard Mar 13, 2025
fae0930
Add methods to save an OMERO.table
lguerard Mar 13, 2025
de5c84a
Add method to save IJ-ROIs to OMERO
lguerard Mar 13, 2025
16dd961
Add missing imports and formatting
lguerard Mar 13, 2025
04a9f84
Formatting
lguerard Mar 13, 2025
8a041de
Use `imp` instead of `imageplus`
lguerard Mar 19, 2025
309360f
Improve method name and docstring
lguerard Mar 19, 2025
170ac0c
Improve method name and docstring
lguerard Mar 19, 2025
cca38ba
Add missing import
lguerard Mar 19, 2025
e858900
Change method to use the one added to pathtools
lguerard Mar 19, 2025
b42cec3
Formatting
lguerard Mar 19, 2025
184a943
Update the formatting
lguerard Mar 19, 2025
f072877
Merge branch 'devel' into coding-session/2025-03-11
ehrenfeu Mar 19, 2025
54ee5f9
Format docstring's Returns `dict`
ehrenfeu Mar 19, 2025
88ee3a8
Add back `create_directory` with better docstring
lguerard Mar 19, 2025
7466838
Fix linting
lguerard Mar 19, 2025
5bea0ad
Formatting
lguerard Mar 19, 2025
0e81c37
Fix linting issues
lguerard Mar 19, 2025
1b222d0
Update docstring of write_ordereddict_to_csv()
ehrenfeu Mar 19, 2025
f9375c5
Rework docstring
ehrenfeu Mar 19, 2025
e99dcdb
Update docstring of locate_latest_imaris()
ehrenfeu Mar 19, 2025
d2a4991
Improve docstring
ehrenfeu Mar 19, 2025
6eb32db
Improve docstring
ehrenfeu Mar 19, 2025
bfbe585
Shorten docstring
ehrenfeu Mar 19, 2025
18131a8
Update dependency for mocks to 0.8.0.a0
ehrenfeu Mar 20, 2025
b3110ec
Merge branch 'devel' into coding-session/2025-03-11
ehrenfeu Mar 20, 2025
b520c28
Revert "Fix linting issues"
lguerard Mar 24, 2025
2b6a8d8
Revert "Formatting"
lguerard Mar 24, 2025
82b8683
Revert "Fix linting"
lguerard Mar 24, 2025
ebb1413
Rename functions
lguerard Mar 24, 2025
b59b597
Change returns to use dictionaries instead
lguerard Mar 24, 2025
98b9ca8
Change input variable name
lguerard Mar 24, 2025
14d2efc
Use logging instead
lguerard Mar 24, 2025
0045e65
Format using Ruff
lguerard Mar 24, 2025
0ff3433
Add comments and notes to docstring, fix missing inputs
lguerard Mar 24, 2025
74ffe42
Change output to inform if command has failed
lguerard Mar 24, 2025
a094dc9
Change method to return faster in case of empty list
lguerard Mar 24, 2025
25ee6ed
Add module docstring for ImageJ processing utilities
lguerard Mar 24, 2025
00dc641
Move minor implementation detail into code comment
ehrenfeu Mar 25, 2025
51248a4
Docstring cleanups
ehrenfeu Mar 25, 2025
d81e682
Shorten docstring example
ehrenfeu Mar 25, 2025
6b641bb
Indent to show as a fixed-width block
ehrenfeu Mar 25, 2025
51f2cec
One example should be enough
ehrenfeu Mar 25, 2025
a65fe41
Add empty line to fix docstring rendering
ehrenfeu Mar 25, 2025
c35e312
Run black formatting (restore default line length of 88)
ehrenfeu Mar 25, 2025
caa1370
Notes section comes before Examples
ehrenfeu Mar 25, 2025
99ab0f0
Minor updates on Notes section
ehrenfeu Mar 25, 2025
07f3064
Update function details
ehrenfeu Mar 25, 2025
4333086
Place Notes section after Returns
ehrenfeu Mar 25, 2025
ec158ff
Docstring conventions
ehrenfeu Mar 25, 2025
047d913
Docstring conventions
ehrenfeu Mar 25, 2025
98cfaff
Reformat dict in Returns section
ehrenfeu Mar 25, 2025
f0a1c9c
Merge branch 'devel' into pr/laurent/coding-session/2025-03-11
ehrenfeu Mar 25, 2025
8cef7bf
Merge branch 'devel' into pr/laurent/coding-session/2025-03-11
ehrenfeu Mar 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 240 additions & 0 deletions src/imcflibs/imagej/bioformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,243 @@
reader = Memoizer(ImageReader())
reader.setId(path_to_file)
reader.close()


def get_metadata_from_file(path_to_image):
"""Extract metadata from an image file using Bio-Formats.

This function reads an image file using the Bio-Formats library and extracts
various metadata properties including physical dimensions, pixel dimensions,
and other image characteristics.

Parameters
----------
path_to_image : str or pathlib.Path
Path to the image file from which metadata should be extracted.

Returns
-------
dict
A dictionary containing the following metadata:

{
unit_width : float, # physical width of a pixel
unit_height : float, # physical height of a pixel
unit_depth : float, # physical depth of a voxel
pixel_width : int, # width of the image in pixels
pixel_height : int, # height of the image in pixels
slice_count : int, # number of Z-slices
channel_count : int, # number of channels
timepoints_count : int, # number of timepoints
dimension_order : str, # order of dimensions, e.g. "XYZCT"
pixel_type : str, # data type of the pixel values
}
"""
reader = ImageReader()
ome_meta = MetadataTools.createOMEXMLMetadata()
reader.setMetadataStore(ome_meta)
reader.setId(str(path_to_image))

Check warning on line 327 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L324-L327

Added lines #L324 - L327 were not covered by tests

phys_size_x = ome_meta.getPixelsPhysicalSizeX(0)
phys_size_y = ome_meta.getPixelsPhysicalSizeY(0)
phys_size_z = ome_meta.getPixelsPhysicalSizeZ(0)
pixel_size_x = ome_meta.getPixelsSizeX(0)
pixel_size_y = ome_meta.getPixelsSizeY(0)
pixel_size_z = ome_meta.getPixelsSizeZ(0)
channel_count = ome_meta.getPixelsSizeC(0)
timepoints_count = ome_meta.getPixelsSizeT(0)
dimension_order = ome_meta.getPixelsDimensionOrder(0)
pixel_type = ome_meta.getPixelsType(0)

Check warning on line 338 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L329-L338

Added lines #L329 - L338 were not covered by tests

image_calibration = {

Check warning on line 340 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L340

Added line #L340 was not covered by tests
"unit_width": phys_size_x.value(),
"unit_height": phys_size_y.value(),
"unit_depth": phys_size_z.value(),
"pixel_width": pixel_size_x.getNumberValue(),
"pixel_height": pixel_size_y.getNumberValue(),
"slice_count": pixel_size_z.getNumberValue(),
"channel_count": channel_count.getNumberValue(),
"timepoints_count": timepoints_count.getNumberValue(),
"dimension_order": dimension_order,
"pixel_type": pixel_type,
}

reader.close()

Check warning on line 353 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L353

Added line #L353 was not covered by tests

return image_calibration

Check warning on line 355 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L355

Added line #L355 was not covered by tests


def get_stage_coords(source, filenames):
"""Get stage coordinates and calibration for a given list of images.

Parameters
----------
source : str
Path to the images.
filenames : list of str
List of images filenames.

Returns
-------
dict

{
dimensions : int, # number of dimensions (2D or 3D)
stage_coordinates_x : list, # absolute stage x-coordinated
stage_coordinates_y : list, # absolute stage y-coordinated
stage_coordinates_z : list, # absolute stage z-coordinated
relative_coordinates_x : list, # relative stage x-coordinates in px
relative_coordinates_y : list, # relative stage y-coordinates in px
relative_coordinates_z : list, # relative stage z-coordinates in px
image_calibration : list, # x,y,z image calibration in unit/px
calibration_unit : str, # image calibration unit
image_dimensions_czt : list, # number of images in dimensions c,z,t
series_names : list of str, # names of all series in the files
max_size : list of int, # max size (x/y/z) across all files
}
"""

# open an array to store the abosolute stage coordinates from metadata
stage_coordinates_x = []
stage_coordinates_y = []
stage_coordinates_z = []
series_names = []

Check warning on line 392 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L389-L392

Added lines #L389 - L392 were not covered by tests

for counter, image in enumerate(filenames):

Check warning on line 394 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L394

Added line #L394 was not covered by tests
# parse metadata
reader = ImageReader()
reader.setFlattenedResolutions(False)
omeMeta = MetadataTools.createOMEXMLMetadata()
reader.setMetadataStore(omeMeta)
reader.setId(source + str(image))
series_count = reader.getSeriesCount()

Check warning on line 401 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L396-L401

Added lines #L396 - L401 were not covered by tests

# get hyperstack dimensions from the first image
if counter == 0:
frame_size_x = reader.getSizeX()
frame_size_y = reader.getSizeY()
frame_size_z = reader.getSizeZ()
frame_size_c = reader.getSizeC()
frame_size_t = reader.getSizeT()

Check warning on line 409 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L404-L409

Added lines #L404 - L409 were not covered by tests

# note the dimensions
if frame_size_z == 1:
dimensions = 2
if frame_size_z > 1:
dimensions = 3

Check warning on line 415 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L412-L415

Added lines #L412 - L415 were not covered by tests

# get the physical calibration for the first image series
physSizeX = omeMeta.getPixelsPhysicalSizeX(0)
physSizeY = omeMeta.getPixelsPhysicalSizeY(0)
physSizeZ = omeMeta.getPixelsPhysicalSizeZ(0)

Check warning on line 420 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L418-L420

Added lines #L418 - L420 were not covered by tests

# workaround to get the z-interval if physSizeZ.value() returns None.
z_interval = 1
if physSizeZ is not None:
z_interval = physSizeZ.value()

Check warning on line 425 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L423-L425

Added lines #L423 - L425 were not covered by tests

if frame_size_z > 1 and physSizeZ is None:
log.debug("no z calibration found, trying to recover")
first_plane = omeMeta.getPlanePositionZ(0, 0)
next_plane_imagenumber = frame_size_c + frame_size_t - 1
second_plane = omeMeta.getPlanePositionZ(0, next_plane_imagenumber)
z_interval = abs(abs(first_plane.value()) - abs(second_plane.value()))
log.debug("z-interval seems to be: " + str(z_interval))

Check warning on line 433 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L427-L433

Added lines #L427 - L433 were not covered by tests

# create an image calibration
image_calibration = [

Check warning on line 436 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L436

Added line #L436 was not covered by tests
physSizeX.value(),
physSizeY.value(),
z_interval,
]
calibration_unit = physSizeX.unit().getSymbol()
image_dimensions_czt = [

Check warning on line 442 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L441-L442

Added lines #L441 - L442 were not covered by tests
frame_size_c,
frame_size_z,
frame_size_t,
]

reader.close()

Check warning on line 448 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L448

Added line #L448 was not covered by tests

for series in range(series_count):
if omeMeta.getImageName(series) == "macro image":
continue

Check warning on line 452 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L450-L452

Added lines #L450 - L452 were not covered by tests

if series_count > 1 and not str(image).endswith(".vsi"):
series_names.append(omeMeta.getImageName(series))

Check warning on line 455 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L454-L455

Added lines #L454 - L455 were not covered by tests
else:
series_names.append(str(image))

Check warning on line 457 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L457

Added line #L457 was not covered by tests
# get the plane position in calibrated units
current_position_x = omeMeta.getPlanePositionX(series, 0)
current_position_y = omeMeta.getPlanePositionY(series, 0)
current_position_z = omeMeta.getPlanePositionZ(series, 0)

Check warning on line 461 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L459-L461

Added lines #L459 - L461 were not covered by tests

physSizeX_max = (

Check warning on line 463 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L463

Added line #L463 was not covered by tests
physSizeX.value()
if physSizeX.value() >= omeMeta.getPixelsPhysicalSizeX(series).value()
else omeMeta.getPixelsPhysicalSizeX(series).value()
)
physSizeY_max = (

Check warning on line 468 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L468

Added line #L468 was not covered by tests
physSizeY.value()
if physSizeY.value() >= omeMeta.getPixelsPhysicalSizeY(series).value()
else omeMeta.getPixelsPhysicalSizeY(series).value()
)
if omeMeta.getPixelsPhysicalSizeZ(series):
physSizeZ_max = (

Check warning on line 474 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L473-L474

Added lines #L473 - L474 were not covered by tests
physSizeZ.value()
if physSizeZ.value()
>= omeMeta.getPixelsPhysicalSizeZ(series).value()
else omeMeta.getPixelsPhysicalSizeZ(series).value()
)

else:
physSizeZ_max = 1.0

Check warning on line 482 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L482

Added line #L482 was not covered by tests

# get the absolute stage positions and store them
pos_x = current_position_x.value()
pos_y = current_position_y.value()

Check warning on line 486 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L485-L486

Added lines #L485 - L486 were not covered by tests

if current_position_z is None:
log.debug("the z-position is missing in the ome-xml metadata.")
pos_z = 1.0

Check warning on line 490 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L488-L490

Added lines #L488 - L490 were not covered by tests
else:
pos_z = current_position_z.value()

Check warning on line 492 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L492

Added line #L492 was not covered by tests

stage_coordinates_x.append(pos_x)
stage_coordinates_y.append(pos_y)
stage_coordinates_z.append(pos_z)

Check warning on line 496 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L494-L496

Added lines #L494 - L496 were not covered by tests

max_size = [physSizeX_max, physSizeY_max, physSizeZ_max]

Check warning on line 498 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L498

Added line #L498 was not covered by tests

# calculate the store the relative stage movements in px (for the grid/collection stitcher)
relative_coordinates_x_px = []
relative_coordinates_y_px = []
relative_coordinates_z_px = []

Check warning on line 503 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L501-L503

Added lines #L501 - L503 were not covered by tests

for i in range(len(stage_coordinates_x)):
rel_pos_x = (

Check warning on line 506 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L505-L506

Added lines #L505 - L506 were not covered by tests
stage_coordinates_x[i] - stage_coordinates_x[0]
) / physSizeX.value()
rel_pos_y = (

Check warning on line 509 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L509

Added line #L509 was not covered by tests
stage_coordinates_y[i] - stage_coordinates_y[0]
) / physSizeY.value()
rel_pos_z = (stage_coordinates_z[i] - stage_coordinates_z[0]) / z_interval

Check warning on line 512 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L512

Added line #L512 was not covered by tests

relative_coordinates_x_px.append(rel_pos_x)
relative_coordinates_y_px.append(rel_pos_y)
relative_coordinates_z_px.append(rel_pos_z)

Check warning on line 516 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L514-L516

Added lines #L514 - L516 were not covered by tests

return {

Check warning on line 518 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L518

Added line #L518 was not covered by tests
"dimensions": dimensions,
"stage_coordinates_x": stage_coordinates_x,
"stage_coordinates_y": stage_coordinates_y,
"stage_coordinates_z": stage_coordinates_z,
"relative_coordinates_x": relative_coordinates_x_px,
"relative_coordinates_y": relative_coordinates_y_px,
"relative_coordinates_z": relative_coordinates_z_px,
"image_calibration": image_calibration,
"calibration_unit": calibration_unit,
"image_dimensions_czt": image_dimensions_czt,
"series_names": series_names,
"max_size": max_size,
}
71 changes: 56 additions & 15 deletions src/imcflibs/imagej/labelimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Functions to work with ImageJ label images."""

from ij import IJ, ImagePlus, Prefs, ImageStack
from ij import IJ, ImagePlus, ImageStack, Prefs

Check warning on line 5 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L5

Added line #L5 was not covered by tests
from ij.plugin import Duplicator, ImageCalculator
from ij.plugin.filter import ThresholdToSelection
from ij.process import FloatProcessor, ImageProcessor
Expand Down Expand Up @@ -67,7 +67,7 @@
return roi_list, max_value


def relate_label_images(label_image_ref, label_image_to_relate):
def cookie_cut_labels(label_image_ref, label_image_to_relate):

Check warning on line 70 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L70

Added line #L70 was not covered by tests
"""Relate label images, giving the same label to objects belonging together.

❗ NOTE: Won't work with touching labels ❗
Expand Down Expand Up @@ -97,6 +97,57 @@
return ImageCalculator.run(label_image_ref, imp_dup, "Multiply create")


def relate_label_images(outer_label_imp, inner_label_imp):

Check warning on line 100 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L100

Added line #L100 was not covered by tests
"""Relate label images, giving the same label to objects belonging together.

Given two label images, this function will create a new label image with the
same labels as the reference image, but with the objects of the second image
using the 3D Association plugin from the 3DImageJSuite.

Parameters
----------
outer_label_imp : ij.ImagePlus
The outer label image.
inner_label_imp : ij.ImagePlus
The inner label image.

Returns
-------
related_inner_imp : ij.ImagePlus
The related inner label image.

Notes
-----
Unlike `cookie_cut_labels`, this should work with touching labels by using
MereoTopology algorithms.
"""

outer_label_imp.show()
inner_label_imp.show()

Check warning on line 126 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L125-L126

Added lines #L125 - L126 were not covered by tests

outer_title = outer_label_imp.getTitle()
inner_title = inner_label_imp.getTitle()

Check warning on line 129 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L128-L129

Added lines #L128 - L129 were not covered by tests

IJ.run(

Check warning on line 131 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L131

Added line #L131 was not covered by tests
"3D Association",
"image_a="
+ outer_title
+ " "
+ "image_b="
+ inner_title
+ " "
+ "method=Colocalisation min=1 max=0.000",
)

related_inner_imp = IJ.getImage()

Check warning on line 142 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L142

Added line #L142 was not covered by tests

outer_label_imp.hide()
inner_label_imp.hide()
related_inner_imp.hide()

Check warning on line 146 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L144-L146

Added lines #L144 - L146 were not covered by tests

return related_inner_imp

Check warning on line 148 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L148

Added line #L148 was not covered by tests


def filter_objects(label_image, table, string, min_val, max_val):
"""Filter labels based on specific min and max values.

Expand Down Expand Up @@ -182,11 +233,11 @@

# Set the minimum size for labeling if provided
if min_vol:
labeler.setMinSize(min_vol)
labeler.setMinSizeCalibrated(min_vol)

Check warning on line 236 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L236

Added line #L236 was not covered by tests

# Set the maximum size for labeling if provided
if max_vol:
labeler.setMaxSize(max_vol)
labeler.setMinSizeCalibrated(max_vol)

Check warning on line 240 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L240

Added line #L240 was not covered by tests

# Get the labeled image
seg = labeler.getLabels(img)
Expand Down Expand Up @@ -229,17 +280,7 @@
current_imp = Duplicator().run(imp, 1, 1, i, imp.getNSlices(), 1, 1)

# Perform a dilation of the labels in the current slice
IJ.run(
current_imp,
"Label Morphological Filters",
"operation=Dilation radius=" + str(dilation_radius) + " from_any_label",
)

# Get the dilated labels
dilated_labels_imp = IJ.getImage()

# Hide the dilated labels to avoid visual clutter
dilated_labels_imp.hide()
dilated_labels_imp = li.dilateLabels(current_imp, dilation_radius)

Check warning on line 283 in src/imcflibs/imagej/labelimage.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/labelimage.py#L283

Added line #L283 was not covered by tests

# Append the dilated labels to the list
dilated_labels_list.append(dilated_labels_imp)
Expand Down
Loading
Loading