diff --git a/2d_spots_in_fibers.py b/2d_spots_in_fibers.py index 22b3a45e44b30e642e4050db67a9cdbffeadd179..acf308f5a5f9437d0f75266604dc2900682cc405 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)