Files
nanotom-scripts/Import_VOL_ImageJ_virtual_stack.ijm

74 lines
2.0 KiB
Plaintext

/* README:
* This macro imports a VOL file into ImageJ using the information contained inside the corresponding PCR file. If no PCR is found,
* the user can input the information required to perform the action manually or provide the PCR file.
*
* Execution:
* runMacro("...path.../Import_VOL.ijm"); Opens a selected VOL file
*
* Changelog:
* 2018.01.22 Created MR54
* 2021.03.12 Datos Ac update, Adapted Linenumbers to new header CC54
*
*/
// Select VOL file and extract PCR file name
filePath = File.openDialog("Select VOL file to import");
tempPath = split(filePath,".");
pcrPath = tempPath[0]+".pcr";
pcrSizeX = 0;
pcrSizeY = 0;
pcrSizeZ = 0;
while (pcrSizeX == 0 || pcrSizeY == 0 || pcrSizeZ == 0) {
if (File.exists(pcrPath)) {
// Extract import parameters from pcr file
pcrContent = File.openAsString(pcrPath);
pcrLines = split(pcrContent,"\n");
for (i=0; i<pcrLines.length; i++) {
splitline = split(pcrLines[i],"=");
if (splitline[0] == "Volume_SizeX") {
pcrSizeX = splitline[1];
}
if (splitline[0] == "Volume_SizeY") {
pcrSizeY = splitline[1];
}
if (splitline[0] == "Volume_SizeZ") {
pcrSizeZ = splitline[1];
}
}
print(pcrSizeX);
print(pcrSizeY);
print(pcrSizeZ);
} else {
// No PCR file found
Dialog.create("Error");
Dialog.addMessage("There was no PCR file with the same name found.\nPlease enter the location of the PCR file or enter the dimensions manually.");
Dialog.addNumber("SizeX",0);
Dialog.addNumber("SizeY",0);
Dialog.addNumber("SizeZ",0);
Dialog.addCheckbox("Select PCR file",false);
Dialog.show();
if (Dialog.getCheckbox()== false) {
// Enter manually
pcrSizeX = Dialog.getNumber();
pcrSizeY = Dialog.getNumber();
pcrSizeZ = Dialog.getNumber();
} else {
// Select new path
pcrPath = File.openDialog("Select PCR file to import");
}
}
}
// Import VOL file
//print(filePath);
run("Raw...", "open=["+filePath+"] image=[32-bit Real] width="+pcrSizeX+" height="+pcrSizeY+" offset=0 number="+pcrSizeZ+" gap=0 little-endian use");