diff --git a/2d_spots_in_fibers.py b/2d_spots_in_fibers.py index 3924854022bf9f6da243ce5317da666ac062797f..22b3a45e44b30e642e4050db67a9cdbffeadd179 100644 --- a/2d_spots_in_fibers.py +++ b/2d_spots_in_fibers.py @@ -30,7 +30,7 @@ from loci.formats import ImageReader, MetadataTools, Memoizer # MorpholibJ imports from inra.ijpb.binary import BinaryImages # BIOP imports -from ch.epfl.biop.ij2command import Labels2Rois, Rois2Labels +from ch.epfl.biop.ij2command import Labels2Rois # python imports import os @@ -330,7 +330,7 @@ def measure_intensity_sum(imp, rm): Example ------- - >>> labels, intensities = measure_intensity_sum(image, roi_manager) + >>> labels, intensities = measure_intensity_sum(imp, roi_manager) """ rt_ = ResultsTable() @@ -428,17 +428,6 @@ def load_rois_from_zip(path): 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 @@ -468,11 +457,6 @@ if threshold <= 0: threshold = get_threshold_from_method(dapi_channel, "otsu") dapi_binary = convert_to_binary(dapi_channel, threshold) -# Get the fiber segmentation from ij roizip and convert to labelimage -load_rois_from_zip(fiber_segmentation_roiset) -fibers_label_imp = convert_rois_to_labelimage(dapi_channel) -dapi_channel.close() - # detect spots and count them per fiber results_table = ResultsTable() for index, channel in enumerate(processing_channels): @@ -480,7 +464,7 @@ for index, channel in enumerate(processing_channels): quality_threshold = float(quality_thresholds[index]) spots_channel = BFopen_image(path_to_image, channel, series_number) spots_label_imp = run_trackmate_dog_spot_detector(spots_channel, spot_diameter, quality_threshold) - save_image_as_IJtif(spots_label_imp, filename, "spots_ch" + str(channel), parent_dir) + # save_image_as_IJtif(spots_label_imp, filename, "spots_ch" + str(channel), parent_dir) save_labelimage_as_ijroiset(spots_label_imp, filename, "spots_ch" + str(channel), parent_dir) spots_binary_imp = convert_labelimage_to_binary(spots_label_imp) dapi_positive_spots_binary = ImageCalculator.run(spots_binary_imp, dapi_binary, "Multiply create")