diff --git a/2d_spots_in_fibers.py b/2d_spots_in_fibers.py index 6dffdfcc52781bcbe5a84f6bf869e2e046152cba..3d169ac4074d7951e6a63582eda9bb7332428a80 100644 --- a/2d_spots_in_fibers.py +++ b/2d_spots_in_fibers.py @@ -7,7 +7,7 @@ #@ Integer (label="DAPI threshold", description="0 = Auto", min=0) threshold #@ String (label="processing channels", description="comma separated list of channels, e.g. 2,3,6,7", value="1,2,3,4") processing_channels_string #@ String (label="Spot detection quality threshold", description="comma separated list of values, one per channel", value="80,80,80,80" ) quality_thresholds_string - +#@ Double (label="Minimum spot diameter", description="smaller spots will be discarded, value=5, min=1, max=200, stepSize=0.5, persist=false, style=slider) spot_diameter # trackmate imports from fiji.plugin.trackmate import Settings @@ -274,7 +274,7 @@ def BFopen_image(path_to_image, channel_number, series_number, region=None, z_sl return imps[0] -def run_trackmate_dog_spot_detector(imp, quality_threshold): +def run_trackmate_dog_spot_detector(imp, spot_diameter, quality_threshold): """Run TrackMates DoG detector with a given quality threshold on a target image @@ -296,7 +296,7 @@ def run_trackmate_dog_spot_detector(imp, quality_threshold): settings.detectorFactory = DogDetectorFactory() settings.detectorSettings['DO_SUBPIXEL_LOCALIZATION'] = True - settings.detectorSettings['RADIUS'] = 0.15 # type = double + settings.detectorSettings['RADIUS'] = spot_diameter / 2 # type = double settings.detectorSettings['TARGET_CHANNEL'] = 0 settings.detectorSettings['THRESHOLD'] = quality_threshold # type = double settings.detectorSettings['DO_MEDIAN_FILTERING'] = False @@ -758,18 +758,16 @@ processing_channels = processing_channels_string.split(",") quality_thresholds_string = quality_thresholds_string.replace(" ", "") quality_thresholds = quality_thresholds_string.split(",") -# Get the fiber segmentation from ij roizip and convert to labelimage -canvas = create_empty_image(32, image_width, image_height) -load_rois_from_zip(fiber_segmentation_roiset) -fibers_label_imp = convert_rois_to_labelimage(canvas) -canvas.close() - # threshold DAPI channel and convert to binary dapi_channel = BFopen_image(path_to_image, dapi_channel_number, series_number) if threshold <= 0: threshold = get_threshold_from_method(dapi_channel, "otsu") dapi_binary = convert_to_binary(dapi_channel, threshold) -close_images([dapi_channel]) + +# 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()