Skip to content
Snippets Groups Projects
example.py 1.33 KiB
Newer Older
# add directory of current script to search path
scripts_dir = os.path.dirname(sys.argv[0])
sys.path.append(scripts_dir) 

from ilastik_obmaps import ilastik_map_objects_simple

CHANNEL_TO_ILASTIK = 1 # i.e. index of color channel from confocal stack
OBJECT_CLASS_FOR_PHOTOACTIVATION = 1
ROOT = 'c:/Users/rhodes/projects/proj0004-marine-photoactivation/data/exp0021/'
PIXEL_CLASSIFIER_PATH = ROOT + 'ilastik/px-01.ilp'
OBJECT_CLASSIFIER_PATH = ROOT + 'ilastik/obj-04.ilp'
DEBUG = True


#obmap = ilastik_map_objects_simple(
#    IJ.getImage(),
#    PIXEL_CLASSIFIER_PATH,
#    OBJECT_CLASSIFIER_PATH,
#    CHANNEL_TO_ILASTIK
#)

# pipeline: remove any existing overlay
IJ.run("Remove Overlay")

resp = hit_endpoint(
    'GET',
    '/ilastik/pixel_then_object_classification/infer',
    {
        'px_model_id': id_px_mod,
        'ob_model_id': id_ob_mod,
        'input_filename': basename(abspath),
        'channel': channel,
    }
)


imp_czi = IJ.getImage()
#czi_fn = imp_czi.getTitle()
#czi_desc = czi_fn.split('.')[0]
#imp_czi.setDisplayMode(IJ.GRAYSCALE)
IJ.run("Make Subset...", "channels=" + str(CHANNEL_TO_ILASTIK))
imp_to_ilastik = IJ.getImage()

#obmap = ilastik_map_objects_simple(
#    imp_to_ilastik,
#    PIXEL_CLASSIFIER_PATH,
#    OBJECT_CLASSIFIER_PATH,
#    CHANNEL_TO_ILASTIK
#)