annotate stack_max_projs.groovy @ 1:9be687213bc9 draft

planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
author lldelisle
date Fri, 13 Dec 2024 07:58:28 +0000
parents a02156aa8bda
children 3fd95c753cff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
1 /**
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
2 *
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
3 * The purpose of this script is to combine a series of time-lapse images into
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
4 * one file per image with possibly multiple channels and multiple time points
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
5 *
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
6 * To make the script run
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
7 * 1. Create a parent folder (base_dir) and a output folder (output_dir)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
8 * 2. The struction of the base_dir must be: one directory per final image and per channel. All the directories should be: `unique_identifier` `suffix specific to channel`.
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
9 * 3. The image names will be sorted before being merged.
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
10 * 4. The images must be regular tif.
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
11 *
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
12 * The expected outputs are:
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
13 * 1. In the output_dir one tiff per `unique_identifier` (potentially multi-T and potentially multi-C)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
14 */
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
15
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
16 #@ File(style="directory", label="Directory with one directory per final image and per channel") base_dir
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
17 #@ File(style="directory", label="Output directory (must exist)") output_dir
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
18 #@ String(label="Suffix for white channel directory", value="_BF_max", help="Leave empty if you are not interested") suffix_white
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
19 #@ String(label="Suffix for fluo channel(s) directory", value="_Fluo_max", help="Leave empty if you are not interested") suffix_fluo
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
20 #@ String(label="Pattern for green channel images", value="_H2B-GFP", help="Leave empty if you are not interested") pattern_green
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
21 #@ String(label="Pattern for red channel images", value="_RFP670", help="Leave empty if you are not interested") pattern_red
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
22
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
23
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
24 /**
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
25 * *****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
26 * ********************************************* Final Variables **************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
27 * ********************************************* DO NOT MODIFY ****************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
28 * ****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
29 */
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
30
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
31 // Version number = date of last modif
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
32 VERSION = "20241213"
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
33
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
34 /**
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
35 * *****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
36 * **************************************** Beginning of the script ***********************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
37 * ****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
38 */
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
39
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
40 try {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
41
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
42 println "Beginning of the script"
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
43
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
44 IJ.run("Close All", "")
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
45
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
46 // Find all directories
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
47 File[] dir_list = base_dir.listFiles()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
48
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
49 // The images are stored in a TreeMap where
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
50 // keys are unique_identifier
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
51 // values are a TreeMap that we call channelMap where:
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
52 // keys are colors (Green, Grays, Red)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
53 // values are an ImagePlus (T-stack)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
54 Map<Integer, Map<String, ImagePlus>> samplesMap = new TreeMap<>()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
55 List<String> dir_suffix_list = [suffix_white, suffix_fluo]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
56 List<String> dir_channels_list = ["Grays", "Fluo"]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
57
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
58 List<String> fluo_pattern_list = [pattern_green, pattern_red]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
59 List<String> fluo_channels_list = ["Green", "Red"]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
60
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
61 // Loop over directories:
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
62 for (File current_directory : dir_list) {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
63 // Ignore if it is not a directory
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
64 if (! current_directory.isDirectory()) {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
65 continue
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
66 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
67 String current_directory_name = current_directory.getName()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
68 // Check if it matches one of the suffix
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
69 String final_color = ""
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
70 // And find the unique identifier:
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
71 String unique_identifier = ""
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
72 for(int i = 0; i < dir_suffix_list.size(); i++){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
73 if (dir_suffix_list[i] != "" && current_directory_name.endsWith(dir_suffix_list[i])) {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
74 final_color = dir_channels_list[i]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
75 unique_identifier = current_directory_name.replace(dir_suffix_list[i], "")
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
76 continue
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
77 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
78 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
79 if (final_color == "") {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
80 println current_directory_name + " do not match any suffix."
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
81 continue
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
82 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
83 if (! samplesMap.containsKey(unique_identifier) ) {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
84 // Initiate the Map
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
85 samplesMap.put(unique_identifier, new TreeMap<>())
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
86 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
87 // Generate the ImagePlus
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
88 if (final_color == "Fluo") {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
89 for(int i = 0; i < fluo_pattern_list.size(); i++){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
90 // Use pattern for each color
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
91 if (fluo_pattern_list[i] != "") {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
92 println "Processing " + unique_identifier + " " + fluo_pattern_list[i]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
93 samplesMap.get(unique_identifier).put(
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
94 fluo_channels_list[i],
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
95 FolderOpener.open(
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
96 current_directory.getAbsolutePath(),
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
97 " filter=" + fluo_pattern_list[i]
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
98 )
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
99 )
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
100 // println samplesMap.get(unique_identifier).get(fluo_channels_list[i]).getDimensions()
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
101 if (!GraphicsEnvironment.isHeadless()){
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
102 samplesMap.get(unique_identifier).get(fluo_channels_list[i]).show()
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
103 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
104 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
105 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
106 } else {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
107 // It is easy as all images are used
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
108 println "Processing " + unique_identifier + " Greys"
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
109 samplesMap.get(unique_identifier).put(final_color, FolderOpener.open(current_directory.getAbsolutePath()))
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
110 // println samplesMap.get(unique_identifier).get(final_color).getDimensions()
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
111 if (!GraphicsEnvironment.isHeadless()){
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
112 samplesMap.get(unique_identifier).get(final_color).show()
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
113 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
114 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
115 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
116
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
117 // Explore the HashMap and save to tiff
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
118 for(String unique_identifier : samplesMap.keySet()){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
119 // get the channel map
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
120 Map<String, ImagePlus> channelsMap = samplesMap.get(unique_identifier)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
121 ArrayList<String> channels = []
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
122 ArrayList<ImagePlus> current_images = []
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
123 int ref_nT = 0
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
124 boolean all_compatibles = true
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
125
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
126 for(String channel : channelsMap.keySet()){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
127 channels.add(channel)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
128 current_images.add(channelsMap.get(channel))
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
129 if (ref_nT == 0) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
130 ref_nT = channelsMap.get(channel).nSlices
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
131 } else {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
132 if (ref_nT != channelsMap.get(channel).nSlices) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
133 all_compatibles = false
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
134 }
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
135 }
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
136 }
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
137
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
138 if (all_compatibles) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
139 // Merge all
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
140 ImagePlus merged_imps = Concatenator.run(current_images as ImagePlus[])
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
141 // Re-order to make a multi-channel, time-lapse image
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
142 ImagePlus final_imp
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
143 if (channels.size() == 1 && nT == 1) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
144 final_imp = merged_imps
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
145 } else {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
146 try {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
147 final_imp = HyperStackConverter.toHyperStack(merged_imps, channels.size() , 1, ref_nT, "xytcz", "Color")
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
148 // set LUTs
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
149 (0..channels.size()-1).each{
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
150 final_imp.setC(it + 1)
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
151 IJ.run(final_imp, channels[it], "")
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
152 final_imp.resetDisplayRange()
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
153 }
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
154 } catch(Exception e) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
155 println "Could not create the hyperstack for " + unique_identifier + ": " + e
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
156 continue
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
157 }
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
158 }
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
159 } else {
1
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
160 println "Not all channels have the same number of slices:"
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
161 (0..channels.size()-1).each{
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
162 println "Channel " + channels[it] + " has " + current_images[it].getDimensions() + " whCZT."
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
163 }
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
164 if (channelsMap.containsKey("Greys")) {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
165 println "Will keep only Greys channel"
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
166 final_imp = channelsMap.get("Greys")
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
167 } else {
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
168 println "Will keep only " + channels[0] + " channel"
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
169 final_imp = current_images[0]
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
170 IJ.run(final_imp, channels[0], "")
9be687213bc9 planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 39c8ae77d15d77ddcd8a0bb70f46d1be1531e9cc
lldelisle
parents: 0
diff changeset
171 }
0
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
172 final_imp.resetDisplayRange()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
173 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
174 // Save to tiff
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
175 final_imp.setTitle(unique_identifier)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
176
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
177 if (!GraphicsEnvironment.isHeadless()){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
178 final_imp.show()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
179 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
180
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
181 def fs = new FileSaver(final_imp)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
182 File output_path = new File (output_dir ,final_imp.getTitle()+"_merge.tif" )
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
183 fs.saveAsTiff(output_path.toString() )
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
184
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
185 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
186 println "End of the script"
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
187
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
188 } catch (Throwable e) {
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
189 println("Something went wrong: " + e)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
190 e.printStackTrace()
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
191 throw e
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
192
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
193 if (GraphicsEnvironment.isHeadless()){
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
194 // Force to give exit signal of error
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
195 System.exit(1)
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
196 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
197
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
198 }
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
199
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
200 return
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
201
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
202 /**
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
203 * ****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
204 * ******************************************* End of the script **************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
205 *
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
206 * ****************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
207 *
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
208 * *********************************** Helpers and processing methods *********************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
209 * ***************************************************************************************************************
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
210 */
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
211
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
212 import ij.IJ
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
213 import ij.ImagePlus
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
214 import ij.io.FileSaver
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
215 import ij.io.Opener
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
216 import ij.plugin.Concatenator
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
217 import ij.plugin.FolderOpener
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
218 import ij.plugin.HyperStackConverter
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
219 import ij.process.LUT
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
220
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
221 import java.awt.GraphicsEnvironment
a02156aa8bda planemo upload for repository https://github.com/lldelisle/tools-lldelisle/tree/master/tools/max_projections_stack_and_upload_omero commit 69a86e0a8ef82ce3c2232b99f72717a184f4d4cf
lldelisle
parents:
diff changeset
222 import java.io.File