Posted by
GP on
Apr 19, 2017; 12:31am
URL: http://imagej.273.s1.nabble.com/setBatchMode-True-for-Python-Script-tp5018569.html
Hie!
I have been converting my script from ".ijm" to ".py".
The problem is that the output images generated from plugins pop open. I couldn't find any setBatchMode(true) option for python script.
I found the discussion (
http://forum.imagej.net/t/jython-equivalent-for-setbatchmode-true/1197/3) but was not able to apply to all the plugins used in this script:
Following are the tasks performed over all sub-folders in the directory:
1) Get Images
2) Find Focussed Slice
3) Make Substack around it
4) Duplicate Substack
4) Process Duplicate Substack
5) Restore Selection on Substack
6) Process Original Substack
7) Save Final Image
Script as follows:
imp = IJ.openImage(images)
title = imp.getTitle()
IJ.run(imp, "Find focused slices", "select=100 variance=0.000") #All image windows start opening from this
#step onwards
IJ.run(imp, "Make Substack...", " slices=" "") #makes 'Substack' around focussed slice
Substack = IJ.getImage()
IJ.run("Duplicate...", "duplicate")
IJ.run("Remove Outliers...", "radius=1 threshold=50 which=Bright stack")
IJ.run("Auto Threshold", "method=Otsu ignore_black ignore_white white")
IJ.run("Z Project...", "projection=[Max Intensity]")
IJ.run("Shen-Castan Edge Detector", "coefficient=0.55")
IJ.run("Find Connected Regions", "allow_diagonal display_one_image display_results regions_for_values_over=100 minimum_number_of_points=1 stop_after=-1")
IJ.run("Ridge Detection", "line_width=3.5 high_contrast=230 low_contrast=87 correct_position extend_line show_junction_points show_ids verbose displayresults add_to_manager make_binary method_for_overlap_resolution=NONE sigma=1.51 lower_threshold=1.06 upper_threshold=4.99")
IJ.run("Find Maxima...", "noise=255 output=[Point Selection]")
h = ImagePlus.getRoi(k)
r = h.getBounds()
IJ.makeRectangle(x-300, y-300, x-300, y-300)
IJ.run(Substack, "Restore Selection", "")
IJ.run(Substack, "Crop", "")
IJ.run(Substack, "Z Project...", "projection=[Max Intensity]")
IJ.saveAs("Tiff" , os.path.join(output_path, title))
In Java API I found out batch mode possibility (
http://wiki.cmci.info/documents/110822jsip_cooking/javascript_imagej_cookbook). Can this be translated to python as well?
Please let me know if there's a way to do all the steps without having image windows opening.
Thank you so much.
Best Regards,