Commit 05d699e5 authored by Georgi Tushev's avatar Georgi Tushev
Browse files

fix signed 16 bit issue

parent 61985409
# ScanImageStitching
ScanImage tiles and z-scans stitching
\ No newline at end of file
ScanImage tiles and z-scans stitching
## Fiji
ImageJ2
version: 2.3.0/1.53f
## Plugins
Grid/Collection Stiching version: 1.2
## Running headless script
```
/Users/tushevg/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --ij2 --headless --console --run ScanImageStitching.ijm
```
## ScanImage issue
[issue](https://forum.image.sc/t/converting-16-bit-signed-tiffs-to-16-bit-unsigned/5847/3) signed vs unsigned 16 bit images
/*
* ScanImageStitching macro
* pre-process images with reverse stack order
* Grid/Collection stiching plugin is required
* version 0.1
* Dec 2021
* sciclist@brain.mpg.de
*/
/* choose and close image
* @param: window title
*/
function closeImageByTitle(title)
{
selectWindow(title);
close();
}
/* check pathname for trailing separator
* @param: path of interest
*/
function checkPathSeparator(path)
{
if (!endsWith(path, File.separator))
path = path + File.separator;
return path;
}
/* get all files from direcotry
* @param: input directory
* @param: file extension
*/
function getFileListWithExtension(path, extension)
{
path = checkPathSeparator(path);
listOfFiles = getFileList(path);
listOfExtension = newArray;
i = 0;
for(f = 0; f < listOfFiles.length; f++) {
fileName = listOfFiles[f];
if (endsWith(toLowerCase(fileName), extension)) {
fullFileName = path + fileName;
listOfExtension = Array.concat(listOfExtension, fullFileName);
i++;
}
}
return listOfExtension;
}
/* get all files from direcotry
* @param: output directory
* @param: list of files
*/
function preprocessStacks(path, files)
{
path = checkPathSeparator(path);
for(f = 0; f < files.length; f++) {
showProgress(f, files.length);
fileIn = files[f];
fileName = File.getName(fileIn);
fileTag = substring(fileName, 0, lastIndexOf(fileName, "."));
fileOut = path + fileName;
run("Bio-Formats Windowless Importer", "open="+fileIn);
getMinAndMax(min, max);
setMinAndMax(0, max - min);
print("min: " + min);
print("max: " + max);
getMinAndMax(min, max);
print("new min: " + min);
print("new max: " + max);
//run("Stack to Images");
//selectWindow(fileTag + "-0002");
//saveAs("Tiff", fileOut);
//close();
//closeImageByTitle(fileTag + "-0001");
break;
}
}
macro "ScanImageStitching"
{
// set directories
pathInput = getDirectory("choose a directory");
pathTemp = pathInput + "temp";
pathStitch = pathInput + "stitched";
File.makeDirectory(pathTemp);
File.makeDirectory(pathStitch);
// grab all files for stitching
filesList = getFileListWithExtension(pathInput, ".tif");
// pre-process
setBatchMode(false);
preprocessStacks(pathTemp, filesList);
setBatchMode(false);
print("pathInput: " + pathInput);
print("pathTemp: " + pathTemp);
print("pathStitch: " + pathStitch);
print("files: " + filesList.length);
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment