Mercurial > repos > bgruening > woundhealing_scratch_assay
annotate measureWoundClosing.groovy @ 0:8948cc562b7c draft default tip
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
author | bgruening |
---|---|
date | Thu, 29 Feb 2024 17:43:50 +0000 |
parents | |
children |
rev | line source |
---|---|
0
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
1 /** |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
2 * This script runs in Fiji |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
3 * |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
4 * It needs the following Fiji update sites: |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
5 * - IJPB-Plugins (MorpholibJ) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
6 */ |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
7 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
8 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
9 import fiji.threshold.Auto_Threshold |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
10 import ij.IJ |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
11 import ij.ImagePlus |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
12 import ij.gui.Roi |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
13 import ij.measure.Measurements |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
14 import ij.measure.ResultsTable |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
15 import ij.plugin.FolderOpener |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
16 import ij.plugin.ImageCalculator |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
17 import ij.plugin.filter.Analyzer |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
18 import ij.plugin.frame.RoiManager |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
19 import inra.ijpb.binary.BinaryImages |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
20 import inra.ijpb.morphology.Morphology |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
21 import inra.ijpb.morphology.Reconstruction |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
22 import inra.ijpb.morphology.strel.SquareStrel |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
23 import inra.ijpb.segment.Threshold |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
24 import net.imagej.ImageJ |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
25 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
26 // INPUT UI AND CLI |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
27 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
28 #@ File (label="Input directory", style="directory") inputDir |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
29 #@ String (label="Dataset ID") datasetId |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
30 #@ Double (label="CoV threshold (-1: auto)", default="-1") threshold |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
31 #@ Boolean (label="Run headless", default="false") headless |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
32 #@ Boolean (label="Save results", default="true") saveResults |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
33 #@ String (label="Output directory name (will be created next to input directory)", default="analysis") outDirName |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
34 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
35 // INPUT FOR TESTING WITHIN IDE |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
36 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
37 //def inputDir = new File("/Users/tischer/Documents/wound-healing-htm-screen/data/input") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
38 //def datasetId = "A3ROI2_Slow"; // C4ROI1_Fast A3ROI2_Slow |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
39 //def outDirName = "analysis" |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
40 //def threshold = (double) -1.0 // auto |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
41 //def headless = false; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
42 //def saveResults = false; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
43 //new ij.ImageJ().setVisible(true) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
44 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
45 // FIXED PARAMETERS |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
46 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
47 def cellDiameter = 20 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
48 def scratchDiameter = 500 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
49 def binningFactor = 2 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
50 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
51 // DERIVED PARAMETERS |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
52 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
53 def cellFilterRadius = cellDiameter/binningFactor |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
54 def scratchFilterRadius = scratchDiameter/binningFactor |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
55 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
56 println("Cell filter radius: " + cellFilterRadius) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
57 println("Scratch filter radius: " + scratchFilterRadius) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
58 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
59 // CODE |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
60 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
61 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
62 // open the images |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
63 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
64 IJ.run("Close All"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
65 println("Opening: " + datasetId) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
66 def imp = FolderOpener.open(inputDir.toString(), " filter=(.*"+datasetId+".*)") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
67 println("Number of slices: " + imp.getNSlices()) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
68 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
69 if ( imp == null || imp.getNSlices() == 0 ) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
70 println("Could not find any files matching the pattern!") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
71 System.exit(1) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
72 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
73 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
74 // process the images to enhance regions with cells |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
75 // using the fact the the cell regions have a higher local variance |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
76 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
77 println("Process images to enhance regions containing cells...") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
78 // remove scaling to work in pixel units |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
79 IJ.run(imp,"Properties...", "pixel_width=1 pixel_height=1 voxel_depth=1"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
80 // bin to save compute time |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
81 IJ.run(imp, "Bin...", "x=" + binningFactor + " y=" + binningFactor + " z=1 bin=Average"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
82 def binnedImp = imp.duplicate() // keep for saving |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
83 // enhance cells |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
84 IJ.run(imp, "32-bit", ""); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
85 def sdevImp = imp.duplicate() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
86 sdevImp.setTitle(datasetId + " sdev" ) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
87 IJ.run(sdevImp, "Find Edges", "stack"); // removes larger structures, such as dirt in the background |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
88 IJ.run(sdevImp, "Variance...", "radius=" + cellFilterRadius + " stack"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
89 IJ.run(sdevImp, "Square Root", "stack"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
90 // mean |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
91 def meanImp = imp.duplicate() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
92 meanImp.setTitle(datasetId + " mean") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
93 IJ.run(meanImp, "Mean...", "radius=" + cellFilterRadius + " stack"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
94 // cov |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
95 def covImp = ImageCalculator.run(sdevImp, meanImp, "Divide create 32-bit stack"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
96 IJ.run(covImp, "Enhance Contrast", "saturated=0.35"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
97 IJ.run(covImp, "8-bit", ""); // otherwise the thresholding does not seem to work |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
98 covImp.setTitle(datasetId + " cov" ) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
99 if (!headless) covImp.duplicate().show(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
100 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
101 // create binary image (cell-free regions are foreground) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
102 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
103 println("Creating binary image of cell-free regions...") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
104 // configure black background |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
105 IJ.run("Options...", "iterations=1 count=1 black"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
106 // determine threshold in first frame, because there we are |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
107 // closest to a 50/50 occupancy of the image with signal, |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
108 // which is best for most auto-thresholding algorithms |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
109 covImp.setPosition(1) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
110 def histogram = covImp.getProcessor().getHistogram() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
111 // Auto threshold with Huang method and |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
112 // multiply the threshold with a fixed factor (as is done in CellProfiler), |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
113 // based on the observation that the threshold is consistently |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
114 // a bit too high, which may be due to |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
115 // the fact that the majority of the image is foreground |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
116 if ( threshold == -1 ) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
117 threshold = Auto_Threshold.Huang(histogram) * 0.8 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
118 println("Threshold: " + threshold) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
119 // create binary image of whole movie, |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
120 // using the threshold of the first image |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
121 // defining the cell free regions as foreground |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
122 def binaryImp = (ImagePlus) Threshold.threshold(covImp, 0.0, threshold) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
123 // dilate the cell free regions, because due to the cell filter radius |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
124 // the cell sizes are over estimated (blurred into cell free regions) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
125 binaryImp = Morphology.dilation(binaryImp, SquareStrel.fromRadius((int) cellFilterRadius)) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
126 binaryImp.setTitle(datasetId + " binary") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
127 if(!headless) binaryImp.duplicate().show() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
128 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
129 // create scratch ROIs |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
130 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
131 println("Creating scratch ROI...") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
132 binaryImp.setPosition(1) // scratch is most visible in first frame |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
133 def scratchIp = binaryImp.crop("whole-slice").getProcessor().duplicate(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
134 // identify largest cell free region as scratch region |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
135 scratchIp = BinaryImages.keepLargestRegion(scratchIp) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
136 // remove cells inside scratch region |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
137 scratchIp = Reconstruction.fillHoles(scratchIp) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
138 if(!headless) new ImagePlus("Scratch", scratchIp.duplicate()).show() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
139 // disconnect from cell free regions outside scratch |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
140 scratchIp = Morphology.opening(scratchIp, SquareStrel.fromRadius((int)(scratchFilterRadius/20))) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
141 // in case the morphological opening cut off some cell free |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
142 // areas outside the scratch we again only keep the largest region |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
143 scratchIp = BinaryImages.keepLargestRegion(scratchIp) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
144 // smoothen scratch edges |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
145 scratchIp = Morphology.closing(scratchIp, SquareStrel.fromRadius((int)(scratchFilterRadius/2))) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
146 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
147 // convert binary image to ROI, which is handy for measurements |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
148 def scratchImp = new ImagePlus("Finale scratch", scratchIp) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
149 if(!headless) scratchImp.show() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
150 IJ.run(scratchImp, "Create Selection", ""); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
151 def scratchROI = scratchImp.getRoi() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
152 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
153 // measure occupancy of scratch ROI |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
154 // `area_fraction` returns the fraction of foreground pixels |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
155 // (cell free area) within the measurement ROI |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
156 println("Performing measurements...") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
157 IJ.run("Set Measurements...", "area bounding area_fraction redirect=None decimal=2"); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
158 def rt = RoiManager.multiMeasure(binaryImp, new Roi[]{scratchROI}, false) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
159 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
160 // show results |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
161 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
162 if ( !headless ) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
163 rt.show("Results") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
164 binnedImp.show() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
165 binnedImp.setTitle(datasetId + " binned") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
166 binnedImp.setRoi(scratchROI, true) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
167 binaryImp.setPosition(1) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
168 binaryImp.show() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
169 binaryImp.setTitle(datasetId + " binary") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
170 binaryImp.setRoi(scratchROI, true) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
171 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
172 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
173 // save results |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
174 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
175 if ( saveResults ) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
176 // create output directory next to input directory |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
177 def outputDir = new File(inputDir.getParent(), outDirName); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
178 println("Ensuring existence of output directory: " + outputDir) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
179 outputDir.mkdir() |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
180 // save table |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
181 rt.save(new File(outputDir, datasetId + ".csv").toString()); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
182 // save binned image with ROI |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
183 binnedImp.setRoi(scratchROI, false) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
184 IJ.save(binnedImp, new File(outputDir, datasetId + ".tif").toString()); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
185 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
186 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
187 println("Analysis of "+datasetId+" is done!") |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
188 if ( headless ) System.exit(0) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
189 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
190 // FUNCTIONS |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
191 // |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
192 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
193 // copied from ImageJ RoiManager because |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
194 // https://forum.image.sc/t/make-multimeasure-public-in-roimanager/69273 |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
195 private static ResultsTable multiMeasure(ImagePlus imp, Roi[] rois) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
196 int nSlices = imp.getStackSize(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
197 Analyzer aSys = new Analyzer(imp); // System Analyzer |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
198 ResultsTable rtSys = Analyzer.getResultsTable(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
199 ResultsTable rtMulti = new ResultsTable(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
200 rtMulti.showRowNumbers(true); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
201 rtSys.reset(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
202 int currentSlice = imp.getCurrentSlice(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
203 for (int slice=1; slice<=nSlices; slice++) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
204 int sliceUse = slice; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
205 if (nSlices==1) sliceUse = currentSlice; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
206 imp.setSliceWithoutUpdate(sliceUse); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
207 rtMulti.incrementCounter(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
208 if ((Analyzer.getMeasurements()& Measurements.LABELS)!=0) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
209 rtMulti.addLabel("Label", imp.getTitle()); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
210 int roiIndex = 0; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
211 for (int i=0; i<rois.length; i++) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
212 imp.setRoi(rois[i]); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
213 roiIndex++; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
214 aSys.measure(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
215 for (int j=0; j<=rtSys.getLastColumn(); j++){ |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
216 float[] col = rtSys.getColumn(j); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
217 String head = rtSys.getColumnHeading(j); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
218 String suffix = ""+roiIndex; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
219 Roi roi = imp.getRoi(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
220 if (roi!=null) { |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
221 String name = roi.getName(); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
222 if (name!=null && name.length()>0 && (name.length()<9||!Character.isDigit(name.charAt(0)))) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
223 suffix = "("+name+")"; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
224 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
225 if (head!=null && col!=null && !head.equals("Slice")) |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
226 rtMulti.addValue(head+suffix, rtSys.getValue(j,rtSys.getCounter()-1)); |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
227 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
228 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
229 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
230 return rtMulti; |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
231 } |
8948cc562b7c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools commit 4d4d0b10eb6be3b1f13b2becc8f057ac41d3f0de
bgruening
parents:
diff
changeset
|
232 |