-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseparate_time_points.ijm
69 lines (41 loc) · 1.52 KB
/
separate_time_points.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
//================================
//Script to save time points of multichannel Z-stack
//as separate files
//Lin Yangchen
//NUS Centre for Bioimaging Sciences
//1 July 2024
//================================
//entire directory path and file names should have no spaces or special characters in them
//folder should contain only the images to be processed and no other files
//folder should not contain subfolders
//prompts you to select the folder containing the images
dir = getDirectory("choose folder");
//replace backslashes with forward slashes (if using Windows)
dir = replace(dir, "\\", "/");
//get the list of files in the folder
filelist = getFileList(dir);
setBatchMode(true); //do not display images during execution
count = 0;
for (i = 0; i < filelist.length; i++)
{
count = count + 1;
print("processing " + filelist[i] + " (dataset " + count + " of " + filelist.length + ")");
open(dir + filelist[i]);
//how many time points are there?
Stack.getDimensions(width, height, channels, slices, frames);
//create new folder to contain the separated time points
filename = File.nameWithoutExtension;
dest = dir + filename + "_separated/";
File.makeDirectory(dest);
timecount = 0;
for (j = 1; j <= frames; j++)
{
timecount = timecount + 1;
print("processing time point " + timecount + " of " + frames + " in " + filelist[i]);
selectImage(filelist[i]);
run("Duplicate...", "duplicate frames=" + j);
saveAs("Tiff", dest + filename + j);
run("Collect Garbage");
}
}
print("job finished");