diff --git a/2d_spots_in_fibers.py b/2d_spots_in_fibers.py index 3757c8e19cf1daad0f47a44e30e94fba71558b2e..a5b54fe966a0f18477e4af7b18772ea1123e512b 100644 --- a/2d_spots_in_fibers.py +++ b/2d_spots_in_fibers.py @@ -36,7 +36,7 @@ from net.imglib2.roi import Regions from net.imglib2.roi.labeling import LabelRegions from net.imglib2.algorithm.labeling import ConnectedComponents # BIOP imports -from ch.epfl.biop.ij2command import Labels2Rois +from ch.epfl.biop.ij2command import Labels2Rois, Rois2Labels # python imports import os @@ -707,6 +707,33 @@ def save_labelimage_as_ijroiset(label_imp, filename, suffix, target): rm.reset() +def load_rois_from_zip(path): + """Load ROIs from the given zip file and add them to the RoiManager. + + Parameters + ---------- + path : string + Path to the ROI zip file. + """ + rm = RoiManager.getInstance() + if not rm: + rm = RoiManager() + rm.reset() + + rm.runCommand("Open", path) + + +def convert_rois_to_labelimage(imp): + rm = RoiManager.getInstance() + if not rm: + rm = RoiManager() + + label_imp = command.run( Rois2Labels , False , 'imp' , imp , 'rm', rm).get().getOutput("label_imp") + rm.reset() # TODO: should be optional but can be default + + return label_imp + + def close_images(list_of_imps): """Close given ImagePlus images