From 2c6afe8e3b650fa6903587504ae828841bc3b99b Mon Sep 17 00:00:00 2001 From: schlda00 <kai.schleicher@unibas.ch> Date: Wed, 16 Apr 2025 13:32:55 +0200 Subject: [PATCH] Remove RoiManager import, get from script parameter instead. --- 2d_spots_in_fibers.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/2d_spots_in_fibers.py b/2d_spots_in_fibers.py index 22b3a45..acf308f 100644 --- a/2d_spots_in_fibers.py +++ b/2d_spots_in_fibers.py @@ -18,7 +18,6 @@ from fiji.plugin.trackmate.action import LabelImgExporter # ij imports from ij import IJ from ij.plugin import ImageCalculator -from ij.plugin.frame import RoiManager from ij.measure import ResultsTable from ij.measure import Measurements as M from ij.plugin.filter import Analyzer @@ -386,7 +385,7 @@ def save_results_table(results_table, filename, suffix, target): results_table.save(savepath) -def save_labelimage_as_ijroiset(label_imp, filename, suffix, target): +def save_labelimage_as_ijroiset(label_imp, rm, filename, suffix, target): """Save all labels i a label Images as IJ-ROIset to target location. Only 2D, requires PTBIOP update site. @@ -401,10 +400,6 @@ def save_labelimage_as_ijroiset(label_imp, filename, suffix, target): target : str the target directory in which to save the table """ - rm = RoiManager.getInstance() - if not rm: - rm = RoiManager() - rm.reset() command.run( Labels2Rois , False , 'imp' , label_imp , 'rm', rm).get() savename = filename + "_" + str(suffix) + ".zip" savepath = os.path.join(target, savename) @@ -412,19 +407,16 @@ def save_labelimage_as_ijroiset(label_imp, filename, suffix, target): rm.reset() -def load_rois_from_zip(path): +def load_rois_from_zip(path, rm): """Load ROIs from the given zip file and add them to the RoiManager. Parameters ---------- path : string Path to the ROI zip file. + rm : RoiManager + The ROI Manager. """ - rm = RoiManager.getInstance() - if not rm: - rm = RoiManager() - rm.reset() - rm.runCommand("Open", path) -- GitLab