Skip to content

Commit 42ffb99

Browse files
authored
Optimisations to TIFF image stack creation in CLEM workflow (#314)
* Overhauled functions used for array manipulation during image stack creation * Added more parameters for more comprehensive metadata transfer during image stack creation
1 parent 6697f07 commit 42ffb99

File tree

7 files changed

+224
-145
lines changed

7 files changed

+224
-145
lines changed

src/murfey/cli/tiff_to_stack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def run():
3535
# Convert to correct object types
3636
tiff_file = Path(args.tiff_path)
3737
# Generate list from the single file provided
38-
tiff_list = [
38+
tiff_list: list[Path] = [
3939
f.resolve()
4040
for f in tiff_file.parent.glob("./*")
4141
if f.suffix in {".tif", ".tiff"}

src/murfey/server/clem/api.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
import importlib.metadata
3+
import sys
44

55
from fastapi import APIRouter
66

@@ -9,6 +9,12 @@
99
from murfey.util.clem.tiff import convert_tiff_to_stack
1010
from murfey.util.models import LifFileInfo, TiffSeriesInfo
1111

12+
# Use backport from importlib_metadata for Python <3.10
13+
if sys.version_info.major == 3 and sys.version_info.minor < 10:
14+
from importlib_metadata import entry_points
15+
else:
16+
from importlib.metadata import entry_points
17+
1218
# Create APIRouter class object
1319
router = APIRouter()
1420

@@ -18,16 +24,20 @@ def lif_to_tiff(
1824
session_id: int, # Used by the decorator
1925
lif_info: LifFileInfo,
2026
):
21-
murfey_workflows = importlib.metadata.entry_points().select(
27+
# Get command line entry point
28+
murfey_workflows = entry_points().select(
2229
group="murfey.workflows", name="lif_to_tiff"
2330
)
31+
32+
# Use entry point if found
2433
if murfey_workflows:
2534
murfey_workflows[0].load()(
2635
# Match the arguments found in murfey.workflows.lif_to_tiff
2736
file=lif_info.name,
2837
root_folder="images",
2938
messenger=_transport_object,
3039
)
40+
# Call function directly otherwise
3141
else:
3242
convert_lif_to_tiff(
3343
file=lif_info.name,
@@ -40,9 +50,12 @@ def tiff_to_stack(
4050
session_id: int, # Used by the decorator
4151
tiff_info: TiffSeriesInfo,
4252
):
43-
murfey_workflows = importlib.metadata.entry_points().select(
44-
group="murfey.workflows", name="tiff_to_stack"
53+
# Get command line entry point
54+
murfey_workflows = entry_points().select(
55+
group="murfey.workflows", name="lif_to_tiff"
4556
)
57+
58+
# Use entry point if found
4659
if murfey_workflows:
4760
murfey_workflows[0].load()(
4861
# Match the arguments found in murfey.workflows.tiff_to_stack
@@ -51,6 +64,7 @@ def tiff_to_stack(
5164
metadata=tiff_info.series_metadata,
5265
messenger=_transport_object,
5366
)
67+
# Call function directly otherwise
5468
else:
5569
convert_tiff_to_stack(
5670
tiff_list=tiff_info.tiff_files,

0 commit comments

Comments
 (0)