Mercurial > repos > bgruening > imagej2_crop
annotate imagej2_analyze_particles_binary_jython_script.py @ 0:018144807556 draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
| author | bgruening | 
|---|---|
| date | Tue, 24 Sep 2024 17:12:52 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
1 import sys | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
2 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
3 from ij import IJ, Prefs | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
4 from ij.plugin.filter import Analyzer | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
5 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
6 OPTIONS = ["edm=Overwrite", "iterations=1", "count=1"] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
7 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
8 # Fiji Jython interpreter implements Python 2.5 which does not | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
9 # provide support for argparse. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
10 roi_coordinate_file = sys.argv[-13] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
11 input_file = sys.argv[-12] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
12 black_background = sys.argv[-11] == "yes" | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
13 size = sys.argv[-10] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
14 circularity_min = float(sys.argv[-9]) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
15 circularity_max = float(sys.argv[-8]) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
16 show = sys.argv[-7] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
17 display_results = sys.argv[-6] == "yes" | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
18 exclude_edges = sys.argv[-5] == "yes" | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
19 include_holes = sys.argv[-4] == "yes" | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
20 output_filename = sys.argv[-3] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
21 output_datatype = sys.argv[-2] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
22 results_path = sys.argv[-1] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
23 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
24 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
25 if black_background: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
26 Prefs.blackBackground = True | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
27 else: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
28 Prefs.blackBackground = False | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
29 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
30 # Open the input image file. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
31 input_image_plus = IJ.openImage(input_file) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
32 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
33 # Create a copy of the image. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
34 input_image_plus_copy = input_image_plus.duplicate() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
35 image_processor_copy = input_image_plus_copy.getProcessor() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
36 analyzer = Analyzer(input_image_plus_copy) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
37 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
38 # Set binary options. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
39 options_list = OPTIONS | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
40 if black_background: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
41 options_list.append("black") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
42 options = " ".join(options_list) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
43 IJ.run(input_image_plus_copy, "Options...", options) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
44 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
45 if not image_processor_copy.isBinary(): | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
46 # Convert the image to binary grayscale. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
47 IJ.run(input_image_plus_copy, "Make Binary", "") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
48 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
49 # Set the options. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
50 options = ["size=%s" % size, "stack"] | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
51 circularity_str = "%.3f-%.3f" % (circularity_min, circularity_max) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
52 options.append("circularity=%s" % circularity_str) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
53 if exclude_edges: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
54 options.append("exclude") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
55 if include_holes: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
56 options.append("include") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
57 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
58 # If you need the coordinates of ROIs we compute it twice | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
59 if len(roi_coordinate_file) > 0: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
60 options2 = list(options) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
61 options2.append("show=Overlay") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
62 IJ.run(input_image_plus_copy, "Analyze Particles...", " ".join(options2)) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
63 ov = input_image_plus_copy.getOverlay() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
64 with open(roi_coordinate_file, 'w') as fo: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
65 fo.write("shape\tpoints\tlabel\tt\tz\n") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
66 for i, roi in enumerate(ov): | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
67 if roi.getName() is None: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
68 roi.name = "ROI_%d" % i | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
69 poly = roi.getPolygon() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
70 x_values = poly.xpoints | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
71 y_values = poly.ypoints | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
72 points_coo = ",".join(["(%d,%d)" % (x, y) for x, y in zip(x_values, y_values)]) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
73 fo.write("Polygon\t%s\t%s\t%d\t%d\n" % (points_coo, roi.getName(), roi.getTPosition(), roi.getZPosition())) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
74 analyzer.resetCounter() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
75 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
76 if show.find("_") >= 0: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
77 show_str = "[%s]" % show.replace("_", " ") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
78 else: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
79 show_str = show | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
80 options.append("show=%s" % show_str) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
81 if display_results: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
82 options.append("display") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
83 # Always run "in_situ". | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
84 options.append("in_situ") | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
85 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
86 # Run the command. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
87 IJ.run(input_image_plus_copy, "Analyze Particles...", " ".join(options)) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
88 | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
89 # Save outputs. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
90 if len(output_filename) > 0: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
91 # Save the ImagePlus object as a new image. | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
92 IJ.saveAs(input_image_plus_copy, output_datatype, output_filename) | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
93 if len(results_path) > 0: | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
94 results_table = analyzer.getResultsTable() | 
| 
 
018144807556
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/image_processing/imagej2 commit 8f49f3c66b5a1de99ec15e65c2519a56792f1d56
 
bgruening 
parents:  
diff
changeset
 | 
95 results_table.saveAs(results_path) | 
