Skip to content

Commit 7ca1652

Browse files
authored
Merge branch 'devel' into fix/129_bdv_variable_type_mixup
2 parents d02ebcf + d1d579f commit 7ca1652

11 files changed

Lines changed: 240 additions & 91 deletions

File tree

.vscode/settings.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@
1111
}
1212
},
1313
"cSpell.words": [
14-
"Prefs"
14+
"acitt",
15+
"bdvp",
16+
"biop",
17+
"imageplus",
18+
"imglib",
19+
"interestpoint",
20+
"intermodes",
21+
"Kheops",
22+
"micrometa",
23+
"multiresolution",
24+
"otsu",
25+
"pathtools",
26+
"Prefs",
27+
"PTBIOP",
28+
"PYENV",
29+
"pylint",
30+
"ransac",
31+
"renyi",
32+
"repartitions",
33+
"RETVAL",
34+
"scijava",
35+
"shanbhag",
36+
"sjlogging",
37+
"spimdata",
38+
"strtools",
39+
"subfolders",
40+
"subsampling",
41+
"trackmate",
42+
"virtualenv",
43+
"virtualfish"
1544
],
1645
}

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.lock.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ version = "0.0.0"
2020
# - or: python = ">=3.10"
2121

2222
[tool.poetry.dependencies]
23-
imcf-fiji-mocks = ">=0.10.0"
23+
imcf-fiji-mocks = ">=0.13.0"
2424
python = ">=2.7"
2525
python-micrometa = "^15.2.2"
2626
sjlogging = ">=0.5.2"

