diff --git a/1_identify_fibers.py b/1_identify_fibers.py index ffb0f5fe01696d9595df60291edabc3a8fb192cc..cae24238bb4cf238694a590bff382c23a567c70b 100755 --- a/1_identify_fibers.py +++ b/1_identify_fibers.py @@ -747,8 +747,13 @@ if __name__ == "__main__": raw, membrane_channel, membrane_channel, 1, 1, 1, 1 ) - if not os.path.exists(str(output_dir)): - os.makedirs(str(output_dir)) + if (membrane.getWidth() * membrane.getHeight()) > 100000: + misc.timed_log("Image is too large, resizing to speed up processing") + membrane = membrane.resize( + membrane.getWidth() / 2, + membrane.getHeight() / 2, + "none", + ) imp_bgd_corrected = do_background_correction(membrane) IJ.run("Conversions...", "scale") IJ.run(imp_bgd_corrected, "16-bit", "") @@ -764,46 +769,11 @@ if __name__ == "__main__": perimeter_thresh=[minPer, maxPer], ) - # update the log for the user - misc.timed_log("Now working on " + str(raw_image_title)) - if raw_image_calibration.scaled() is False: - IJ.log( - "Your image is not spatially calibrated! Size measurements are only possible in [px]." + imp_result = imp_result.resize( + raw.getWidth(), + raw.getHeight(), + "none", ) - # Only print it once since we'll use the same settings everytime - if index == 0: - IJ.log(" -- settings used -- ") - IJ.log("area = " + str(minAr) + "-" + str(maxAr)) - IJ.log("perimeter = " + str(minPer) + "-" + str(maxPer)) - IJ.log("circularity = " + str(minCir) + "-" + str(maxCir)) - IJ.log("ROI expansion [microns] = " + str(enlarge_radius)) - IJ.log("Membrane channel = " + str(membrane_channel)) - IJ.log("MHC positive fiber channel = " + str(fiber_channel)) - # IJ.log("sub-tiling = " + str(tiling_factor)) - IJ.log(" -- settings used -- ") - - # image (pre)processing and segmentation (-> ROIs)# imp, firstC, lastC, firstZ, - # lastZ, firstT, lastT - membrane = Duplicator().run(raw, membrane_channel, membrane_channel, 1, 1, 1, 1) - imp_bgd_corrected = do_background_correction(membrane) - IJ.run("Conversions...", "scale") - IJ.run(imp_bgd_corrected, "16-bit", "") - - imp_result = run_tm( - imp_bgd_corrected, - 1, - cellpose_dir.getPath(), - PretrainedModel.CYTO2, - 30.0, - area_thresh=[minAr, maxAr], - circularity_thresh=[minCir, maxCir], - perimeter_thresh=[minPer, maxPer], - ) - IJ.saveAs( - imp_result, - "Tiff", - os.path.join(output_dir, raw_image_title + "_all_fibers_binary"), - ) IJ.saveAs( imp_result,