-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmy_startupMacro.ijm
4779 lines (4485 loc) · 178 KB
/
my_startupMacro.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Kevin Terretaz
// StartupMacros perso
// global variables are in UPPER_CASE
// macro "test Tool - C000 T0508T T5508e Ta508s Tg508t"{
// getCursorLoc(x, y, z, flags);
// showStatus(flags);
// }
var SAVED_LOC_X = 0;
var SAVED_LOC_Y = screenHeight() - 470;
//for image window size backup (macro[2])
var POSITION_BACKUP_TITLE = "";
var X_POSITION_BACKUP = 300;
var Y_POSITION_BACKUP = 300;
var WIDTH_POSITION_BACKUP = 400;
var HEIGHT_POSITION_BACKUP = 400;
// for quick Set LUTs
var CHOSEN_LUTS = get_Pref_LUTs_List(newArray("k_Blue","k_Magenta","k_Orange","k_Green","Grays","Cyan","Magenta","Yellow"));
var NOICE_LUTs = 0;
// For split_View
var COLOR_MODE = "Colored";
var MONTAGE_STYLE = "Linear";
var LABELS = "No labels";
var BORDER_SIZE = "Auto";
var FONT_SIZE = 30;
var CHANNEL_LABELS = newArray("CidB","CidA","DNA","H4Ac","DIC");
var TILES = newArray(1);
// For MultiTool
var MAIN_TOOL = "Move Windows";
var MULTITOOL_LIST = newArray("Move Windows", "Slice / Frame Tool", "LUT Gamma Tool", "Curtain Tool", "Magic Wand", "Scale Bar Tool", "Multi-channel Plot Tool");
var LAST_CLICK_TIME = 0;
//For wand tool
var WAND_BOX_SIZE = 5;
var ADD_TO_MANAGER = 0;
var TOLERANCE_THRESHOLD = 40;
var EXPONENT = 2;
var FIT_MODE = "None";
// title of the assigned target image : space + [7] key
var TARGET_IMAGE_TITLE = "";
// for Scale Bar Tool
var REMOVE_SCALEBAR_TEXT = false;
// for counting tools
var COUNT_LINE = 0;
// for multitool switch
var LAST_TOOL = 0;
// for [f5]
var DO_SCROLL_LOOP = false;
// for Action Bars
var ACTION_BAR_STRING = "";
//--------------------------------------------------------------------------------------------------------------------------------------
// MULTI TOOL
//--------------------------------------------------------------------------------------------------------------------------------------
macro "Multi Tool - N44C000D0cD0dD0eD1dD1eD1fD2aD2eD2fD3aD3bD3eD3fD4aD4bD4cD4dD4eD4fD4gD5bD5cD5dD5eD5fD5gD5hD6fD6gD6hD6iD7gD7hD7iD7jD83D84D85D86D87D88D89D8aD8bD8cD8dD8eD8fD8gD8hD8iD8jD8kD8lD92D93D9lD9mDa1Da2DamDanDb1DbnDc1DcnDd1DdnDe1De2DemDenDf2Df3DflDfmDg3Dg4Dg5Dg6Dg7Dg8Dg9DgaDgbDgcDgdDgeDgfDggDghDgiDgjDgkDh6Dh7Dh8Dh9DhaDhbDhcDi7Di8Di9DiaDicDidDj8Dj9DjaDjbDjdDjeDk9DkaDkbDkcDkdDkeDkfDlbDlcDldDleDlfDlgDmdDmeDmfDmgDmhCfffDa8Db8Dc6Dc7Dc8Dc9DcaDd8De8DibDjcCf30D94D95D96D97D98D99D9aD9bD9cD9dD9eD9fD9gD9hD9iD9jD9kDa3Da4Da5Da6Da7Da9DaaDabDacDadDaeDafDagDahDaiDajDakDalDb2Db3Db4Db5Db6Db7Db9DbaDbbDbcDbdDbeDbfDbgDbhDbiDbjDbkDblDbmDc2Dc3Dc4Dc5DcbDccDcdDceDcfDcgDchDciDcjDckDclDcmDd2Dd3Dd4Dd5Dd6Dd7Dd9DdaDdbDdcDddDdeDdfDdgDdhDdiDdjDdkDdlDdmDe3De4De5De6De7De9DeaDebDecDedDeeDefDegDehDeiDejDekDelDf4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDffDfgDfhDfiDfjDfk" {
multi_Tool();
}
macro "Multi Tool Options" {
Dialog.createNonBlocking("Multitool Options");
Dialog.addRadioButtonGroup("____________________ Main Tool : ____________________", MULTITOOL_LIST, 4, 2, MAIN_TOOL);
Dialog.addCheckbox("Remove text under scale bar?", REMOVE_SCALEBAR_TEXT);
Dialog.addMessage("________________ Magic Wand options : ______________");
Dialog.addNumber("Detection window size", WAND_BOX_SIZE);
Dialog.addSlider("Tolerance estimation threshold", 0, 100, TOLERANCE_THRESHOLD);
Dialog.addSlider("Adjustment speed", 1, 2, EXPONENT);
Dialog.addCheckbox("Auto add ROI to manager?", ADD_TO_MANAGER);
Dialog.addChoice("Fit selection? How?", newArray("None","Fit Spline","Fit Ellipse"), FIT_MODE);
Dialog.addHelp("https://kwolby.notion.site/Multi-Tool-526950d8bafc41fd9402605c60e74a99");
Dialog.show();
MAIN_TOOL = Dialog.getRadioButton();
REMOVE_SCALEBAR_TEXT = Dialog.getCheckbox();
WAND_BOX_SIZE = Dialog.getNumber();
TOLERANCE_THRESHOLD = Dialog.getNumber();
EXPONENT = Dialog.getNumber();
ADD_TO_MANAGER = Dialog.getCheckbox();
FIT_MODE = Dialog.getChoice();
save_Main_Tool(MAIN_TOOL);
}
//--------------------------------------------------------------------------------------------------------------------------------------
// SHORTCUTS
//--------------------------------------------------------------------------------------------------------------------------------------
var ShortcutsMenu = newMenu("Custom Menu Tool",
newArray( "Batch convert to tiff","Convert all opened images to 8-bit", "Convert all opened images to 16-bit", "Count table backup", "Merge Ladder and Signal WB","Macro TEM Chantal",
"-","Rotate 90 Degrees Right","Rotate 90 Degrees Left", "make my LUTs",
"-", "Gaussian Blur 3D...","Gamma...","Voronoi Threshold Labler (2D/3D)", "Scale Bar...","Long image to square"));
// macro "Custom Menu Tool - N55C000D1aD1bD1cD1dD29D2dD39D3dD49D4dD4eD59D5eD69D75D76D77D78D79D85D88D89D94D98D99Da4Da7Da8Da9Db3Db7Db8Dc3Dc6Dc7DccDcdDd3Dd6Dd8DdbDdcDe2De3De6De8De9DeaDebDecCfffD0dD3cD5cD6dD7bD8bD8cD96D9aD9bDa5DacDadDb5DcaDd4Dd9DdaDe4CdddD0aD1eD2bD6aD74D7aD95Dc4Dc5DeeC222D8eDa3DbcC111D38D5bD6bD7dDabDbaDd7C888D66De5C666D19Db4DcbC900CbbbD0cD87DaeDb2C444D28D2aD3eD48D84Db6Dc2CaaaDb9DedC777D0bD2eD4aD6cD7cD7eD9cD9dD9eDbdDc8CcccD2cDdeDe7C333D67D68DbeDd2DddC999D4cD58D5aD5dD93DceDd5Bf0C000D03D06D0cD13D16D1bD23D26D2aD33D37D39D43D44D47D48D54D65D76D77D87D88D89D8aD8bD8cD8dD8eD9bCfffD04D08D0dD0eD14D18D19D24D28D2cD35D3bD3cD3dD3eD45D46D4aD4bD4cD4eD56D57D5aD5bD5cD5dD5eD68D69D6aD6bD6cD6dD7cD7dCdddD1cD25D63D7eD97C222D64D66D9aC111D02D0bD36C888D98C666D12D38D78C900CbbbD0aD15D1eD2dD32D34C444D22D49D55D75D86D9cD9dCaaaD05D29D53C777D27D3aCcccD09D17C333D99C999D1aD2bD58D9eB0fC000D02D03D04D05D08D09D18D27D28D36D37D45D46D54D55D63D64D71D72D80D81CfffD06D07D16D25D30D34D35D40D43D44D52D57D60D61D75D83D85CdddD10D22D32D33D42D74C222D01D13D14D73C111C888D47D70C666C900D56D66D67D76D77D78D86D87D96CbbbD12D15D19D20D23D24D41D82C444D17CaaaC777D00CcccD11D26D90C333C999D62D65Nf0C000D33D34D35D36D42D43D46D50D51D55D64D65D66D67D73D74D78D88D96D97Da4Da5Db4Dc4Dd4Dd6Dd7Dd8De3De4De6De8De9CfffD15D31D44D53D54D58D62D84D85D86D92D93Da2Db2Dc2Dd2De7CdddD63Da1Da7Dc1Dd0De2C222D75D95Db3C111C888D23D32D45Dc3C666D40D52D57C900CbbbD70D80D94C444D24D60D68D87Da3Db0CaaaD26Dc0C777D41D81D91D98Dc7De5CcccD61D72D79D83D89Dc5Dd5Dd9De1C333D25D47D56D77Da0C999D37D76D90Da6Db5Dc6Dc8Dd3" {
macro "Custom Menu Tool - C000H6580a5f5c9de8b3e4915" {
command = getArgument();
if (command=="Batch convert to tiff") batch_ims_To_tif();
else if (command=="Convert all opened images to 8-bit") for ( i = 0; i < nImages; i++) {selectImage(i+1); run("8-bit");}
else if (command=="Convert all opened images to 16-bit") for ( i = 0; i < nImages; i++) {selectImage(i+1); run("16-bit");}
else if (command=="Merge Ladder and Signal WB") merge_Ladder_And_Signal_From_Licor();
else if (command=="make my LUTs") make_My_LUTs();
else if (command=="Macro TEM Chantal") traitement_TEM_Images_Chantal();
else if (command=="make my LUTs") make_My_LUTs();
else if (command=="Long image to square") square_Montage();
else run(command);
}
macro "Stacks Menu Built-in Tool" {}
// macro "LUT Menu Built-in Tool" {}
//--------------------------------------------------------------------------------------------------------------------------------------
// POPUP
//--------------------------------------------------------------------------------------------------------------------------------------
var pmCmds = newMenu("Popup Menu",
newArray("Set Main Tool", "Remove Overlay", "Duplicate...","Set LUTs","Set active path", "Set target image",
"-", "CLAHE", "Color Blindness",
"-", "Record...", "Monitor Memory...","Control Panel...", "Startup Macros..."));
macro "Popup Menu" {
command = getArgument();
if (command == "CLAHE") CLAHE();
else if (command == "Set active path") set_Active_Path();
// else if (command == "test") gauss_Correction_32bit();
else if (command == "Gaussian Correction") gauss_Correction();
else if (command == "Color Blindness") {rgb_Snapshot(); run("Dichromacy", "simulate=Deuteranope");}
else if (command == "Set LUTs") {get_LUTs_Dialog(); apply_LUTs();}
else if (command == "Set target image") set_Target_Image();
else if (command == "Set Main Tool") show_main_Tools_Regular_Bar();
else run(command);
}
//--------------------------------------------------------------------------------------------------------------------------------------
// PREVIEW OPENER
//--------------------------------------------------------------------------------------------------------------------------------------
macro "Preview Opener Action Tool - B00C000D00D01D02D03D04D05D06D07D08D09D0aD0bD0cD0dD0eD0fD10D15D1aD1fD20D25D2aD2fD30D35D3aD3fD40D45D4aD4fD50D51D52D53D54D55D56D57D58D59D5aD5bD5cD5dD5eD5fD60D65D6aD6fD70D75D7aD7fD80D85D8aD8fD90D95D9aD9fDa0Da1Da2Da3Da4Da5Da6Da7Da8Da9DaaDabDacDadDaeDafDb0Db5DbaDbfDc0Dc5DcaDcfDd0Dd5DdaDdfDe0De5DeaDefDf0Df1Df2Df3Df4Df5Df6Df7Df8Df9DfaDfbDfcDfdDfeDffC09bD1bD1cD1dD1eD2bD2cD2dD2eD3bD3cD3dD3eD4bD4cD4dD4eCfb0D16D17D18D19D26D27D28D29D36D37D38D39D46D47D48D49DbbDbcDbdDbeDcbDccDcdDceDdbDdcDddDdeDebDecDedDeeCcf8D11D12D13D14D21D22D23D24D31D32D33D34D41D42D43D44Cf84Db1Db2Db3Db4Dc1Dc2Dc3Dc4Dd1Dd2Dd3Dd4De1De2De3De4C8bfD66D67D68D69D76D77D78D79D86D87D88D89D96D97D98D99Ce05D6bD6cD6dD6eD7bD7cD7dD7eD8bD8cD8dD8eD9bD9cD9dD9eC8fdDb6Db7Db8Db9Dc6Dc7Dc8Dc9Dd6Dd7Dd8Dd9De6De7De8De9Cf4dD61D62D63D64D71D72D73D74D81D82D83D84D91D92D93D94"{
if (!isOpen("Preview Opener.tif")) make_Preview_Opener();
}
//--------------------------------------------------------------------------------------------------------------------------------------
// ACTION BARS
//--------------------------------------------------------------------------------------------------------------------------------------
var Action_Bars_Menu = newMenu("Action Bars Menu Tool",
newArray("Main Macro Shortcuts",
"-", "Splitview Macros", "Numerical Keyboard Macros", "More Macros",
"-", "Online Help"));
// "Utilities Macros", "Contrast Macros","Export Macros",
macro "Action Bars Menu Tool - B00C000D00D01D02D03D05D06D07D08D0aD0bD0cD0dD10D13D15D18D1aD1dD20D23D25D28D2aD2dD30D33D35D38D3aD3dD40D43D45D48D4aD4bD4cD4dD50D53D55D58D60D63D65D68D6aD6bD6cD6dD70D73D75D76D77D78D7aD7dD80D83D8aD8dD90D93D95D96D97D98D9aD9dDa0Da3Da5Da8DaaDadDb0Db3Db5Db8DbaDbdDc0Dc3Dc5Dc8DcaDcdDd0Dd3Dd5Dd8DdaDddDe0De3De5De8DeaDedDf0Df1Df2Df3Df5Df6Df7Df8DfaDfbDfcDfd" {
command = getArgument();
if (command == "Main Macro Shortcuts") show_All_Macros_Action_Bar();
else if (command == "SplitView Macros") show_SplitView_Bar();
else if (command == "Numerical Keyboard Macros") show_Numerical_Keyboard_Bar();
else if (command == "More Macros") show_Other_Macros();
else if (command == "Online Help") run("URL...", "url=[https://kwolby.notion.site/Macros-Shortcuts-f6a0cb526bcf4cb78ac72ff8cd29f30b]");
}
//--------------------------------------------------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------------------------------------------------
//FUNCTIONS KEYS
macro "[f1]" { count_Button("Type 1", "green"); }
macro "[f2]" { count_Button("Type 2", "magenta"); }
macro "[f3]" { count_Button("Type 3", "orange"); }
macro "[f4]" { count_Button("Type 4", "#00b9ff"); }
macro "[f5]" { scroll_Loop(); }
//NUMPAD KEYS
macro "[n0]"{ if (isKeyDown("space")) set_Favorite_LUT(); else if (isKeyDown("alt")) convert_To_iMQ_Style(); else paste_Favorite_LUT();}
macro "[n1]"{ if (isKeyDown("space")) toggle_Channel(1); else if (isKeyDown("alt")) toggle_Channel_All(1); else run("Grays");}
macro "[n2]"{ if (isKeyDown("space")) toggle_Channel(2); else if (isKeyDown("alt")) toggle_Channel_All(2); else run("KTZ Noice Green"); }
macro "[n3]"{ if (isKeyDown("space")) toggle_Channel(3); else if (isKeyDown("alt")) toggle_Channel_All(3); else run("KTZ Noice Red");}
macro "[n4]"{ if (isKeyDown("space")) toggle_Channel(4); else if (isKeyDown("alt")) toggle_Channel_All(4); else run("KTZ Noice Blue"); }
macro "[n5]"{ if (isKeyDown("space")) toggle_Channel(5); else if (isKeyDown("alt")) toggle_Channel_All(5); else run("KTZ Noice Magenta"); }
macro "[n6]"{ if (isKeyDown("space")) toggle_Channel(6); else if (isKeyDown("alt")) toggle_Channel_All(6); else run("KTZ Noice Orange"); }
macro "[n7]"{ if (isKeyDown("space")) toggle_Channel(7); else if (isKeyDown("alt")) toggle_Channel_All(7); else run("KTZ Noice Cyan"); }
macro "[n8]"{ if (isKeyDown("space")) run("8-bit"); else if (isKeyDown("alt")) run("16-bit"); else run("Magenta"); }
macro "[n9]"{ if (isKeyDown("space")) run("glasbey_on_dark"); else run("Yellow");}
macro "[n*]"{ difference_Of_Gaussian_Clij();}
//TOP NUMBER KEYS
macro "[0]" {
if (no_Alt_no_Space()) run("Open in ClearVolume");
else if (isKeyDown("space")) open_in_3D_Viewer();
// else if (isKeyDown("alt"))
}
macro "[1]" {
if (no_Alt_no_Space()) apply_LUTs();
else if (isKeyDown("space")) apply_All_LUTs();
else if (isKeyDown("alt")) get_My_LUTs();
}
macro "[2]" {
if (no_Alt_no_Space()) maximize_Image();
else if (isKeyDown("space")) restore_Image_Position();
else if (isKeyDown("alt")) full_Screen_Image();
}
macro "[3]" {
if (no_Alt_no_Space()) my_3D_projection();
else if (isKeyDown("space")) fancy_3D_montage();
// else if (isKeyDown("alt"))
}
macro "[4]" {
if (no_Alt_no_Space()) { run("Make Montage...", "scale=1"); setOption("Changes", 0); }
else if (isKeyDown("space")) run("Montage to Stack...");
// else if (isKeyDown("alt"))
}
macro "[5]" {
if (no_Alt_no_Space()) make_Scaled_Rectangle(25);
else if (isKeyDown("space")) make_Scaled_Rectangle(500);
// else if (isKeyDown("alt")) signal_normalisation_BIOP();
}
macro "[6]" {
if (no_Alt_no_Space()) force_black_canvas();
else if (isKeyDown("space")) show_my_Zbeul_Action_Bar();
else if (isKeyDown("alt")) show_my_Zbeul_Action_Bar();
}
macro "[7]" {
if (no_Alt_no_Space()) set_Target_Image();
else if (isKeyDown("space")) set_my_Custom_Location();
}
macro "[8]" {
if (no_Alt_no_Space()) run("Rename...");
else if (isKeyDown("space")) unique_Rename(getTitle());//rename(get_Time_Stamp("full") + "_" + getTitle());
else if (isKeyDown("alt")) rename(get_Time_Stamp("short") + "_" + getTitle());
}
macro "[9]" {
if (no_Alt_no_Space()) { if(File.exists(getDirectory("temp")+"test.tif")) open(getDirectory("temp")+"test.tif"); }
else if (isKeyDown("space")) saveAs("tif", getDirectory("temp")+"test.tif");
else if (isKeyDown("alt")) { run("Install...","install=["+getDirectory("macros")+"/toolsets/Visualization_toolset.ijm]"); setTool(15);}
}
macro "[V]" {
run("Install...","install=["+getDirectory("macros")+"/toolsets/Visualization_toolset.ijm]");
}
//LETTER KEYS
macro "[a]" {
if (no_Alt_no_Space()) if (matches(getTitle(), ".*Lookup Tables.*")) select_Montage_Panel(); else run("Select All");
else if (isKeyDown("space")) run("Restore Selection");
else if (isKeyDown("alt")) run("Select None");
}
macro "[A]" {
if (no_Alt_no_Space()) { if (bitDepth() == 24) run("Enhance True Color Contrast", "saturated=0.01"); else run("Enhance Contrast", "saturated=0.1");}
else if (isKeyDown("space")) enhance_All_Channels();
else if (isKeyDown("alt")) enhance_All_Images_Contrasts();
}
macro "[b]" {
if (no_Alt_no_Space()) split_View("Vertical", "Colored", "No labels");
else if (isKeyDown("space")) split_View("Vertical", "Grayscale", "No labels");
else if (isKeyDown("alt")) quick_Figure_Splitview("vertical");
}
macro "[B]" {
if (no_Alt_no_Space()) switch_Composite_Mode();
else if (isKeyDown("space")) quick_Scale_Bar(100);
}
macro "[C]" { run("Brightness/Contrast...");}
macro "[d]" {
if (no_Alt_no_Space()) {getDimensions(width, height, channels, slices, frames); if (channels>1 || bitDepth()==24) run("Split Channels"); else run("Stack to Images");}
else if (isKeyDown("space")) {run("Duplicate...", " "); string_To_Recorder("run(\"Duplicate...\", \" \");");}//slice
else if (isKeyDown("alt")) duplicate_The_Way_I_Want();
}
macro "[D]" {
if (no_Alt_no_Space()) {run("Duplicate...", "duplicate"); string_To_Recorder("run(\"Duplicate...\", \"duplicate\");");}
else if (isKeyDown("space")) open_Memory_And_Recorder();
else if (isKeyDown("alt")) run("Rotate 90 Degrees Left");
}
macro "[e]" {
if (no_Alt_no_Space()) plot_LUT();
else if (isKeyDown("space")) see_All_LUTs();
else if (isKeyDown("alt")) run("Edit LUT...");
}
macro "[E]" {
if (no_Alt_no_Space()) my_Tile();
else if (isKeyDown("alt")) {setKeyDown("None"); cul();}
}
macro "[F]" {
if (no_Alt_no_Space()) my_Tool_Roll();
else if (isKeyDown("space")) multichannel_CliJ_Stack_Focuser();
}
macro "[f]" {
if (no_Alt_no_Space()) run("Gamma...");
else if (isKeyDown("space")) set_Gamma_LUT_All_Channels(0.8);
else if (isKeyDown("alt")) run("Gaussian Blur 3D...","x=0.5 y=0.5 z=0.5");
}
macro "[G]" {
if (no_Alt_no_Space()) { run("Z Project...", "projection=[Max Intensity] all"); string_To_Recorder("run(\"Z Project...\", \"projection=[Max Intensity] all\");");}
else if (isKeyDown("space")) z_Project_All();
else if (isKeyDown("alt")) run("Z Project...", "projection=[Sum Slices] all");
}
macro "[g]" {
if (no_Alt_no_Space()) run("Z Project...");
else if (isKeyDown("space")) color_Code_Progressive_Max();
else if (isKeyDown("alt")) color_Code_No_Projection();
}
macro "[h]" {
if (no_Alt_no_Space()) run("Histogram");
else if (isKeyDown("space")) open(getDir("home") + "/desktop/Lookup Tables.tif");
else if (isKeyDown("alt")) open(File.getDirectory(getDirectory("imagej")) + "/images/_Preview Opener.tif");
}
macro "[H]" { run("Show All");}
macro "[i]" {
if (no_Alt_no_Space()) run("Invert LUTs");
else if (isKeyDown("space")) inverted_Overlay_HSB();
else if (isKeyDown("alt")) run("Invert LUT");
}
macro "[J]" {
if (no_Alt_no_Space()) {run("Input/Output...", "jpeg=100"); saveAs("Jpeg");}
else if (isKeyDown("space")) save_As_LZW_compressed_tif();
}
macro "[j]" {
if (no_Alt_no_Space()) run("Macro");
else if (isKeyDown("space")) run("Subtract Background...");
else if (isKeyDown("alt")) run_Clipboard_Macro_On_All_opened_Images();
}
macro "[k]" {
if (no_Alt_no_Space()) multi_Plot();
else if (isKeyDown("space")) multi_Plot(); //normalized multiplot
else if (isKeyDown("alt")) multi_Plot_Z_Axis();
}
macro "[l]" {
if (no_Alt_no_Space()) run("Find Commands...");
else if (isKeyDown("space")) random_Awesome_LUT(5);
else if (isKeyDown("alt")) show_LUT_Bar();
}
macro "[L]" {
if (no_Alt_no_Space()) copy_Paste_All_Channels_LUTs();
else if (isKeyDown("space")) rgb_LUT_To_LUT();
// else if (isKeyDown("alt"))
}
macro "[M]" {
if (no_Alt_no_Space()) fast_Merge();
else if (isKeyDown("space")) run("Merge Channels...");
// else if (isKeyDown("alt"))
}
macro "[m]" {
if (no_Alt_no_Space()) run("Measure");
else if (isKeyDown("alt")) linear_LUTs_Baker();
}
macro "[n]" {
if (no_Alt_no_Space()) Hela();
else if (isKeyDown("space")) make_LUT_Image();
else if (isKeyDown("alt")) open(File.getDirectory(getDirectory("imagej")) + "/images/1ch_newTestImage.tif");
}
macro "[N]" {
if (no_Alt_no_Space()) show_Numerical_Keyboard_Bar();
else if (isKeyDown("space")) run("Text Window...", "name=Untitled width=50 height=10 menu");
else if (isKeyDown("alt")) open(File.getDirectory(getDirectory("imagej")) + "/images/1ch_z_projection_test.tif");
}
macro "[o]" {
if (nImages > 0) {
if (matches(getTitle(), ".*Preview Opener.*")) open_From_Preview_Opener();
else if (matches(getTitle(), ".*Lookup Tables.*")) set_LUT_From_Montage();
}
else open("["+ String.paste() + "]");
}
macro "[p]" {
if (no_Alt_no_Space()) split_View("Linear", "Grayscale", "No labels");
else if (isKeyDown("space")) split_View("Square", "Grayscale", "No labels");
else if (isKeyDown("alt")) quick_Figure_Splitview("linear");
}
macro "[Q]" { composite_Switch(); }
macro "[q]" {
if (no_Alt_no_Space()) arrange_Channels();
else if (isKeyDown("space")) reorder_LUTs();
else if (isKeyDown("alt")) doCommand("Start Animation [\\]");
}
macro "[R]" {
if (no_Alt_no_Space()) auto_Contrast_All_Channels();
else if (isKeyDown("space")) auto_Contrast_All_Images();
else if (isKeyDown("alt")) propagate_Contrasts_All_Images();
}
macro "[r]" {
if (no_Alt_no_Space()) adjust_Contrast();
else if (isKeyDown("space")) {run("Install...","install=["+getDirectory("macros")+"/StartupMacros.fiji.ijm]"); setTool(15);}
else if (isKeyDown("alt")) reduce_Contrast();
}
macro "[S]" {
if (no_Alt_no_Space()) split_View("Square", "Colored", "No labels");
else if (isKeyDown("space")) split_View("Linear", "Colored", "No labels");
else if (isKeyDown("alt")) split_View_Dialog();
}
macro "[s]" {
if (no_Alt_no_Space()) saveAs("Tiff");
else if (isKeyDown("space")) ultimate_SplitView();
else if (isKeyDown("alt")) save_All_Images_Dialog();
}
macro "[t]" {
if (no_Alt_no_Space()) eval(String.paste);
else if (isKeyDown("space")) run("Action Bar", String.paste);
else if (isKeyDown("alt")) install_Tool_From_Clipboard();
}
macro "[u]" {
if (no_Alt_no_Space()) rgb_To_Composite_switch();
else if (isKeyDown("space")) my_RGB_Converter("half");
else if (isKeyDown("alt")) Red_Green_to_Orange_Blue();
}
macro "[U]" {
if (no_Alt_no_Space()) my_RGB_Converter("full");
}
macro "[v]" {
if (no_Alt_no_Space()) run("Paste");
else if (isKeyDown("space")) run("System Clipboard");
else if (isKeyDown("alt")) open(getDirectory("temp")+"/copiedLut.lut");
}
macro "[w]" {
if (no_Alt_no_Space()) {
if (nImages()==0) exit();
//avoid "are you sure?" and stores path in case of misclick
path = getDirectory("image") + getTitle();
if (File.exists(path)) call("ij.Prefs.set","last.closed", path);
close();
}
else if (isKeyDown("space")) open(call("ij.Prefs.get","last.closed",""));
else if (isKeyDown("alt")) close("\\Others");
}
macro "[x]" {
if (no_Alt_no_Space()) copy_LUT();
else if (isKeyDown("space")) channels_Roll();
else if (isKeyDown("alt")) {run("Copy to System"); showStatus("copy to system");}
}
macro "[y]" {
if (no_Alt_no_Space()) run("Synchronize Windows");
else if (isKeyDown("space")) {getCursorLoc(x, y, z, modifiers); doWand(x, y, estimate_Tolerance(), "8-connected");}
}
macro "[Z]" {
if (no_Alt_no_Space()) run("Channels Tool...");
else if (isKeyDown("space")) run("LUT Channels Tool");
else if (isKeyDown("alt")) {setKeyDown("None"); run("LUTs Finder");}
}
macro "[n/]" {
show_Shortcuts_Table();
}
function show_Shortcuts_Table(){
SHORTCUT_LINE_INDEX = -1;
Table.create("Macro shortcuts");
Table.setLocationAndSize(0, 100, 580, 600);
// line Key Alone with Space with Alt
add_Shortcuts_Line("f1, f2, f3, f4", "Count++ and add overlay", "Count-- and remove overlay", "new line on Count Table (not f4!)");
add_Shortcuts_Line("f5", "Toggle auto slice scroll", "", "");
add_Shortcuts_Line("0", "Open in ClearVolume ", "Open in 3D viewer ", "__________________ ");
add_Shortcuts_Line("1", "Apply favorite LUTs", "Apply LUTs to all", "Set favorite LUTs");
add_Shortcuts_Line("2", "Center image", "Restore position", "Full width of screen");
add_Shortcuts_Line("3", "3D animation", "Cool 3D animation", "");
add_Shortcuts_Line("4", "Make montage", "Montage to stack", "");
add_Shortcuts_Line("5", "Make selection 25x25", "make selection 500x500", "");
add_Shortcuts_Line("6", "Force black canvas", "my Popup Bar", "");
add_Shortcuts_Line("7", "Set target image", "Set source image", "Set custom position");
add_Shortcuts_Line("8", "Rename image", "Add short time stamp to title", "Add full time Stamp to title");
add_Shortcuts_Line("9", "Open temp image", "Save image in temp", "");
add_Shortcuts_Line("n0", "Favorite LUT", "Set favorite LUT", "Convert LUT to IMQ");
add_Shortcuts_Line("n1", "Grays LUT", "toggle channel 1", "toggle channel 1 all images");
add_Shortcuts_Line("n2", "Green LUT", "toggle channel 2", "toggle channel 2 all images");
add_Shortcuts_Line("n3", "Red LUT", "toggle channel 3", "toggle channel 3 all images");
add_Shortcuts_Line("n4", "Light blue LUT", "toggle channel 4", "toggle channel 4 all images");
add_Shortcuts_Line("n5", "My Magenta LUT", "toggle channel 5", "toggle channel 5 all images");
add_Shortcuts_Line("n6", "Orange LUT", "toggle channel 6", "toggle channel 6 all images");
add_Shortcuts_Line("n7", "Cyan LUT", "toggle channel 7", "toggle channel 7 all images");
add_Shortcuts_Line("n8", "Magenta LUT", "Convert image to 8-bit", "Convert image to 16-bit");
add_Shortcuts_Line("n9", "Yellow LUT", "Glasbey on dark LUT", "");
add_Shortcuts_Line("a", "Select All", "Restore Selection", "Select None");
add_Shortcuts_Line("A", "Enhance Contrast 0.03%", "Enhance all channels", "Enhance all images");
add_Shortcuts_Line("b", "Vertical colored Splitiview", "Vertical grayscale split_View", "Quick vertical PPT SplitView");
add_Shortcuts_Line("B", "Switch composite modes", "Auto scale bar", "");
add_Shortcuts_Line("c", "Copy", "", "");
add_Shortcuts_Line("C", "Brightness & Contrast", "", "");
add_Shortcuts_Line("d", "Split Channels", "Duplicate slice", "Duplicate full channel");
add_Shortcuts_Line("D", "Duplicate full image", "Open Memory and recorder", "");
add_Shortcuts_Line("e", "Plot Current LUT", "", "");
add_Shortcuts_Line("E", "Arrange windows on Tiles", "Multichannel LUT montage", "Edit LUT...");
add_Shortcuts_Line("f", "Gamma (real one)", "Gamma 0.7 on all LUTs", "Gaussian blur 3D 0.5");
add_Shortcuts_Line("F", "Rectangle/MultiTool switch", "ClIJ Stack focuser", "");
add_Shortcuts_Line("g", "Z Project...", "MaxColorCoding on copied LUT", "Color Coding no max (heavy)");
add_Shortcuts_Line("G", "Max Z Projection", "Max on all opened images", "Sum Z Projection");
add_Shortcuts_Line("H", "Show All images", "", "");
add_Shortcuts_Line("i", "Invert LUTs (Built in)", "Snapshot and invert colors", "Reverse LUT");
add_Shortcuts_Line("j", "Script Editor <3", "Rolling Ball bkg substraction", "Run clipboard macro on opened images");
add_Shortcuts_Line("J", "Save as JPEG max quality", "save As LZW compressed tif", "");
add_Shortcuts_Line("k", "Multi channel plot", "Normalized Multichannel Plot", "Multichannel Plot Z axis");
add_Shortcuts_Line("K", "Random LUTs", "", "");
add_Shortcuts_Line("l", "Find commands Tool <3", "LUT generator", "Open LUT Bar");
add_Shortcuts_Line("L", "Transfer LUTs from source ", "RGB image to LUT", "");
add_Shortcuts_Line("m", "LUT baker", "Max Paste mode", "");
add_Shortcuts_Line("M", "Automatic Merge channels", "Manual Merge channels", "");
add_Shortcuts_Line("n", "Open Hela Cells", "Create small LUT image", "Open my test image");
add_Shortcuts_Line("N", "numerical Keyboard Bar", "Text Window...", "");
add_Shortcuts_Line("o", "Open from macro montages", "", "");
add_Shortcuts_Line("p", "Linear grayscale splitview", "Squared grayscale Splitview", "Quick linear PPT SplitView");
add_Shortcuts_Line("P", "Properties...", "", "");
add_Shortcuts_Line("q", "Arrange channels order", "Arrange LUTs order", "Animation start/stop");
add_Shortcuts_Line("Q", "Composite/channel switch", "", "");
add_Shortcuts_Line("r", "Reset contrast channel", "Refresh startupMacros", "Reduce all max");
add_Shortcuts_Line("R", "Reset contrast all channels", "Reset contrast all images", "Same contrast all images");
add_Shortcuts_Line("s", "Save as tiff", "Hyperstack splitview", "Save all opened images");
add_Shortcuts_Line("S", "Colored squared Splitview", "Colored linear Splitiview", "Splitview options Dialog");
add_Shortcuts_Line("t", "Run macro from clipboard", "Install Ac_Bar from clipboard", "Install macro tool from clipboard");
add_Shortcuts_Line("u", "RGB/8bit switch", "RGB to half CMY", "RGB to Orange Blue");
add_Shortcuts_Line("U", "RGB to half CMY", "", "");
add_Shortcuts_Line("v", "Paste", "Paste from system", "Paste LUT");
add_Shortcuts_Line("x", "Copy LUT", "channel roll", "Copy to System");
add_Shortcuts_Line("y", "Synchronise windows", "Do my Wand", "");
add_Shortcuts_Line("w", "Close image", "Open last closed image (w)", "Close all others");
add_Shortcuts_Line("Z", "Channels Tool", "LUT Channels Tool", "LUT Panel");
add_Shortcuts_Line("n*", "Difference of gaussian", "", "");
}
var SHORTCUT_LINE_INDEX = -1;
function add_Shortcuts_Line(key, alone, space, alt){
SHORTCUT_LINE_INDEX++;
Table.set("Key", SHORTCUT_LINE_INDEX, key);
Table.set("Alone", SHORTCUT_LINE_INDEX, alone);
Table.set("with Space", SHORTCUT_LINE_INDEX, space);
Table.set("with Alt", SHORTCUT_LINE_INDEX, alt);
}
function square_Montage(){
getDimensions(width, height, channels, slices, frames);
getPixelSize(unit, pixelWidth, pixelHeight);
title = getTitle();
column = round(sqrt(width/height));
if (column <= 1) exit();
setBatchMode(1);
run("Montage to Stack...", "columns=&column rows=1 border=0");
run("Make Montage...", "columns=1 rows=&column scale=1");
unique_Rename(title + "_montage");
setVoxelSize(pixelWidth, pixelHeight, 1, unit);
setBatchMode(0);
}
function max_With_a_Twist(){
getDimensions(width, height, channels, slices, frames);
run("Duplicate...","duplicate");
setBatchMode(1);
for (c = 1; c <= channels; c++) {
if (channels>0) Stack.setChannel(c);
for (i = 1; i < nSlices; i++) {
setSlice(i);
run("Copy");
setSlice(i+1);
setPasteMode("substract");
run("Paste");
setPasteMode("Max");
run("Paste");
}
}
setBatchMode(0);
setPasteMode("Copy");
run("Select None");
setOption("Changes", 0);
}
function traitement_TEM_Images_Chantal(){
for ( i = 0; i < nImages(); i++) {
selectImage(i+1);
TITLE = getTitle();
setBatchMode(1);
// run("32-bit");
// run("Duplicate...", "title=gaussed duplicate");
// getDimensions(width, height, channels, slices, frames);
// SIGMA = maxOf(height,width) / 4;
// run("Gaussian Blur...", "sigma=" + SIGMA + " stack");
// imageCalculator("Divide stack", TITLE, "gaussed");
// selectImage(i+1);
run("Bandpass Filter...", "filter_large=500 filter_small=0 suppress=None tolerance=5");
resetMinAndMax();
run("8-bit");
rename(TITLE + "_corrected_d");
setBatchMode(0);
run("Enhance Local Contrast (CLAHE)", "blocksize=200 histogram=256 maximum=1.3 mask=*None* fast_(less_accurate)");
run("Unsharp Mask...", "radius=2 mask=0.30");
run("Enhance Contrast", "saturated=0.1");
setOption("Changes", 0);
}
}
function signal_normalisation_BIOP(){
noiseLimit=30; // set this to 3-5 times the standard deviation in a region with only noise
radius=10;
title=getTitle();
run("Duplicate...", "duplicate");
setBatchMode(1);
rename("orig");
run("32-bit");
run("Duplicate...", "title=average");
run("Mean...", "radius=&radius");
selectWindow("orig");
run("Duplicate...", "title=normalization");
run("Variance...", "radius=&radius");
run("Square Root");
run("Min...", "value=&noiseLimit");
imageCalculator("Subtract", "orig","average");
imageCalculator("Divide", "orig","normalization");
unique_Rename(title);
setBatchMode(0);
}
function save_Main_Tool(main_Tool) {
call("ij.Prefs.set","Multi_Tool.Main_Tool", main_Tool);
// setTool(15);
showStatus("multi tool: " + main_Tool);
return main_Tool;
}
function get_Main_Tool(default_Main_Tool) {
return call("ij.Prefs.get","Multi_Tool.Main_Tool", default_Main_Tool);
}
function save_Pref_LUT(index, lut_Name) {
call("ij.Prefs.set","Fav_LUT." + index, lut_Name);
}
function get_Pref_LUT(index, default_LUT) {
return call("ij.Prefs.get","Fav_LUT." + index, default_LUT);
}
function get_Pref_LUTs_List(default_LUTs){
chosen_luts = newArray();
for ( i = 0; i < 8; i++) chosen_luts[i] = get_Pref_LUT(i, default_LUTs[i]);
return chosen_luts;
}
function string_To_Recorder(string) {
if (isOpen('Recorder')) call("ij.plugin.frame.Recorder.recordString",string + "\n");
}
function clipboard_To_String(){
string = replace(String.paste(), "\"", "\\\"");
String.copy("\"" + string + "\"");
showStatus("corrected in clipboard");
}
function unique_Rename(name) {
final_Name = name;
i = 1;
while (isOpen(final_Name)) {
final_Name = name + "_" + i;
i++;
}
rename(final_Name);
}
function quick_Figure_Splitview(linear_or_Vertical){
if (nImages()==0) exit();
getDimensions(width, height, channels, slices, frames);
BORDER_SIZE = minOf(height, width) * 0.02;
if (linear_or_Vertical == "linear") split_View("Linear", "Grayscale", "Add labels");
else split_View("Vertical", "Grayscale", "Add labels");
run("Copy to System");
}
function clipboard_To_Completion() {
command = String.paste();
command = replace(command, "\"", "\\\"");
full_Command = command;
end_Index = command.indexOf("(");
if (end_Index == -1) end_Index = command.length;
command = "\n\n { \"trigger\": \"" + command.substring(0, end_Index) + "\", \"contents\": \"" + add_Fields(command) + "\""+ ", \"annotation\": \"" + full_Command + "\" },";
return String.copy(command);
}
// fields = auto variable selection after completion
function add_Fields(s) {
index_1 = indexOf(s, "(");
index_2 = indexOf(s, ")");
if (index_1 == -1 || index_2 == -1) return s+"();";
result_String = substring(s, 0, indexOf(s, "(")+1);
fields = substring(s, index_1+1, index_2);
fields = split(fields, ", ");
if (fields.length == 0) return s +";";
for (i = 0; i < fields.length; i++) {
fields[i] = "${" + toString(i+1) +":"+ fields[i] + "}";
if (i==fields.length-1) result_String += fields[i] + ");";
else result_String += fields[i] + ", ";
}
return result_String;
}
function count_Button(column_Name, color){
if (nImages==0) exit();
if(!isOpen("count.csv")){
COUNT_LINE = 0;
Table.create("count.csv");
Table.setLocationAndSize(0, 50, 230, 120);
Table.set("Type 1", COUNT_LINE, 0);
Table.set("Type 2", COUNT_LINE, 0);
Table.set("Type 3", COUNT_LINE, 0);
Table.set("Type 4", COUNT_LINE, 0);
Table.update;
}
if (isKeyDown("alt")) {
COUNT_LINE++;
Table.set("Type 1", COUNT_LINE, 0);
Table.set("Type 2", COUNT_LINE, 0);
Table.set("Type 3", COUNT_LINE, 0);
Table.set("Type 4", COUNT_LINE, 0);
Table.update;
exit();
}
n = Table.get(column_Name, COUNT_LINE);
if (isKeyDown("space")){
Table.set(column_Name, COUNT_LINE, n-1);
remove_Selected_Overlay();
}
else {
getCursorLoc(x, y, z, modifiers);
setColor(color);
Overlay.drawEllipse(x-5, y-5, 10, 10);
Overlay.show;
setColor("orange");
Table.set(column_Name, COUNT_LINE, n+1);
}
Table.update;
saveAs("Results", getDir("temp") + "count.csv");
}
function remove_Selected_Overlay(){
getCursorLoc( x, y, z, flags );
if ( Overlay.size < 1 ) exit();
id = Overlay.indexAt( x, y );
if (id!=-1) Overlay.removeSelection(id);
}
function scroll_Loop(){
if (DO_SCROLL_LOOP) DO_SCROLL_LOOP = false;
else DO_SCROLL_LOOP = true;
getDimensions(width, height, channels, slices, frames);
if(slices==1 && frames==1) exit();
getCursorLoc(x, y, z, flags);
flags = flags%32; //remove "cursor in selection" flag
while(DO_SCROLL_LOOP) {
getCursorLoc(x, y, z, flags);
getDisplayedArea(area_x, area_y, width, height);
flags = flags%32; //remove "cursor in selection" flag
if (frames > 1) Stack.setFrame(((x - area_x) / width) * frames);
else Stack.setSlice(((x - area_x) / width) * slices);
wait(10);
}
}
function arrange_Channels() {
// whithout losing metadata
if (nImages()==0) exit();
infos = getMetadata("Info");
run("Arrange Channels...");
setMetadata("Info", infos);
string_To_Recorder("run(\"Arrange Channels...\");");
}
// Add scale bar to image in 1-2-5 series size
// adapted from there https://forum.image.sc/t/automatic-scale-bar-in-fiji-imagej/60774?u=k_taz
function quick_Scale_Bar(factor){
if (nImages()==0) exit();
if ( Overlay.size > 0) {run("Remove Overlay"); exit();}
color = "White";
// approximate size of the scale bar relative to image width :
scalebar_Size = 0.13;
getPixelSize(unit, pixel_Width, pixel_Height);
if (unit == "pixels") exit("Image not spatially calibrated");
// image width in measurement units
shortest_Image_Edge = pixel_Width * minOf(Image.width, Image.height);
// initial scale bar length in measurement units :
scalebar_Length = 1;
// recursively calculate a 1-2-5 series until the length reaches scalebar_Size
// 1-2-5 series is calculated by repeated multiplication with 2.3, rounded to one significant digit
while (scalebar_Length < shortest_Image_Edge * scalebar_Size)
scalebar_Length = round((scalebar_Length*2.3)/(Math.pow(10,(floor(Math.log10(abs(scalebar_Length*2.3)))))))*(Math.pow(10,(floor(Math.log10(abs(scalebar_Length*2.3))))));
if (REMOVE_SCALEBAR_TEXT) {
scalebar_Settings_String = " height=" + minOf(Image.width, Image.height)/factor + " color="+color+" hide overlay";
print("Scale Bar length = " + scalebar_Length);
}
else scalebar_Settings_String = " height=" + minOf(Image.width, Image.height)/factor + " font=" + minOf(Image.width, Image.height)/(factor/2) + " color="+color+" bold overlay";
run("Scale Bar...", "width=&scalebar_Length " + scalebar_Settings_String);
string_To_Recorder("run(\"Scale Bar...\", \"width=" + scalebar_Length + scalebar_Settings_String + "\"");
}
function run_Clipboard_Macro_On_All_opened_Images(){
for ( i = 0; i < nImages(); i++) {
selectImage(i+1);
eval(String.paste());
}
}
function merge_Ladder_And_Signal_From_Licor() {
if (nImages == 0) exit("no image");
image_Titles = getList("image.titles");
Dialog.createNonBlocking("Select images");
Dialog.addMessage("Don't forget to adjust contrast before")
Dialog.addChoice("ladder:", image_Titles,image_Titles[0]);
Dialog.addChoice("signal", image_Titles,image_Titles[1]);
Dialog.show();
image1 = Dialog.getChoice();
image2 = Dialog.getChoice();
setBatchMode(1);
selectWindow(image1);
run("Duplicate...", "duplicate title=1");
setOption("ScaleConversions", true);
run("16-bit");
selectWindow(image2);
run("Duplicate...", "duplicate title=2");
run("16-bit");
imageCalculator("Subtract create 32-bit", "1", "2");
setBatchMode(0);
}
function save_As_LZW_compressed_tif(){
path = getDir("save As LZW compressed tif");
title = File.nameWithoutExtension;
print( path + File.separator + title);
run("Bio-Formats Exporter", "save=["+ path + File.separator + title + "_.tif] compression=LZW");
}
function multichannel_CliJ_Stack_Focuser(){
if (bitDepth()==24) run("Make Composite");
setBatchMode(1);
title = getTitle();
info = getMetadata("Info");
getVoxelSize(pixel_width, pixel_height, depth, unit);
getDimensions(width, height, channels, slices, frames);
if (channels > 1) {
for (i = 0; i < channels; i++) {
selectWindow(title);
Stack.setChannel(i+1);
getLut(reds, greens, blues);
clij_Stack_Focuser();
setLut(reds, greens, blues);
rename(title+i+1);
resetMinAndMax();
}
txt = "";
for (i=0; i<channels; i++) {
txt = txt + "c" + i+1 + "=[" + title+i+1 + "] ";
}
run("Merge Channels...", txt + "create");
}
else {
getLut(reds, greens, blues);
clij_Stack_Focuser();
setLut(reds, greens, blues);
}
unique_Rename(title+"_focused");
setMetadata("Info", info);
setVoxelSize(pixel_width, pixel_height, depth, unit);
setBatchMode(0);
}
function clij_Stack_Focuser(){
//Convert the strategy established by R. Wheeler in an imageJ macro running on CPU into an imageJ macro running in GPU
//Principle:
//In focus regions have sharper detail, therefore have a stronger edge detection result.
//The slice with the maximum edge detection result is most in focus.
//Build up the image from the original stack in patches according to the most in focus slice.
//Use gaussian blending to reduce the appearance of sharp edges.
//This is similar to the plugin by Michael Umorin:
//http://rsbweb.nih.gov/ij/plugins/stack-focuser.html
// input: a grayscale Z stack
// Marjorie Guichard - 08/04/2022
// Modified for gpu memory saving
//initialise GPU
run("CLIJ2 Macro Extensions", "cl_device=");
Ext.CLIJ2_clear();
//Get image information
slice_Number = nSlices;
width = getWidth();
height = getHeight();
bit = bitDepth();
max_Radius = 0;
blur_Sigma = 2;
//Load stack in GPU
original_Stack = getTitle();
Ext.CLIJ2_push(original_Stack);
//Sobel filter on GPU
Ext.CLIJ2_sobelSliceBySlice(original_Stack, sobel_Stack);
// Create max filter on pixel neighbours for each slice
Ext.CLIJ2_maximum3DSphere(sobel_Stack, sobel_Max_Stack, max_Radius, max_Radius, 0);
Ext.CLIJ2_release(sobel_Stack);
// z position of maximum z projection > create a height map
Ext.CLIJ2_zPositionOfMaximumZProjection(sobel_Max_Stack, z_Pos_of_Max);
Ext.CLIJ2_release(sobel_Max_Stack);
//initialise z position of maximum z projection separation
Ext.CLIJ2_create3D(z_Pos_To_Stack, width, height, slice_Number, bit);
Ext.CLIJ2_threshold(z_Pos_of_Max, threshTemp, slice_Number-1);
Ext.CLIJ2_copySlice(threshTemp, z_Pos_To_Stack, slice_Number-1);
Ext.CLIJ2_release(threshTemp);
//separate z position of maximum z projection in different slices
for (i = slice_Number-2; i > -1; i--) {
threshold = i;
Ext.CLIJ2_threshold(z_Pos_of_Max, threshTemp0, threshold+1);
Ext.CLIJ2_threshold(z_Pos_of_Max, threshTemp, threshold);
Ext.CLIJ2_subtractImages(threshTemp, threshTemp0, threshTempSub);
Ext.CLIJ2_copySlice(threshTempSub, z_Pos_To_Stack, i);
}
Ext.CLIJ2_release(threshTempSub);
Ext.CLIJ2_release(threshTemp0);
Ext.CLIJ2_release(threshTemp);
//Convert height map to float
Ext.CLIJ2_convertFloat(z_Pos_To_Stack, z_Pos_To_Stack_Float);
Ext.CLIJ2_release(z_Pos_To_Stack);
//Gaussian blur on height map and Stack Map slice by slice
for (i = 0; i < slice_Number; i++) {
Ext.CLIJ2_copySlice(z_Pos_To_Stack_Float, temp_Max, i);
Ext.CLIJ2_copySlice(original_Stack, temp_original, i);
Ext.CLIJ2_gaussianBlur2D(temp_Max, temp_Blur, blur_Sigma, blur_Sigma);
Ext.CLIJ2_multiplyImages(temp_Blur, temp_original, temp_Multiply);
Ext.CLIJ2_copySlice(temp_Multiply, z_Pos_To_Stack_Float, i);
}
//Sum slice
Ext.CLIJ2_sumZProjection(z_Pos_To_Stack_Float, result_image);
//display image
Ext.CLIJ2_pull(result_image);
Ext.CLIJ2_clear();
}
function correct_Copied_Path(){
copied_Path = replace(String.paste(), "\\", "/");
String.copy(copied_Path);
showStatus("corrected in clipboard");
}
// true if
function no_Alt_no_Space(){
if(!isKeyDown("space") && !isKeyDown("alt"))
return true;
else return false;
}
function make_LUT_Image() {
if (nImages == 0) {
newImage("lut"+round(random*100), "8-bit ramp", 256, 32, 1);
exit();
}
infos = getMetadata("Info");
if (bitDepth()==24) {
newImage("lut"+round(random*100), "8-bit ramp", 256, 32, 1);
exit();
}
getLut(reds, greens, blues);
newImage("lut"+round(random*100), "8-bit ramp", 256, 32, 1);
setLut(reds, greens, blues);
setMetadata("Info", infos);
}
function open_LUT_Bar(){
run("Action Bar", File.openUrlAsString("https://raw.githubusercontent.com/kwolbachia/Imagej-macro-addiction/main/LUT_Bar.ijm"));
}
function duplicate_The_Way_I_Want() {
if (nImages()==0) exit();
getDimensions(width, height, channels, slices, frames);
title = getTitle() + "_dup";
Stack.getPosition(channel, slice, frame);
if (channels > 1 && frames==1) {
run("Duplicate...", "duplicate title=title channels=&channel");
string_To_Recorder("run(\"Duplicate...\", \"duplicate title=" + title + " channels=" + channel + "\");");
}
else {
run("Duplicate...", "duplicate title=title channels=&channel frames=frame");
string_To_Recorder("run(\"Duplicate...\", \"duplicate title=" + title + " channels=" + channel + " frames=" + frame + "\");");
}
unique_Rename(title);
}
function force_black_canvas(){
for (i=0; i<nImages; i++) {
setBatchMode(1);
selectImage(i+1);
run("Appearance...", " ");
run("Appearance...", "black no");
setBatchMode(0);
}
}
function make_Scaled_Rectangle(size) {
//makes a squared selection of specified size, centered at mouse position
if (nImages()==0) exit();
toUnscaled(size);
size = round(size);
max = maxOf(Image.width(), Image.height());
if (size > max) size = max;
getCursorLoc(x, y, null, null);
call("ij.IJ.makeRectangle", x - (size/2), y-(size/2), size, size); //regular macro function is buggy
showStatus(size+"x"+size);
}
function set_Target_Image(){
if (nImages()==0) exit();
// modify the global variable TARGET_IMAGE_TITLE with the current image title
run("Alert ", "object=Image color=Orange duration=1000");
TARGET_IMAGE_TITLE = getTitle();
showStatus("target = " + TARGET_IMAGE_TITLE);