-
Notifications
You must be signed in to change notification settings - Fork 0
/
seriesDapiNd22tif.ijm
73 lines (60 loc) · 1.94 KB
/
seriesDapiNd22tif.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
// save DAPI channel from the series files each of them
// is the stack with 4 channels in tif format
// DAPI is 3 channel (0-index!)s
// Close all open tif's and nd2's
close("*.tif");
close("*.nd2");
// run bio-format extension
run("Bio-Formats Macro Extensions");
// don't show images
setBatchMode(true);
// DAPI is always the third channel (0-index!)
DAPI_index = 3;
// Define Input Folder
input = getDirectory("Select a Directory for import");
// Define Output Folder
output = getDirectory("Select a Directory for output"); // "/Users/kkolyva/Desktop/test_f/d/";
// Get list of files
filenames = getFileList(input);
Array.sort(filenames);
// image for testing
// img = "/Volumes/Samsung_T3/2017-05-22_smFISH-rex1-deletion/N2_DPY-23_wdr5.5_mdh-1_002.nd2";
for (iFile = 0; iFile < filenames.length; ++iFile){
img = input + filenames[iFile];
filename = filenames[iFile];
// work only on the nd2 files
if (endsWith(filename, ".nd2")){
// image path
print(img);
// get the metadata of the file
Ext.setId(img);
// get the number of images (series)
Ext.getSeriesCount(nSeries);
// count number of leading zeros
numZeros = 0;
tmp = nSeries;
while (tmp > 0){
tmp = floor(tmp / 10);
numZeros++;
}
// iterate over all images in the series
for (iSeries = 1; iSeries <= nSeries; iSeries++){
print("Processing series #" + iSeries);
run("Bio-Formats Importer", "open=[" + img + "] color_mode=Default view=Hyperstack stack_order=XYCZT series_" + iSeries + " split_channels");
// choose series
Ext.setSeries(iSeries - 1);
// single series omage should be processed separetely
if (nSeries == 1){
title = filename + " - C=" + DAPI_index;
}
else{
title = filename + " - " + filename + " (series " + IJ.pad(iSeries, numZeros) + ") "+ "- C=" + DAPI_index;
}
print(title);
selectWindow(title);
saveAs("Tiff", output + title + ".tif");
Ext.close();
showProgress(iSeries, nSeries);
}
}
}