Skip to content

Commit

Permalink
Prompt the user for the stack concatenation axis
Browse files Browse the repository at this point in the history
Closes ome#4126.
  • Loading branch information
melissalinkert committed Apr 17, 2012
1 parent 4c649d0 commit 45e6530
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions components/loci-plugins/src/loci/plugins/in/Concatenator.java
Expand Up @@ -27,6 +27,7 @@ Data Browser and Stack Slicer. Copyright (C) 2005-@year@ Melissa Linkert,

import ij.ImagePlus;
import ij.ImageStack;
import ij.gui.GenericDialog;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -46,6 +47,22 @@ public class Concatenator {
/** Concatenates the list of images as appropriate. */
public List<ImagePlus> concatenate(List<ImagePlus> imps) {

GenericDialog axisDialog = new GenericDialog("Choose concatenation axis");
String[] options = new String[] {"T", "Z", "C"};
axisDialog.addMessage(
"Choose the axis along which to concatenate image planes:");
axisDialog.addChoice("Axis", options, options[0]);
axisDialog.showDialog();

if (axisDialog.wasCanceled()) {
return imps;
}

String axis = axisDialog.getNextChoice();
boolean doAppendT = axis.equals("T");
boolean doAppendZ = axis.equals("Z");
boolean doAppendC = axis.equals("C");

// list of output (possibly concatenated) images
final List<ImagePlus> outputImps = new ArrayList<ImagePlus>();

Expand Down Expand Up @@ -88,14 +105,16 @@ public List<ImagePlus> concatenate(List<ImagePlus> imps) {
outputImp.setStack(outputImp.getTitle(), outputStack);

// update image dimensions
// NB: For now, we prioritize adding to the time points, then
// focal planes, and lastly channels. In some cases, there may be
// multiple compatible dimensions; in the future, we may prompt the
// user to choose the axis for concatenation.
if (canAppendT) outputImp.setDimensions(c, z, t + tSize);
else if (canAppendZ) outputImp.setDimensions(c, z + zSize, t);
else if (canAppendC) outputImp.setDimensions(c + cSize, z, t);
else throw new IllegalStateException("Dimensional mismatch");

if (doAppendT && canAppendT) {
outputImp.setDimensions(c, z, t + tSize);
}
else if (doAppendZ && canAppendZ) {
outputImp.setDimensions(c, z + zSize, t);
}
else if (doAppendC && canAppendC) {
outputImp.setDimensions(c + cSize, z, t);
}

append = true;
break;
Expand Down

1 comment on commit 45e6530

@melissalinkert
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test, attempt to open a multi-series dataset (with uniform sizes) when the "Concatenate stacks when compatible" option is checked. You should eventually be prompted for the axis to which to concatenate.

@ctrueden, would you mind trying this out, as it's something we discussed some time ago?

Please sign in to comment.