Skip to content
Snippets Groups Projects
Commit aa9f80b0 authored by Laurent Guerard's avatar Laurent Guerard
Browse files

Add rescaling if image is too big for Cellpose even on Naboo

parent 2ef8b8cc
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment