-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTEM_Ser_dm3_batch_convert.ijm
80 lines (70 loc) · 2.64 KB
/
TEM_Ser_dm3_batch_convert.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
// Copyright 2018-2023 Zhou XU
//
// This file is part of ImageJ plugin EM-tool.
//
// EM-tool is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// EM-tool is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with EM-tool. If not, see <http://www.gnu.org/licenses/>.
//
//
// Batch convert TIA or Gatan dm3 image file to tiff
// by Zhou XU
// 2020/05/05
// at Monash Centre for Electron Microscopy
// Windows 10 Enterprise Ver. 1803
// ImageJ ver. 1.52p
List.setCommands;
if (List.get("TIA Reader")!="") {
// Check to make sure TIA reader plugin is installed
//open directory of images
input = getDirectory("location where images are stored");
output = getDirectory("Location for results");
// determine number of Files of given FileFormat
list = getFileList(input);
ImgNumber=0;
for (i=0; i<list.length; i=i+1) {
if (endsWith(list[i], ".ser")) {
ImgNumber=ImgNumber+1;
filename = input + list[i];
print(filename);
run("TIA Reader", ".ser-reader...=filename");
// get the pixel size and unit of image, TIA reader should have set the scale when import in
getPixelSize (unit, pixelWidth, pixelHeight);
imageWidth = getWidth();
HFW = imageWidth * pixelWidth;
filename_short = substring(list[i], 0, lastIndexOf(list[i], "."));
exportFile = output + filename_short +"_HFW"+ HFW + unit + ".tif";
saveAs("Tiff", exportFile);
run("Close All");
}
else if (endsWith(list[i], ".dm3")) {
// for gatan dm3 files
ImgNumber=ImgNumber+1;
filename = input + list[i];
print(filename);
open(filename);
// get the pixel size and unit of image, TIA reader should have set the scale when import in
getPixelSize (unit, pixelWidth, pixelHeight);
imageWidth = getWidth();
HFW = imageWidth * pixelWidth;
filename_short = substring(list[i], 0, lastIndexOf(list[i], "."));
exportFile = output + filename_short +"_HFW"+ HFW + unit + ".tif";
saveAs("Tiff", exportFile);
run("Close All");
}
}
}
else {
Dialog.create("Error");
Dialog.addMessage("TIA Reader plugin is not intalled, \nplease download and install from \nhttps://imagej.nih.gov/ij/plugins/tia-reader.html \n ");
//Dialog.addHelp("<html>https://imagej.nih.gov/ij/plugins/tia-reader.html");
Dialog.show();