src/imcflibs/imagej/bdv.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ def phase_correlation_pairwise_shifts_calculation(
10801080
project_path : str
10811081
Full path to the `.xml` file.
10821082
processing_opts : imcflibs.imagej.bdv.ProcessingOptions, optional
1083-
The `ProcessingOptinos` object defining parameters for the run. Will
1083+
The `ProcessingOptions` object defining parameters for the run. Will
10841084
fall back to the defaults defined in the corresponding class if the
10851085
parameter is `None` or skipped.
10861086
downsampling_xyz : list of int, optional
@@ -1199,7 +1199,7 @@ def optimize_and_apply_shifts(
11991199
project_path : str
12001200
Path to the `.xml` on which to optimize and apply the shifts.
12011201
processing_opts : imcflibs.imagej.bdv.ProcessingOptions, optional
1202-
The `ProcessingOptinos` object defining parameters for the run. Will
1202+
The `ProcessingOptions` object defining parameters for the run. Will
12031203
fall back to the defaults defined in the corresponding class if the
12041204
parameter is `None` or skipped.
12051205
relative_error : float, optional
@@ -1350,11 +1350,13 @@ def interest_points_registration(
13501350
+ "transformation=Affine "
13511351
+ "regularize_model "
13521352
+ "model_to_regularize_with=Affine "
1353-
+ "lamba=0.10 "
1353+
+ "lambda=0.10 "
13541354
+ "number_of_neighbors=3 "
13551355
+ "redundancy=1 "
13561356
+ "significance=3 "
1357+
+ "search_radius=100 "
13571358
+ "allowed_error_for_ransac=5 "
1359+
+ "inlier_factor=3 "
13581360
+ "ransac_iterations=Normal "
13591361
+ "global_optimization_strategy=["
13601362
+ "Two-Round: Handle unconnected tiles, "
@@ -1389,7 +1391,7 @@ def duplicate_transformations(
13891391
Transformation mode, one of `channel` (to propagate from one channel to
13901392
all others) and `tiles` (to propagate from one tile to all others).
13911393
channel_source : int, optional
1392-
Reference channel nummber (starting at 1), by default None.
1394+
Reference channel number (starting at 1), by default None.
13931395
tile_source : int, optional
13941396
Reference tile, by default None.
13951397
transformation_to_use : str, optional
@@ -1405,8 +1407,8 @@ def duplicate_transformations(
14051407
tile_apply = ""
14061408
tile_process = ""
14071409

1408-
chnl_apply = ""
1409-
chnl_process = ""
1410+
ch_apply = ""
1411+
ch_process = ""
14101412

14111413
if transformation_type == "channel":
14121414
apply = "[One channel to other channels]"
@@ -1430,7 +1432,7 @@ def duplicate_transformations(
14301432
"processing_channel=[channel " + str(channel_source - 1) + "] "
14311433
)
14321434
else:
1433-
chnl_apply = "apply_to_channel=[All channels] "
1435+
ch_apply = "apply_to_channel=[All channels] "
14341436
else:
14351437
raise ValueError("Invalid transformation type: %s" % transformation_type)
14361438

@@ -1445,8 +1447,8 @@ def duplicate_transformations(
14451447
+ "apply_to_illumination=[All illuminations] "
14461448
+ tile_apply
14471449
+ tile_process
1448-
+ chnl_apply
1449-
+ chnl_process
1450+
+ ch_apply
1451+
+ ch_process
14501452
+ "apply_to_timepoint=[All Timepoints] "
14511453
+ "source="
14521454
+ source
@@ -1491,7 +1493,7 @@ def fuse_dataset(
14911493
project_path : str
14921494
Path to the `.xml` on which to run the fusion.
14931495
processing_opts : imcflibs.imagej.bdv.ProcessingOptions, optional
1494-
The `ProcessingOptinos` object defining parameters for the run. Will
1496+
The `ProcessingOptions` object defining parameters for the run. Will
14951497
fall back to the defaults defined in the corresponding class if the
14961498
parameter is `None` or skipped.
14971499
result_path : str, optional

src/imcflibs/imagej/bioformats.py

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,31 @@ def export_using_orig_name(imp, path, orig_name, tag, suffix, overwrite=False):
352352
return out_file
353353

354354

355+
def get_reader(path_to_file, setFlattenedResolutions=False):
356+
"""Get a Bio-Formats ImageReader for the specified file.
357+
358+
Parameters
359+
----------
360+
path_to_file : str
361+
The full path to the image file.
362+
setFlattenedResolutions : bool, optional
363+
Whether to flatten resolutions in the ImageReader (default: False).
364+
365+
Returns
366+
-------
367+
ImageReader
368+
A configured ImageReader instance for the specified file.
369+
"""
370+
reader = ImageReader()
371+
ome_meta = MetadataTools.createOMEXMLMetadata()
372+
reader.setMetadataStore(ome_meta)
373+
m = DynamicMetadataOptions()
374+
m.setBoolean(ZeissCZIReader.ALLOW_AUTOSTITCHING_KEY, False)
375+
reader.setMetadataOptions(m)
376+
reader.setId(str(path_to_file))
377+
return reader, ome_meta
378+
379+
355380
def get_series_info_from_ome_metadata(path_to_file, skip_labels=False):
356381
"""Get the Bio-Formats series information from a file on disk.
357382
@@ -378,44 +403,31 @@ def get_series_info_from_ome_metadata(path_to_file, skip_labels=False):
378403
>>> count, indices = get_series_info_from_ome_metadata("image.nd2", skip_labels=True)
379404
"""
380405

406+
reader, ome_meta = get_reader(path_to_file, skip_labels)
407+
series_count = reader.getSeriesCount()
381408
if not skip_labels:
382-
reader = ImageReader()
383-
reader.setFlattenedResolutions(False)
384-
ome_meta = MetadataTools.createOMEXMLMetadata()
385-
reader.setMetadataStore(ome_meta)
386-
reader.setId(path_to_file)
387-
series_count = reader.getSeriesCount()
388-
389-
reader.close()
409+
# If we are not skipping labels, return the full range
390410
return series_count, range(series_count)
391411

392-
else:
393-
reader = ImageReader()
394-
# reader.setFlattenedResolutions(True)
395-
ome_meta = MetadataTools.createOMEXMLMetadata()
396-
reader.setMetadataStore(ome_meta)
397-
reader.setId(path_to_file)
398-
series_count = reader.getSeriesCount()
399-
400-
series_ids = []
401-
series_names = []
402-
x = 0
403-
y = 0
404-
for i in range(series_count):
405-
reader.setSeries(i)
412+
series_ids = []
413+
series_names = []
414+
x = 0
415+
y = 0
416+
for i in range(series_count):
417+
reader.setSeries(i)
406418

407-
if reader.getSizeX() > x and reader.getSizeY() > y:
408-
name = ome_meta.getImageName(i)
419+
if reader.getSizeX() > x and reader.getSizeY() > y:
420+
name = ome_meta.getImageName(i)
409421

410-
if name not in ["label image", "macro image"]:
411-
series_ids.append(i)
412-
series_names.append(name)
422+
if name not in ["label image", "macro image"]:
423+
series_ids.append(i)
424+
series_names.append(name)
413425

414-
x = reader.getSizeX()
415-
y = reader.getSizeY()
426+
x = reader.getSizeX()
427+
y = reader.getSizeY()
416428

417-
print(series_names)
418-
return len(series_ids), series_ids
429+
print(series_names)
430+
return len(series_ids), series_ids
419431

420432

421433
def write_bf_memoryfile(path_to_file):
@@ -452,10 +464,7 @@ def get_metadata_from_file(path_to_image):
452464
An instance of `imcflibs.imagej.bioformats.ImageMetadata` containing the extracted metadata.
453465
"""
454466

455-
reader = ImageReader()
456-
ome_meta = MetadataTools.createOMEXMLMetadata()
457-
reader.setMetadataStore(ome_meta)
458-
reader.setId(str(path_to_image))
467+
reader, ome_meta = get_reader(path_to_image)
459468

460469
metadata = ImageMetadata(
461470
unit_width=ome_meta.getPixelsPhysicalSizeX(0).value(),
@@ -507,11 +516,7 @@ def get_stage_coords(filenames):
507516
max_phys_size_z = 0.0
508517

509518
for counter, image in enumerate(filenames):
510-
reader = ImageReader()
511-
reader.setFlattenedResolutions(False)
512-
ome_meta = MetadataTools.createOMEXMLMetadata()
513-
reader.setMetadataStore(ome_meta)
514-
reader.setId(str(image))
519+
reader, ome_meta = get_reader(image)
515520
series_count = reader.getSeriesCount()
516521

517522
# Process only the first image to get values not dependent on series
@@ -569,8 +574,7 @@ def get_stage_coords(filenames):
569574
if series_count > 1 and not str(image).endswith(".vsi"):
570575
series_names.append(ome_meta.getImageName(series))
571576
else:
572-
series_names.append(str(image))
573-
577+
series_names.append(os.path.basename(str(image)))
574578
current_position_x = getattr(
575579
ome_meta.getPlanePositionX(series, 0), "value", lambda: 0
576580
)()

0 commit comments

Comments
 (0)