Install Atlas Toolkit plugin

Hi,

After several attempts to install the Atlas Toolkit (https://imagej.net/Atlas_Toolkit), i can’t find a solution. I have tried installing it on the latest version of Fiji (1.52p), as well as the versions of 2015 and 2014 (Linux). Each time i use the plugin, i get the following Command text :
image

The plugin is issued each time at the same step :
image

Could you help me with my issue, please ?

Thank you

@Orphel

I believe @GrocottLab is the best person to assist you in this…

1 Like

Thanks for the heads-up @etadobson

1 Like

@Orphel

Many apologies for this issue. It’s one I’ve encountered myself on my Linux (Ubuntu) box. I’m new to Linux and haven’t had a chance to troubleshoot this yet. The plugin still works ok on my MacBook, so I’m not sure what the problem is at this point.

I’m working on a paper at the moment, but will try to fix this when I can. If you don’t have access to a Mac or Windows machine, I could try registering your data for you when I’m back in the office. Might give you a quick idea if it’s worth pursuing.

2 Likes

@GrocottLab

Thank you for your reply.
Actually, i get the same error messages on Windows…

For now, i am performing tests on smaller files which are a cylinder made from Segmentation Editor. One of the 2 image sequences is moved by 5 pixels from the original.

I am wondering if i am not using the plugin wrongly.

Thank you for your help !

image
image

Here are some screeshots from my trial on Windows (ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_172).

1 Like

@Orphel

I had a go a registering the test data that’s included with the paper (zip file here: https://static-content.springer.com/esm/art%3A10.1038%2Fsrep20732/MediaObjects/41598_2016_BFsrep20732_MOESM8_ESM.zip)

This works fine on both my MacBook and Ubuntu workstation. However, I was previously experiencing the same issue with Ubuntu, so something has changed with that machine to make it work again. So, the issue may be with your Fiji environment.

We’re running the same ImageJ version on all three machines: ImageJ 1.52p.

Both machines that have/had the issue (your Windows 10 and my Ubuntu machine) are running the same Java 8 (Java 1.8.0_172), whereas my Mac never had this issue and is currently running Java 1.8.0_201.

From your screenshot I can see the exception is being triggered by the bUnwarpJ plugin, which Atlas Toolkit is built on. So, I’m wondering if it might be a clash between the bUnwarpJ version and the specific Java 8 version as the two machines we know have/had the issue are using the same Java (1.8.0_172); one of the regular bUnwarpJ updates may explain why my Ubuntu machine is now working.

Could you check to see which version of the bUnwarpJ plugin you’re currently using?

  • Click the Fiji ‘Help’ menu
  • Click ‘About Plugins’
  • Click ‘About bUnwaprJ…’

Both my Mac and Ubuntu machines are running bUnwarpJ 2.6.12.

If you’re running an older version of bUnwarpJ, you could try updating this (Help>Update…) and see if that fixes the problem.

If it still doesn’t work, you could try registering the test data from the paper (link above) in case it’s an issue with your image stacks.

Please let me know how you get on.

2 Likes

@GrocottLab

Thank you for your reply !

I have checked the bUnwarpJ plugin : its version is the same as you (both on Windows and Linux) :
image

On Linux
So, i have tried to register the test data from your paper on my Linux machine. I have tried with both the version of Atlas Toolkit i had and the version from your folder.
Both times, i ended up with the same error message :

Here is the log file text :
1st part :


Last part :

And here is a picture of the running plugin, where it has frozen :
image

On Windows, the plugin worked and i obtained the same results as expected.
So, i tried again with my own test data. Changing the files from ImageSequence to Tiff files made the difference : the plugin worked properly.
However, my Windows machine is not as strong as my Linux one, so it would be really appreciated that the plugin worked on Linux ! I’ll work with what i have for now !

Thank you for your help !

1 Like

@Orphel

I’m glad you got it working on your Windows machine.

I agree it would be good to find and resolve the underlying problem. Would you be able to share the image stacks that are still triggering this exception with Linux? Hopefully I can use them to reproduce the issue on one of my machines as a first step.

Edit: I found some stacks of my own that recreate the issue on my Linux box. Hopefully I can track down the bug.

@Orphel

I believe I may have found the source of the bug and can suggest a workaround for your Linux machine.

POSSIBLE CAUSE:
To make good use of multiple CPU cores, the bUnwarpJ plugin (specifically the applyTransformationMT() method of the MiscTools class; https://github.com/fiji/bUnwarpJ/blame/master/src/main/java/bunwarpj/MiscTools.java#L3072-L3096) chops an image into several smaller images that can be processed in parallel. I’m thinking that rounding errors might sometimes occur when calculating the number and dimensions of the smaller images pieces (https://github.com/fiji/bUnwarpJ/blame/master/src/main/java/bunwarpj/MiscTools.java#L3076). Some combinations of image dimensions and thread counts might result in a negative height for one of the smaller image pieces, resulting in the NegativeSizeArray exception (specifically if i*blockHeight > targetHeight; https://github.com/fiji/bUnwarpJ/blame/master/src/main/java/bunwarpj/MiscTools.java#L3092). Differences in thread counts (logical cores) between different machines would then explain why the exception only arises on some machines and not others.

SUGGESTED WORKAROUND:
To avoid these possible rounding errors, you could ensure that each of the xyz dimensions of each of your stacks are an exact multiple of the thread count for whichever machine you happen to be using. E.g. my MacBook has 6 cores (= 12 threads thanks to hyper-threading), whereas my Linux machine has 20 cores (= 40 threads). Note that bUnwarpJ bypasses the number of threads specified in “Edit>Options>Memory & Threads” and asks the Java Runtime how many threads to use directly. The x & y dimensions can be adjusted either by resizing the stack, or by adding/removing pixels around the periphery via “Image>Adjust>Canvas Size…”. The z dimension can be adjusted via “Image>Stacks>Add Slice” or “Image>Stacks>Delete Slice”. Please let me know if this works for you.

PROPER FIX:
I will verify that the suspected rounding error is indeed actual cause. If so, I will then try to find an alternative way of working the math inside MiscTools.applyTransformMT() method of bUnwarpJ and suggest a fix.

Hope this helps.

2 Likes

@iarganda
Please would it be possible to make the following fix in MiscTools.applyTransformationMT() in bUnwarpJ?

Currently, lines 3077-3078 and presumably lines 3158-3159 for colour images (https://github.com/fiji/bUnwarpJ/blame/master/src/main/java/bunwarpj/MiscTools.java#L3077-L3078; https://github.com/fiji/bUnwarpJ/blame/master/src/main/java/bunwarpj/MiscTools.java#L3158-L3159)
are sometimes resulting in a negative image height for the last thread so that a NegativeArraySizeException is thrown when the FloatProcessor constructor is called in line 3096.

Commenting out lines 3077-3078 appears to fix this issue.

I tested the math with the following standalone plugin code:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.frame.*;

public class Math_test_for_bUnwarpJ implements PlugIn {

	public void run(String arg) {

		int targetHeight = 327;
		int targetWidth = 500;
		IJ.log("targetHeight = 327");
		IJ.log("nProc = 40\n");

		IJ.log("### Old Method:###");
		
		// Check the number of processors in the computer 
		int nproc = 40; //Runtime.getRuntime().availableProcessors();

		// We will use threads to display parts of the output image
		int block_height = targetHeight / nproc;
		if (targetHeight % 2 != 0) 
			block_height++;
		IJ.log("block_height == " + block_height);
		
		int nThreads = nproc; 			

		//Thread[] threads  = new Thread[nThreads];
		Rectangle[] rects = new Rectangle[nThreads];
		//FloatProcessor[] fp_tile = new FloatProcessor[nThreads];
		for (int i=0; i<nThreads; i++) 
		{
			// last block size is the rest of the window
			int y_start = i*block_height;

			if (nThreads-1 == i) {
				block_height = targetHeight - i*block_height;
				IJ.log("Last block_height == " + block_height);
			}
			rects[i] = new Rectangle(0, y_start, targetWidth, block_height);

			// This is the line that throws a NegativeArraySizeException:
			//fp_tile[i] = new FloatProcessor(rects[i].width, rects[i].height);

			// Write numbers to log
			//IJ.log("rects[" + i +"].width == " + rects[i].width + "; rects[" + i +"].height == " + rects[i].height);

			//threads[i] = new Thread(new GrayscaleApplyTransformTile(swx, swy, source, 
			//											targetWidth, targetHeight, intervals,															 
			//											rects[i], fp_tile[i]));
			//threads[i].start();
		}

		IJ.log("\n### New Method:###");
	
		// Calc blockHeight
		block_height = targetHeight / nproc;
		//if (targetHeight % 2 != 0) 
		//	block_height++;
		IJ.log("block_height == " + block_height);
		
		// Check the number of processors in the computer 
		nproc = 40; //Runtime.getRuntime().availableProcessors();

		// We will use threads to display parts of the output image
		block_height = targetHeight / nproc;
		//if (targetHeight % 2 != 0) 
		//	block_height++;

		nThreads = nproc; 			

		rects = new Rectangle[nThreads];

		for (int i=0; i<nThreads; i++) 
		{
			// last block size is the rest of the window
			int y_start = i*block_height;

			if (nThreads-1 == i) {
				block_height = targetHeight - i*block_height;
				IJ.log("Last block_height == " + block_height);
			}
			rects[i] = new Rectangle(0, y_start, targetWidth, block_height);

			// This is the line that throws a NegativeArraySizeException:
			//fp_tile[i] = new FloatProcessor(rects[i].width, rects[i].height);

			// Write numbers to log
			//IJ.log("rects[" + i +"].width == " + rects[i].width + "; rects[" + i +"].height == " + rects[i].height);
		}
	}

}

which gives the following output:

Many thanks in advance.