NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug.

The Fiji project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Bug 1000 - "images to stack" does not work
"images to stack" does not work
Status: RESOLVED WONTFIX
Product: Fiji
Classification: Unclassified
Component: Plugins
unspecified
Macintosh Mac OS
: P4 normal
Assigned To: ImageJ Bugs Mailing List
Depends on:
Blocks:
 
Reported: 2015-02-05 09:35 CST by Ferdinando Pucci
Modified: 2015-02-06 14:01 CST
3 users (show)

See Also:


Attachments
image properties (223.01 KB, image/png)
2015-02-05 12:16 CST, Ferdinando Pucci
error (118.46 KB, image/png)
2015-02-05 12:16 CST, Ferdinando Pucci
img properties (454.41 KB, image/png)
2015-02-05 14:03 CST, Ferdinando Pucci
error (190.49 KB, image/png)
2015-02-05 14:03 CST, Ferdinando Pucci

Description Ferdinando Pucci 2015-02-05 09:35:41 CST
Although I do have more than 2 images open I get the "There must be at least two images open" error.

Information about your version of Java:

  os.arch => x86_64
  os.name => Mac OS X
  os.version => 10.10.1
  java.version => 1.6.0_65
  java.vendor => Apple Inc.
  java.runtime.name => Java(TM) SE Runtime Environment
  java.runtime.version => 1.6.0_65-b14-466.1-11M4716
  java.vm.name => Java HotSpot(TM) 64-Bit Server VM
  java.vm.version => 20.65-b04-466.1
  java.vm.vendor => Apple Inc.
  java.vm.info => mixed mode
  java.awt.graphicsenv => apple.awt.CGraphicsEnvironment
  java.specification.name => Java Platform API Specification
  java.specification.version => 1.6
  sun.cpu.endian => little
  sun.desktop => null
  file.separator => /

The up-to-date check says: CHECK_TURNED_OFF

Information relevant to JAVA_HOME related problems:

  JAVA_HOME is set to: null
  imagej.dir => /Applications/Fiji.app

Information about the version of each plugin:

Activated update sites:
ImageJ: http://update.imagej.net/ (last check:20150203171720)
Fiji: http://fiji.sc/update/ (last check:20150204162755)

Files not up-to-date:
  424f128a (MODIFIED) 20150205094843 Contents/Info.plist
  b6bf3817 (OBSOLETE_UNINSTALLED) 20140214180410 jars/edu_mines_jtk.jar
  25895ad6 (OBSOLETE_UNINSTALLED) 20141211164331 jars/imglib2-ops-2.0.0-beta-26.jar
  8c636e50 (OBSOLETE_UNINSTALLED) 20140214180410 jars/jai_codec.jar
  717dd8e0 (OBSOLETE_UNINSTALLED) 20140214180410 jars/jai_core.jar
  1ad3be0d (LOCAL_ONLY) 20140214180410 jars/jpedalSTD.jar
  617c3507 (LOCAL_ONLY) 20140513152031 plugins/QuickTime_Plugins.jar
Comment 1 Wayne Rasband 2015-02-05 11:39:10 CST
P;ease provide a small test macro that reproduces the problem. The following macro, which opens three images and runs "Images to Stack", works as expected.

  run("Close All");
  run("Boats (356K)");
  run("Bridge (174K)");
  run("Dot Blot (7K)");
  run("Images to Stack", "method=[Copy (center)] name=Stack use");
Comment 2 Ferdinando Pucci 2015-02-05 12:14:05 CST
I have no macro, please see attachments, thanks
Comment 3 Ferdinando Pucci 2015-02-05 12:16:34 CST
Created attachment 230
image properties
Comment 4 Ferdinando Pucci 2015-02-05 12:16:46 CST
Created attachment 231
error
Comment 5 Curtis Rueden 2015-02-05 12:18:51 CST
Wayne is asking you to please create such a macro, which illustrates the problem you are experiencing. You can use the Macro Recorder to create one easily:

http://imagej.net/Macros#The_recorder
Comment 6 Curtis Rueden 2015-02-05 12:22:04 CST
Based on your screenshots, I created a macro that reproduces the problem on my system:

