Skip to content
Snippets Groups Projects
Commit d8310623 authored by Kai Schleicher's avatar Kai Schleicher
Browse files

Add function to convert ijrois to labelimage

parent c32ebcbe
No related branches found
No related tags found
1 merge request!2Initial commit
...@@ -36,7 +36,7 @@ from net.imglib2.roi import Regions ...@@ -36,7 +36,7 @@ from net.imglib2.roi import Regions
from net.imglib2.roi.labeling import LabelRegions from net.imglib2.roi.labeling import LabelRegions
from net.imglib2.algorithm.labeling import ConnectedComponents from net.imglib2.algorithm.labeling import ConnectedComponents
# BIOP imports # BIOP imports
from ch.epfl.biop.ij2command import Labels2Rois from ch.epfl.biop.ij2command import Labels2Rois, Rois2Labels
# python imports # python imports
import os import os
...@@ -707,6 +707,33 @@ def save_labelimage_as_ijroiset(label_imp, filename, suffix, target): ...@@ -707,6 +707,33 @@ def save_labelimage_as_ijroiset(label_imp, filename, suffix, target):
rm.reset() 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): def close_images(list_of_imps):
"""Close given ImagePlus images """Close given ImagePlus images
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment