NDPITool in macro problem

batch-processing
plugin
macro
Tags: #<Tag:0x00007fb87cda7140> #<Tag:0x00007fb87cda6f88> #<Tag:0x00007fb87cda6d30>

#1

Hi,
I am ne to the field so my question might be trivial.
I have encounter a problem with implementation of NDPITools plugin in macro.
I would like to open one after another TIF files from chosen folder (files created from .ndpi by software ndpisplit), but the function does not recognize my directory:

dir = getDirectory("Choose a Directory");
list = getFileList(dir);
for(i=0; i<list.length; i++) {
name = dir+list[i];
run("Open TIFF...", "ndpitools=[name]";
// here would be commands that I would like to do on my image)
}

In macro recorder, when I open the tool form the toolbar (Plugins>NDPITools>Open Tiff), the command is for instance:

run("Open TIFF...", "ndpitools=[Z:/New folder/E93_25_(A)_PSR-FG - 2018-05-04 15.28.27_x5_z0.tif]");

It seems that command “ndpitools=[name]” does not recognize the path.

Does anyone know how can I overcome this problem?

Thank you
Michal


#2

@Michal_Mlacki

So… unfortunately, I am not familiar with NDPITools myself, but there are a few things we can check…

Is the tool properly installed and functioning manually?

Regarding batching your macro via scripts…

  1. Have you added print() statements to be sure the correct paths & filenames are being used and concatenated in the correct way?

  2. You can always try this other skeleton of a script for processing .tif files in folders/subfolders (it comes with Fiji’s Script Editor and is found at TemplatesImageJ 1.xExamplesProcess_Folder (IJ1 Macro))

/*
 * Macro template to process multiple images in a folder
 */

#@ File (label = "Input directory", style = "directory") input
#@ File (label = "Output directory", style = "directory") output
#@ String (label = "File suffix", value = ".tif") suffix

// See also Process_Folder.py for a version of this code
// in the Python scripting language.

processFolder(input);

// function to scan folders/subfolders/files to find files with correct suffix
function processFolder(input) {
	list = getFileList(input);
	list = Array.sort(list);
	for (i = 0; i < list.length; i++) {
		if(File.isDirectory(input + File.separator + list[i]))
			processFolder(input + File.separator + list[i]);
		if(endsWith(list[i], suffix))
			processFile(input, output, list[i]);
	}
}

function processFile(input, output, file) {
	// Do the processing here by adding your own code.
	// Leave the print statements until things work, then remove them.
	print("Processing: " + input + File.separator + file);
	print("Saving to: " + output);
}

There are already print statements in there to help de-bug the whole path/filename issue. :slight_smile:

Hope this helps a bit!

eta :slight_smile:


#3

Hi,
I tried and tried and managed (life of the novice) :slight_smile:

Thank you Eta for the suggestion, the function processFolder introduced just after
directory of input folder solved the problem, and my macro is processing files one
after another.

Working piece of my macro looks like:

dir = getDirectory("Choose a Directory");
function processFolder(dir); 
list = getFileList(dir);
for(i=0; i<list.length; i++) {
name = dir+list[i];
run("Open TIFF...", "ndpitools=[name]");
// here would be my commands
}

Michal