newImage("5x7_000001.tif", "16-bit random", 2273, 3570, 4);
run("Properties...", "channels=1 slices=1 frames=4 unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000");
newImage("5x7_000002.tif", "16-bit random", 2273, 3181, 4);
run("Properties...", "channels=1 slices=1 frames=4 unit=pixel pixel_width=1.0000 pixel_height=1.0000 voxel_depth=1.0000");
run("Images to Stack");
Comment 7 Wayne Rasband 2015-02-05 12:34:05 CST
The "Images to Stack" command does not work with stacks as input. Instead, use the Image>Stacks>Tools>Concatenate command,
Comment 8 Curtis Rueden 2015-02-05 12:40:23 CST
Thanks Wayne!

Here is a patch that tells the user this when such a circumstance occurs:

diff --git a/src/main/java/ij/plugin/ImagesToStack.java b/src/main/java/ij/plugin/ImagesToStack.java
index e84d924..d72dc30 100644
--- a/src/main/java/ij/plugin/ImagesToStack.java
+++ b/src/main/java/ij/plugin/ImagesToStack.java
@@ -38,15 +38,22 @@ public class ImagesToStack implements PlugIn {
                        return;
                }

-               int count = 0;
+               int count = 0, stackCount = 0;
                image = new ImagePlus[wList.length];
                for (int i=0; i<wList.length; i++) {
                        ImagePlus imp = WindowManager.getImage(wList[i]);
                        if (imp.getStackSize()==1)
                                image[count++] = imp;
+                       else
+                               stackCount++;
                }
                if (count<2) {
-                       IJ.error("Images to Stack", "There must be at least two open images.");
+                       if (stackCount >= 2) {
+                               IJ.error("Images to Stack", "The \"Images to Stack\" command " +
+                                       "does not work with stacks as input.\nInstead, use the " +
+                                       "Image>Stacks>Tools>Concatenate command.");
+                       }
+                       else IJ.error("Images to Stack", "There must be at least two open images.");
                        return;
                }
Comment 9 Wayne Rasband 2015-02-05 14:03:22 CST
Thanks Curtis. Your patch that provides a more informative error message is in the latest ImageJ daily build (1.49p8).
Comment 10 Ferdinando Pucci 2015-02-05 14:03:25 CST
Created attachment 232
img properties
Comment 11 Ferdinando Pucci 2015-02-05 14:03:39 CST
Created attachment 233
error
Comment 12 Ferdinando Pucci 2015-02-05 14:05:27 CST
thank you all.

I understand that the "Images to stack" command does not work with multi frames images.  Upon transforming into multichannel images, the command still do not work.  Please see new attachments thanks
Comment 13 Wayne Rasband 2015-02-05 14:18:55 CST
The "Images to Stack" command does not currently work with multi-channel images. You need to use the Image>Stack>Tools>Concatenate command.
Comment 14 Ferdinando Pucci 2015-02-05 14:24:16 CST
Thanks Wayne.  

I cannot use "concatenate" because my images (about 100) have all slightly different dimensions (they come from grid stitching).

Afaik only "Images to stack" works with images of different sizes.

Best,
Comment 15 Wayne Rasband 2015-02-05 23:29:00 CST
Run the following macro before using the Concatenate command. It zero pads all open images so that they have the same dimensions.

  maxWidth = 0;
  maxHeight = 0;
  for (i=1; i<=nImages; i++) {
     selectImage(i);
     if (getWidth>maxWidth) maxWidth=getWidth;
     if (getHeight>maxHeight) maxHeight=getHeight;
  }
  for (i=1; i<=nImages; i++) {
     selectImage(i);
     if (getWidth!=maxWidth || getHeight!=maxHeight)
        run("Canvas Size...", "width=&maxWidth height=&maxHeight position=Center zero");
  }
Comment 16 Wayne Rasband 2015-02-06 11:28:29 CST
The Image>Stacks>Tools>Concatenate command works with images of different dimensions in the latest ImageJ daily build (1.49p9). You can upgrade by using the Help>Update ImageJ command and selecting "daily build" from the drop down menu.
Comment 17 Ferdinando Pucci 2015-02-06 14:01:56 CST
Wayne, 
Thank you so much, this is great!
Best,