Skip to content

Commit 32abdc1

Browse files
Update gfp_annotation.py
1 parent 301e018 commit 32abdc1

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

scripts/intensity_annotation/gfp_annotation.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,21 @@ def _create_mask(sgns_extended, gfp):
132132
return mask
133133

134134

135-
def gfp_annotation(prefix, default_stat="median", background_norm=None):
135+
def gfp_annotation(prefix, default_stat="median", background_norm=None, is_otof=False):
136136
assert background_norm in (None, "division", "subtraction")
137137

138138
direc = os.path.dirname(os.path.abspath(prefix))
139139
basename = os.path.basename(prefix)
140140
file_names = [entry.name for entry in os.scandir(direc)]
141-
gfp_file = [name for name in file_names if basename in name and "GFP" in name][0]
142-
sgn_file = [name for name in file_names if basename in name and "SGN" in name][0]
143-
pv_file = [name for name in file_names if basename in name and "PV" in name][0]
141+
# Keeping the names "gfp", "sgn", and "pv" is a bit hacky, maybe we should change this to more geeric names.
142+
if is_otof: # OTOF cochlea with VGlut3, Alphatag and IHC segmentation.
143+
gfp_file = [name for name in file_names if basename in name and "GFP" in name][0]
144+
sgn_file = [name for name in file_names if basename in name and "IHC" in name][0]
145+
pv_file = [name for name in file_names if basename in name and "lut3" in name][0]
146+
else: # ChReef cochlea with PV, GFPand SGN segmentation
147+
gfp_file = [name for name in file_names if basename in name and "GFP" in name][0]
148+
sgn_file = [name for name in file_names if basename in name and "SGN" in name][0]
149+
pv_file = [name for name in file_names if basename in name and "PV" in name][0]
144150

145151
gfp = imageio.imread(os.path.join(direc, gfp_file))
146152
sgns = imageio.imread(os.path.join(direc, sgn_file))
@@ -254,12 +260,16 @@ def threshold_widget(viewer: napari.Viewer, threshold: float = (max_val - min_va
254260
# - M_LR_000145_L: rough alignment is ok, detailed alignment also ok.
255261
# - M_LR_000151_R: rough alignment is ok, detailed alignment also ok.
256262
def main():
257-
parser = argparse.ArgumentParser()
258-
parser.add_argument("prefix")
259-
parser.add_argument("-b", "--background_norm")
263+
parser = argparse.ArgumentParser(description="Start a GUI for determining an intensity threshold for positive / negative transduction in segmented cells.")
264+
parser.add_argument("prefix", help="The prefix of the files to open with the annotation tool.")
265+
parser.add_argument(
266+
"-b", "--background_norm", help="How to normalize the intensity values for background intensity."
267+
"Valid options are 'division' and 'subtraction'. If nothing is passed then the intensity values are not normalized."
268+
)
269+
parser.add_argument("--otof", action="store_true", help="Whether to run the annotation tool for otof samples with VGlut3, Alphatag and IHC segmentation.") # noqa
260270
args = parser.parse_args()
261271

262-
gfp_annotation(args.prefix, background_norm=args.background_norm)
272+
gfp_annotation(args.prefix, background_norm=args.background_norm, is_otof=args.otof)
263273

264274

265275
if __name__ == "__main__":

0 commit comments

Comments
 (0)