Skip to content

Commit 2a3160b

Browse files
committed
Improved name flexibility
1 parent 1013dc0 commit 2a3160b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

scripts/intensity_annotation/gfp_annotation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import os
23

34
import imageio.v3 as imageio
45
import napari
@@ -134,9 +135,16 @@ def _create_mask(sgns_extended, gfp):
134135
def gfp_annotation(prefix, default_stat="median", background_norm=None):
135136
assert background_norm in (None, "division", "subtraction")
136137

137-
gfp = imageio.imread(f"{prefix}_GFP_resized.tif")
138-
sgns = imageio.imread(f"{prefix}_SGN_resized_v2.tif")
139-
pv = imageio.imread(f"{prefix}_PV_resized.tif")
138+
direc = os.path.dirname(os.path.abspath(prefix))
139+
basename = os.path.basename(prefix)
140+
file_names = [entry.name for entry in os.scandir(direc)]
141+
gfp_file = [name for name in file_names if basename and "GFP" in name][0]
142+
sgn_file = [name for name in file_names if basename and "SGN" in name][0]
143+
pv_file = [name for name in file_names if basename and "PV" in name][0]
144+
145+
gfp = imageio.imread(os.path.join(direc, gfp_file))
146+
sgns = imageio.imread(os.path.join(direc, sgn_file))
147+
pv = imageio.imread(os.path.join(direc, pv_file))
140148

141149
# bb = np.s_[128:-128, 128:-128, 128:-128]
142150
# gfp, sgns, pv = gfp[bb], sgns[bb], pv[bb]

0 commit comments

Comments
 (0)