/
pimage.ijm
710 lines (613 loc) · 22.2 KB
/
pimage.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
macro "Multiloader" {
// Protocol dialog
showMessageWithCancel("Protocol: Multiloader","Summary of protocol steps:\n"+
"BEFORE STARTING: ensure red and green raw data subfolders are within a folder labelled with condition/coverslip/neuron number e.g. C456Yc2_1\n"+
"1: Dialog to choose a directory - select folder containing red and green raw data subfolders\n"+
"2: Dialog to load red image sequence\n"+
"3: Dialog to load green image sequence\n"+
"Press OK on this dialog to begin")
close("*");
dir=getDirectory("Choose a Directory");
print(dir);
File.makeDirectory(dir);
path_red = File.openDialog("Load first image in red image sequence");
run("Image Sequence...", "open=[path_red]");
run("Z Project...", "projection=[Average Intensity]");
// Save images as stack
red_name = File.getName(path_red);
selectWindow("AVG_Pos0");
saveAs("Tiff",dir+"_AVG_stack_r");
path_green = File.openDialog("Load first image in green image sequence");
run("Image Sequence...", "open=[path_green]");
run("Z Project...", "projection=[Average Intensity]");
// Save image as stack
green_name = File.getName(path_green);
selectWindow("AVG_Pos0");
saveAs("Tiff",dir+"_AVG_stack_g");
}
macro "PrepareImages" {
// Protocol dialog
showMessageWithCancel("Protocol: Prepare images","Summary of protocol steps:\n"+
"1: Dialog to load raw red image\n"+
"2: Dialog to load raw green image\n"+
"3: Manual alignment of red and green image planes\n"+
"4: Prompt to continue with protocol when user completes alignment\n"+
"Warning: Pressing OK will close all open images and reset ROI manager")
close("*");
roiManager("reset");
run("Clear Results");
setBatchMode("true");
setOption("ScaleConversions",true)
print("\\Clear")
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) images
path_red = File.openDialog("Load raw red image");
open(path_red);
w = getWidth();
h = getHeight();
path = getDirectory("image");
if (bitDepth() == 24) {
rename("1");
run("Split Channels");
close("1 (green)");
close("1 (blue)");
}
if (bitDepth() > 8) {
run("8-bit");
}
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
run("Remove Outliers...", "radius=2 threshold=50 which=Dark");
path_green = File.openDialog("Load raw green image");
open(path_green);
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimensions");
}
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
if (bitDepth() == 24) {
rename("2");
run("Split Channels");
close("2 (red)");
close("2 (blue)");
}
if (bitDepth() > 8) {
run("8-bit");
}
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
run("Remove Outliers...", "radius=2 threshold=50 which=Dark");
// Perform image alignment
run("Images to Stack", "name=Stack title=[] use");
// Add a third slice at the end of the stack
setSlice(2);
run("Add Slice");
// Convert to 8-bit and then convert stack to RGB
run("Stack to RGB");
run("Enhance Contrast...", "saturated=0 normalize");
close("Stack");
run("ROI Manager...");
run("Align RGB planes");
setBatchMode("false");
setTool("polygon");
waitForUser("Alignment","1. Adjust alignment of the images using Align RGB window controls.\n"+
"2. Draw polygon around the cell of interest and press the key 't'.\n"+
"3. Close the Align RGB window and click OK in this dialog.\n");
// Subtract uneven background
//run("Subtract Background...", "rolling=500 separate");
// Split channels
setBatchMode("true");
run("Split Channels");
close("Stack (RGB) (blue)");
// Duplicate green and red images
selectWindow("Stack (RGB) (green)");
run("Duplicate...", " ");
selectWindow("Stack (RGB) (red)");
run("Duplicate...", " ");
// Create background green and red images
selectWindow("Stack (RGB) (green)-1");
run("Subtract Background...", "rolling=500 create sliding"); // create file for subtract uneven background with sliding paraboloid
green_fname = File.getName(path_green);
i = lastIndexOf(green_fname,".");
green_fname = substring(green_fname,0,i);
saveAs("Tiff",path+green_fname+"_green_background");
selectWindow("Stack (RGB) (red)-1");
run("Subtract Background...", "rolling=500 create sliding"); // create file for subtract uneven background with sliding paraboloid
red_fname = File.getName(path_red);
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
saveAs("Tiff",path+red_fname+"_red_background");
// Save images
selectWindow("Stack (RGB) (red)");
run("Subtract Background...", "rolling=500 sliding"); // Subtract uneven background
red_fname = File.getName(path_red);
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
saveAs("Tiff",path+red_fname+"_red");
selectWindow("Stack (RGB) (green)");
run("Subtract Background...", "rolling=500 sliding"); // Subtract uneven background
green_fname = File.getName(path_green);
i = lastIndexOf(green_fname,".");
green_fname = substring(green_fname,0,i);
saveAs("Tiff",path+green_fname+"_green");
// Save ROI
run("Select All");
roiManager("Deselect");
roiManager("Save", path+"/prepROI.zip");
}
macro "PrepareImages16bit" {
// Protocol dialog
showMessageWithCancel("Protocol: Prepare images","Summary of protocol steps:\n"+
"1: Dialog to load raw red image\n"+
"2: Dialog to load raw green image\n"+
"3: Manual alignment of red and green image planes\n"+
"4: Prompt to continue with protocol when user completes alignment\n"+
"Warning: Pressing OK will close all open images and reset ROI manager")
close("*");
roiManager("reset");
run("Clear Results");
setBatchMode("true");
setOption("ScaleConversions",true)
print("\\Clear")
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) images
path_red = File.openDialog("Load raw red image");
run("Bio-Formats Importer", "open=["+path_red+"] color_mode=Grayscale rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
//open(path_red);
path = getDirectory("image");
if (bitDepth() == 16) {
rename("Red");
run("Make Substack...", "channels=1");
close("Red");
}
w = getWidth();
h = getHeight();
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
run("Remove Outliers...", "radius=2 threshold=50 which=Dark");
path_green = File.openDialog("Load raw green image");
run("Bio-Formats Importer", "open=["+path_green+"] color_mode=Grayscale rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
if (bitDepth() == 16) {
rename("Green");
run("Make Substack...", "channels=2");
close("Green");
}
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimensions");
}
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
run("Remove Outliers...", "radius=2 threshold=50 which=Dark");
// Perform image alignment
run("Images to Stack", "name=Stack title=[] use");
// Add a third slice at the end of the stack
setSlice(2);
run("Add Slice");
// Convert to 8-bit and then convert stack to RGB
run("Stack to RGB");
run("Enhance Contrast...", "saturated=0 normalize");
close("Stack");
run("ROI Manager...");
run("Align RGB planes");
setBatchMode("false");
setTool("polygon");
waitForUser("Alignment","1. Adjust alignment of the images using Align RGB window controls.\n"+
"2. Draw polygon around the cell of interest and press the key 't'.\n"+
"3. Close the Align RGB window and click OK in this dialog.\n");
// Subtract uneven background
//run("Subtract Background...", "rolling=500 separate");
// Split channels
setBatchMode("true");
run("Split Channels");
close("Stack (RGB) (blue)");
// Duplicate green and red images
selectWindow("Stack (RGB) (green)");
run("Duplicate...", " ");
selectWindow("Stack (RGB) (red)");
run("Duplicate...", " ");
// Create background green and red images
selectWindow("Stack (RGB) (green)-1");
run("Subtract Background...", "rolling=500 create sliding"); // create file for subtract uneven background with sliding paraboloid
green_fname = File.getName(path_green);
i = lastIndexOf(green_fname,".");
green_fname = substring(green_fname,0,i);
saveAs("Tiff",path+green_fname+"_green_background");
selectWindow("Stack (RGB) (red)-1");
run("Subtract Background...", "rolling=500 create sliding"); // create file for subtract uneven background with sliding paraboloid
red_fname = File.getName(path_red);
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
saveAs("Tiff",path+red_fname+"_red_background");
// Save images
selectWindow("Stack (RGB) (red)");
run("Subtract Background...", "rolling=500 sliding"); // Subtract uneven background
red_fname = File.getName(path_red);
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
saveAs("Tiff",path+red_fname+"_red");
selectWindow("Stack (RGB) (green)");
run("Subtract Background...", "rolling=500 sliding"); // Subtract uneven background
green_fname = File.getName(path_green);
i = lastIndexOf(green_fname,".");
green_fname = substring(green_fname,0,i);
saveAs("Tiff",path+green_fname+"_green");
// Save ROI
run("Select All");
roiManager("Deselect");
roiManager("Save", path+"/prepROI.zip");
}
macro "SpineFluorMeasure" {
// Protocol dialog
showMessageWithCancel("Protocol: Measure synaptic/total SEP-GluN1 fluorescence","Summary of protocol steps:\n"+
"1: Dialog to load prepared red image\n"+
"2: Dialog to load prepared green image\n"+
"3: Dialog to load red background image\n"+
"4: Dialog to load green background image\n"+
"5: Dialog to load prepROI.zip\n"+
"6: Specify radius of Median filter\n"+
"Warning: Pressing OK will close all open images and reset ROI manager");
close("*");
roiManager("reset");
run("Clear Results");
setBatchMode("true");
setOption("ScaleConversions",true)
print("\\Clear")
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) images
path_red = File.openDialog("Load prepared red image");
open(path_red);
w = getWidth();
h = getHeight();
path = getDirectory("image");
path_green = File.openDialog("Load prepared green image");
open(path_green);
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimenions");
}
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
red_fname = File.getName(path_red);
green_fname = File.getName(path_green);
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) background images
path_red_bkgnd = File.openDialog("Load red background image");
open(path_red_bkgnd);
w = getWidth();
h = getHeight();
path = getDirectory("image");
path_green_bkgnd = File.openDialog("Load green background image");
open(path_green_bkgnd);
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimenions");
}
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
green_bkgnd_fname = File.getName(path_green_bkgnd);
red_bkgnd_fname = File.getName(path_red_bkgnd);
// Load prepROI
path_roi = File.openDialog("Load prepROI.zip");
roiManager("Open",path_roi);
// Use median filter and global thresholding to create mask and ROI of synapses
selectWindow(red_fname);
roiManager("Select",0);
run("Copy");
run("Select None");
newImage("original","8-bit black",w,h,0);
roiManager("Select",0);
run("Paste");
newImage("filtered","8-bit black",w,h,0);
roiManager("Select",0);
run("Paste");
run("Median...");
imageCalculator("Subtract create", "original","filtered");
close("original");
close("filtered");
roiManager("Select",0);
run("Threshold...");
setThreshold(0,255);
call("ij.plugin.frame.ThresholdAdjuster.setMode", "B&W");
waitForUser("Alignment","Manually adjust global threshold then press OK");
run("Convert to Mask");
run("Median...","radius=1"); // Despeckle
run("Create Selection");
run("Make Inverse");
roiManager("Add");
rename("synapses");
run("Select None");
// Calculate relative spine fluorescence of green signal
selectWindow(green_fname);
run("Clear Results");
run("Set Measurements...", "mean standard redirect=None decimal=9");
roiManager("Select",1); // synapse ROI on green background-subtracted image
run("Measure");
selectWindow(green_bkgnd_fname);
roiManager("Select",1); // synapse ROI on green background image
run("Measure");
a = getResult("Mean",0); // Mean synapse green fluorescence
b = getResult("Mean",1); // Mean background green fluorescence
print("Synaptic green fluorescence = "+a);
print("Background green fluorescence = "+b);
run("Select None");
// Calculate relative spine fluorescence of red signal
selectWindow(red_fname);
run("Clear Results");
run("Set Measurements...", "mean standard redirect=None decimal=9");
roiManager("Select",1); // synapse ROI on red background-subtracted image
run("Measure");
selectWindow(red_bkgnd_fname);
roiManager("Select",1); // synapse ROI on red background image
run("Measure");
a = getResult("Mean",0); // Mean synapse red fluorescence
b = getResult("Mean",1); // Mean background red fluorescence
print("Synaptic red fluorescence = "+a);
print("Background red fluorescence = "+b);
run("Select None");
// Save mask of synapses
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
selectWindow("synapses");
saveAs("Tiff",path+red_fname+"_synapses");
// Save ROIs
roiManager("Deselect");
roiManager("Save", path+"/spineFluorROI.zip");
// Save log
selectWindow("Log");
saveAs("Text",path+"summary.txt");
// Clear up
setBatchMode("false");
}
macro "SpineFluorMeasureSplit" {
// Protocol dialog
showMessageWithCancel("Protocol: Measure synaptic/total SEP-GluN1 fluorescence","Summary of protocol steps:\n"+
"1: Dialog to load prepared red image\n"+
"2: Dialog to load prepared green image\n"+
"3: Dialog to load red background image\n"+
"4: Dialog to load green background image\n"+
"5: Dialog to load prepROI.zip\n"+
"6: Specify radius of Median filter\n"+
"Warning: Pressing OK will close all open images and reset ROI manager");
close("*");
roiManager("reset");
run("Clear Results");
setBatchMode("true");
setOption("ScaleConversions",true)
print("\\Clear")
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) images
path_red = File.openDialog("Load prepared red image");
open(path_red);
w = getWidth();
h = getHeight();
path = getDirectory("image");
path_green = File.openDialog("Load prepared green image");
open(path_green);
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimenions");
}
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
red_fname = File.getName(path_red);
green_fname = File.getName(path_green);
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) background images
path_red_bkgnd = File.openDialog("Load red background image");
open(path_red_bkgnd);
w = getWidth();
h = getHeight();
path = getDirectory("image");
path_green_bkgnd = File.openDialog("Load green background image");
open(path_green_bkgnd);
if ( (w != getWidth()) || (h != getHeight()) ) {
exit("Images must have the same dimenions");
}
if (path != getDirectory("image")) {
exit("Images must come from the same directory");
}
green_bkgnd_fname = File.getName(path_green_bkgnd);
red_bkgnd_fname = File.getName(path_red_bkgnd);
// Load prepROI
path_roi = File.openDialog("Load prepROI.zip");
roiManager("Open",path_roi);
//Subtract BG
// Use median filter and global thresholding to create mask and ROI of synapses
selectWindow(red_fname);
roiManager("Select",0);
run("Copy");
run("Select None");
newImage("original","8-bit black",w,h,0);
roiManager("Select",0);
run("Paste");
newImage("filtered","8-bit black",w,h,0);
roiManager("Select",0);
run("Paste");
run("Median...");
imageCalculator("Subtract create", "original","filtered");
close("original");
close("filtered");
roiManager("Select",0);
run("Threshold...");
setThreshold(0,255);
call("ij.plugin.frame.ThresholdAdjuster.setMode", "B&W");
waitForUser("Alignment","Manually adjust global threshold then press OK");
run("Convert to Mask");
run("Median...","radius=1"); // Despeckle
run("Create Selection");
run("Make Inverse");
roiManager("Add");
rename("synapses");
roiManager("Split"); //Split the ROIs
nROIs = roiManager("count");
run("Select None");
run("Properties...", "channels=1 slices=1 frames=1 pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000 global"); //Helps us identify ROIs of 1 pixel by measuring area.
// Calculate relative spine fluorescence of green signal
run("Clear Results");
run("Set Measurements...", "area mean display redirect=None decimal=9");
print("Label, Pixels, Synaptic green fluorescence, Background green fluorescence, Synaptic red fluorescence, Background red fluorescence");
k=2;
do {
run("Select None");
run("Clear Results");
selectWindow(green_fname);
roiManager("Select",k); // synapse ROI on green background-subtracted image
run("Measure");
selectWindow(green_bkgnd_fname);
roiManager("Select",k); // synapse ROI on green background image
run("Measure");
a = getResult("Mean",0); // Mean synapse green fluorescence
b = getResult("Mean",1); // Mean background green fluorescence
run("Clear Results");
selectWindow(red_fname);
roiManager("Select",k); // synapse ROI on green background-subtracted image
run("Measure");
selectWindow(red_bkgnd_fname);
roiManager("Select",k); // synapse ROI on green background image
run("Measure");
c = getResult("Mean",0); // Mean synapse red fluorescence
d = getResult("Mean",1); // Mean synapse red background fluorescence
l = getResultLabel(0);
p = getResult("Area",0);
if (p>1) {
print(l+","+p+","+a+","+b+","+c+","+d);
}
k=k+1;
} while(k<nROIs);
run("Select None");
// Save mask of synapses
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
selectWindow("synapses");
saveAs("Tiff",path+red_fname+"_synapses");
// Save ROIs
roiManager("Deselect");
roiManager("Save", path+"/spineFluorROI.zip");
//Save Results
selectWindow("Log");
saveAs("Text", path+"Results.csv");
// Save log
selectWindow("Log");
saveAs("Text",path+"summary.txt");
// Clear up
setBatchMode("false");
}
macro "SpineMorphMeasure" {
// Load the Homer1c-tdTomato (red) images
path_red = File.openDialog("Load prepared red image");
open(path_red);
w = getWidth();
h = getHeight();
path = getDirectory("image");
run("Properties...", "channels=1 slices=1 frames=1 unit=pixel pixel_width=1 pixel_height=1 voxel_depth=1");
setTool("multipoint");
print("\\Clear")
roiManager("reset");
run("Select None");
run("Clear Results");
//to set the division factor for pixel length to micrometers for later output measurements
Dialog.create("Pixel Size");
Dialog.addMessage("Enter pixel size");
Dialog.addNumber("Pixel (Microns)",0.103); //0.103 = um per pixel for Axiovert lab microscope at 63xObjective
Dialog.show();
p = Dialog.getNumber();
//to define the straight line of dendrite and create a line along the dendtrite
waitForUser( "Pause","Draw Line Points at either end of dendrite area");
run("Measure");
x1 = getResult("X",0);
y1 = getResult("Y",0);
x2 = getResult("X",1);
y2 = getResult("Y",1);
roiManager("Add");
roiManager("Show All");
makeLine(x1, y1, x2, y2);
roiManager("add");
run("Clear Results");
//to define dendrite diameter
setTool("line");
waitForUser( "Pause","Draw Line across dendrite diameter");
roiManager("add");
run("Measure");
t = getResult("Length",0);
Diam = t*p
run("Clear Results");
//to define spine location coordinates
setTool("multipoint");
waitForUser( "Pause","Select Spines");
roiManager("add");
run("Measure");
n = nResults;
i=1;
count=0;
do {
x = getResult("X",i-1);
y = getResult("Y",i-1);
Dm = (y1-y2)/(x1-x2);
Dc = y1-((Dm)*x1);
Sm = -(1/Dm);
Sc = y-(Sm*x);
Xint = -(Dc-Sc)/(Dm-Sm);
Yint = (Dm*Xint)+Dc;
if ((Xint > minOf(x1,x2)) && (Xint < maxOf(x1,x2))) {
makeLine(x, y, Xint, Yint);
roiManager("add");
z = sqrt(pow(x-Xint,2)+pow(y-Yint,2));
if (((z*p)-(0.5*Diam))>0) {
print((z*p)-(0.5*Diam));
} else {
print ("0");
}
count = count+1;
}
i = i+1;
} while(i<=n);
//Calculate spine density
l = (sqrt(pow(x1-x2,2)+pow(y1-y2,2))*p);
d = count/l;
print(d+" - d");
print(l+" - l");
run("Clear Results");
//Saving ROI .zip file
Dialog.create("Save ROI File");
Dialog.addMessage("Enter ROI File Name (without extension)");
Dialog.addString("ROI File Name", "Add a File Name for the ROI set");
Dialog.show();
ROIname = Dialog.getString();
name = getTitle();
dir = getDirectory("image");
path = dir+name+ROIname;
ROIpath = dir+ROIname;
saveAs("Tiff", path);
roiManager("Deselect");
roiManager("Save", ROIpath+".zip");
//Saving data Log
selectWindow("Log");
saveAs("Text",path);
}
macro "red fix" {
roiManager("reset");
run("Clear Results");
setBatchMode("true");
setOption("ScaleConversions",true)
print("\\Clear")
// Load the Homer1c-tdTomato (red) and SEP-GluN1 (green) images
path_red = File.openDialog("Load raw red image");
open(path_red);
w = getWidth();
h = getHeight();
path = getDirectory("image");
if (bitDepth() == 24) {
rename("1");
run("Split Channels");
close("1 (green)");
close("1 (blue)");
}
if (bitDepth() > 8) {
run("8-bit");
}
run("Remove Outliers...", "radius=2 threshold=50 which=Bright");
run("Remove Outliers...", "radius=2 threshold=50 which=Dark");
// Subtract uneven background
//run("Subtract Background...", "rolling=500 separate");
// Save images
selectWindow("_AVG_stack_r.tif");
run("Subtract Background...", "rolling=500 sliding"); // Subtract uneven background
red_fname = File.getName(path_red);
i = lastIndexOf(red_fname,".");
red_fname = substring(red_fname,0,i);
saveAs("Tiff",path+red_fname+"_red");
}