public class Hyperstack_Maker extends BatchDialog implements org.scijava.command.Command
The plugin (and subclasses of this plugin) can be called either via their menu entry, by calling Hyperstack_Maker.run("") (display the GUI) or by running the macro-recorded command ("preconfigured headless execution").
Macro-recording is automatically implemented thanks to the use of BatchDialog (a custom subclass of GenericDialog).
The generated hyperstack use VirtualStacks for efficient data-loading from disk.
The pixel size (Calibration) is automatically set according to the metadata in the filename, for images of original dimensions (2048 x 2048, to make sure no binning was done).
With Z-stack, the pixel size is also set for the Z-dimension. It is reported as the pixel depth, although it is NOT the depth-of-focus, but the spacing between slices.
The depth for the full stack volume is thus not as reported in Image > Show Info..., but the reported value - 1 pixel "depth".
With multiple channels, colour LUT are automatically associated to the corresponding microscope channel of the image.
Default colour LUTs are provided, but the mapping microscope channel<->LUT-colour can be customised either programmatically with setDefaultChannelsLut(String[])
or setChannelLut(int, String)
.
Or via the dedicated plugin in ACQUIFER > Settings > Set_Channel_Colors.py
Note about headless execution
While the plugin can be executed in headless mode, since displaying of images is not supported it has limited benefit.
The saving of the projected images can be performed though.
The plugin can also be called via the command line without the --headless tag.
This works with the --ij2 --console --run myMacro.ijm for instance, but only for a single call.
This first call opens Fiji and will run the macro, eventually calling the plugin and showing the images.
Calling a second time the command in the same command prompt currently fails though, if the single instance listener option is on (Edit > Options > Misc).
Modifier and Type | Class and Description |
---|---|
static class |
Hyperstack_Maker.DisplayMode
Display mode for hyperstack with multiple channels.
|
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType
java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
Modifier and Type | Field and Description |
---|---|
protected static String[] |
channelsLuts
User-defined LUT names to use for the IM channels.
|
protected static double |
displayMagnification
Relative size of the image window displayed in Fiji in %.
|
protected acquifer.core.ImageSeries[] |
groupedImageInfos |
protected acquifer.core.im.MetadataParser |
metadataParser |
String[] |
METHODS
Set of projection method for the stack
|
protected ij.ImagePlus |
proj
Stack projection
|
protected String |
projDir
Where to save the projection if saveProjection is true
|
protected boolean |
projectStack
If yes or no the stack should be projected
|
protected String |
projMethod
The selected projection method as a string
|
protected static double |
saturation
Percentage of pixels that will be saturated when enhancing the contrast.
|
protected boolean |
saveProjection
If the projection should be saved
|
protected boolean |
saveStack
If yes or no, the stack should be saved.
|
protected boolean |
showProjection
Show stack projection (yes/no)
|
protected boolean |
showProjectionTickbox
If a tick box should be shown in the GUI to ask the user about yes/no project stack
|
protected boolean |
showStack
If yes or no the stack should be shown
|
protected ij.ImagePlus |
stack
Stack/hyperstack generated by the plugin at each iteration (each well).
|
protected String |
stackDir
Where the stack should be saved if saveStack is true.
|
protected int |
startSlice |
protected int |
stopSlice |
protected boolean |
useCustomRange
If a custom Z-slice range should be used for projection
|
protected boolean |
useVirtual
If VirtualStack should be used to display the stack.
|
filenameFilter, headless, imageDirectory, labelChannels, labelSubposition, labelTimepoint, labelZ, listChannels, listSubPositions, listTimepoints, listWells, listZslices, nColumns, nGroupCheckboxes, nRows, plate, rowSelectionCheckboxes
checkbox, choice, defaultChoiceIndexes, defaultStrings, defaultText, defaultValues, numberField, radioButtonGroups, slider, stringField, textArea1, textArea2, theLabel
Constructor and Description |
---|
Hyperstack_Maker(String title,
acquifer.core.im.FilenameFilter filenameFilter)
Initialise the hyperstack maker plugin with the associated GUI window title, (ie IM03/4) metadataParser and fileUtils.
|
Modifier and Type | Method and Description |
---|---|
protected void |
composeGUI()
Compose the right panel of the plugin GUI.
|
static ij.gui.ImageWindow |
createImageWindow(ij.ImagePlus imp,
double magnification)
Create an image window for the display of an image at a predefined display magnification (for ImageJ>=1.53i27).
|
boolean |
executedOnce()
Method called once in the
run() method before loopBody(ImageSeries) is called for each stack. |
static String[] |
getChannelsLuts()
Return the list of colours LUT associated to the microscope channels.
|
static String |
getLutNameForChannel(int channel)
Return the name of the color-LUT associated to a given microscope channel (between 1 and 6).
|
static String[] |
getLuts()
Returns the list of LUTs advised for the display of hyperstacks channels.
|
static ij.ImagePlus[] |
groupAsHyperStacks(acquifer.core.Dataset dataset,
acquifer.core.im.MetadataParser metadataParser)
Make a list of hyperstacks from the ImageSeries contained in a dataset.
|
static boolean |
isMultiDimensional(ij.ImagePlus stack)
Return true if the stack has at least 2-dimension sliders.
|
static boolean |
isOneDimensional(ij.ImagePlus imp)
Check if an ImagePlus is a 1D dimensional stack (ie single dimension slider).
|
boolean |
loopBody(acquifer.core.ImageSeries imageSeries)
Define what is executed for each list of images representing a hyperstack.
|
static ij.ImagePlus |
makeHyperStack(acquifer.core.ImageSeries imageSeries,
acquifer.core.im.MetadataParser metadataParser)
Create a hyperstack from an imageSeries adding pixel size read from the tiff header.
|
ij.ImagePlus |
makeHyperStack(acquifer.core.im.Metadata[] subList)
Deprecated.
|
static ij.ImagePlus |
makeHyperStack(String title,
ij.VirtualStack vStack,
int nChannels,
int nZslices,
int nTimepoints)
Same as
makeHyperStack(String, VirtualStack, int, int, int, DisplayMode) but uses the display mode set in preference (hyperstack.displayMode). |
static ij.ImagePlus |
makeHyperStack(String title,
ij.VirtualStack vStack,
int nChannels,
int nZslices,
int nTimepoints,
Hyperstack_Maker.DisplayMode displayMode)
Make a multi-dimensional hyperstack from a 1D virtual stack of disk-resident images.
|
static ij.VirtualStack |
makeVirtualStack(acquifer.core.im.Metadata[] listImageInfos)
Returns a 1D VirtualStack from a list of ImageInfos, for a given well and subposition.
|
void |
readGuiInputs()
Read the GUI inputs, in a macro-recordable way : storing them as fields of the class.
|
void |
renameProjectedSlices(ij.ImagePlus stack,
ij.ImagePlus proj,
String projMethod,
boolean useCustomRange,
int firstSlice)
When the result of the projection is a stack, rename the slice labels according to original stack.
|
static void |
resetDisplayRange(ij.ImagePlus hyperstack)
Auto-scale display range by histogram stretching, same as Process>Enhance Contrast or Image>Adjust>Brightness/Contrast.
|
void |
run()
Call the hyperstack plugin to generate hyperstacks from list of IM files.
|
static void |
setChannelLut(int channel,
String lutName)
Set the Look Up Table (LUT) for a given channel of the microscope.
|
static void |
setContrastSaturation(double percentSaturation)
Set the saturation used to automatically enhance contrast of stacks generated with the plugin.
|
static void |
setDefaultChannelsLut(String[] lutNames)
Set the Look Up Tables used to rendered the IM channels in hyperstacks.
|
static void |
setDefaultDisplayMagnification(double magnification)
Set default magnification used by the hyperstack plugin for the display of new images.
|
static void |
setDefaultSliderPositions(ij.ImagePlus imp)
Set the slider position to the default values defined in settings
|
static void |
setHyperStackDisplayMode(Hyperstack_Maker.DisplayMode mode)
Set the default display mode for hyperstack when nChannels>1.
|
static void |
setLUTs(ij.ImagePlus imp,
Collection<Integer> setChannels)
Apply the LUT defined in settings to the channels of the provided imp (for ImageJ>=1.53).
|
static void |
showHyperStacks(acquifer.core.Dataset dataset,
acquifer.core.im.MetadataParser metadataParser)
Display the hyperstack(s) of a dataset.
|
static void |
updateDisplayMagnification(ij.ImagePlus imp,
double magnification)
Set the magnification-level of an image already displayed.
|
static boolean |
validateCustomRange(ij.ImagePlus stack,
int start,
int stop)
Verify that the custom range for projection with a substack fits in the actual stack dimensions.
|
boolean |
validateInputs()
Check values entered in the dialog, to make sure they make sense (no negative...).
|
actionPerformed, addDefaultDirectoryInput, addMessageBold, convertToIntegerSet, createAndSetDefaultDirectory, escapePressed, getBoldFont, getChannels, getCheckboxesForColumn, getCheckboxGroup, getCurrentImageDirectory, getDefaultInputs, getFont, getHeaderCheckboxes, getImageDirectory, getMatchingDataset, getMatchingDataset, getMatchingDataset, getNextStringAsIntegers, getSavedWellCheckboxState, getSubpositions, getTimepoints, getWellCheckboxes, getWells, getZslice, itemStateChanged, readMacroContent, saveDefaultParameters, saveWellCheckboxState, setOKLabel, showDialog, textValueChanged
addButton, addComponent, addComponent, addDirectoryField, addDirectoryField, addDirectoryOrFileField, addDirectoryOrFileField, addFileField, addFileField, addImage, addImage, addImage, addImageChoice, addStringField, createImageIcon, getConstraints, getNextImage, keyPressed, keyReleased, keyTyped
addCheckbox, addCheckboxGroup, addCheckboxGroup, addChoice, addDialogListener, addEnumChoice, addHelp, addImage, addMessage, addMessage, addMessage, addNumericField, addNumericField, addNumericField, addPanel, addPanel, addPreviewCheckbox, addPreviewCheckbox, addRadioButtonGroup, addSlider, addSlider, addStringField, addTextAreas, addToSameRow, adjustmentValueChanged, centerDialog, dispose, enableYesNoCancel, enableYesNoCancel, focusGained, focusLost, getButtons, getCheckboxes, getChoices, getErrorMessage, getInsets, getInstance, getLabel, getMessage, getNextBoolean, getNextChoice, getNextChoiceIndex, getNextEnumChoice, getNextNumber, getNextRadioButton, getNextString, getNextText, getNumericFields, getPreviewCheckbox, getRadioButtonGroups, getSliders, getStringFields, getTextArea1, getTextArea2, getValue, hideCancelButton, invalidNumber, isMacro, isPreviewActive, paint, parseDouble, previewRunning, repaint, setCancelLabel, setDefaultString, setEchoChar, setFont, setHelpLabel, setInsets, setLocation, setSmartRecording, setup, wasCanceled, wasOKed, windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
addNotify, getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBack
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, update, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
protected acquifer.core.im.MetadataParser metadataParser
protected acquifer.core.ImageSeries[] groupedImageInfos
protected boolean showStack
protected boolean useVirtual
protected boolean saveStack
protected String stackDir
protected boolean projectStack
protected boolean showProjectionTickbox
protected boolean showProjection
protected boolean saveProjection
public final String[] METHODS
protected String projMethod
protected boolean useCustomRange
protected int startSlice
protected int stopSlice
protected String projDir
protected ij.ImagePlus stack
protected ij.ImagePlus proj
protected static double saturation
protected static double displayMagnification
protected static String[] channelsLuts
public Hyperstack_Maker(String title, acquifer.core.im.FilenameFilter filenameFilter)
filenameFilter
- an instance of filenameFilter specific to the relevant IM version, used to keep only IM image files.protected void composeGUI()
public void run()
loopBody(ImageSeries)
for each of them.loopBody(ImageSeries)
makes a hyperstack and if selected a Z-projection and display them if selected.run
in interface Runnable
public void readGuiInputs()
public boolean validateInputs()
BatchDialog
validateInputs
in class BatchDialog
public boolean executedOnce()
run()
method before loopBody(ImageSeries)
is called for each stack. public boolean loopBody(acquifer.core.ImageSeries imageSeries)
saveStack
, showStack
..imageSeries
- list of images infos, for a specific well and sub-Positionpublic static ij.VirtualStack makeVirtualStack(acquifer.core.im.Metadata[] listImageInfos) throws loci.formats.FormatException, IOException, IllegalArgumentException
IOException
loci.formats.FormatException
IllegalArgumentException
public static ij.ImagePlus makeHyperStack(String title, ij.VirtualStack vStack, int nChannels, int nZslices, int nTimepoints, Hyperstack_Maker.DisplayMode displayMode)
resetDisplayRange(ImagePlus)
after displaying the resulting hyperstack to auto-adjust the brightness for each channel.title
- title for the output ImagePlusvStack
- nChannels
- the number of channels in the resulting hyperstacknZslices
- the number of Z-slices in the resulting hyperstacknTimepoints
- the number of timepoints in the resulting hyperstackdisplayMode
- when nChannels>1, set the display mode to "grayscale", "color" (1 LUT/channel) or "composite" (1 LUT/channel and overlaid).public static ij.ImagePlus makeHyperStack(String title, ij.VirtualStack vStack, int nChannels, int nZslices, int nTimepoints)
makeHyperStack(String, VirtualStack, int, int, int, DisplayMode)
but uses the display mode set in preference (hyperstack.displayMode). resetDisplayRange(ImagePlus)
after displaying the hyperstack to auto-adjust the brightness for each channel.public static ij.ImagePlus makeHyperStack(acquifer.core.ImageSeries imageSeries, acquifer.core.im.MetadataParser metadataParser) throws IOException
resetDisplayRange(ImagePlus)
after displaying the hyperstack to auto-adjust the brightness for each channel.imageSeries
- images forming a hyperstackmetadataParser
- used to parse the pixel size from the image nameIOException
@Deprecated public ij.ImagePlus makeHyperStack(acquifer.core.im.Metadata[] subList) throws IllegalArgumentException, loci.formats.FormatException, IOException
makeHyperStack(ImageSeries, MetadataParser)
subList
- IOException
loci.formats.FormatException
IllegalArgumentException
public static ij.ImagePlus[] groupAsHyperStacks(acquifer.core.Dataset dataset, acquifer.core.im.MetadataParser metadataParser)
dataset
- a hyperstack will be generated for each ImageSeries in the dataset.metadataParser
- used to parse the pixel size from the image name.public static void showHyperStacks(acquifer.core.Dataset dataset, acquifer.core.im.MetadataParser metadataParser)
public static boolean isMultiDimensional(ij.ImagePlus stack)
public static boolean isOneDimensional(ij.ImagePlus imp)
public static boolean validateCustomRange(ij.ImagePlus stack, int start, int stop)
public void renameProjectedSlices(ij.ImagePlus stack, ij.ImagePlus proj, String projMethod, boolean useCustomRange, int firstSlice)
public static void setDefaultSliderPositions(ij.ImagePlus imp)
public static void setDefaultChannelsLut(String[] lutNames)
getLuts()
returns a list of LUT names advised for channels, but any LUt in IJ.getLuts is actually supported.lutNames
- a list of colour names ex: ["Blue", "Red"...]. The number of colours should not exceed the number of channels (ie max 6).public static void setChannelLut(int channel, String lutName)
getLuts()
to see the list of LUTs advised for rendering of channels (additional channels in IJ.getLuts are supported though).channel
- index of the microscope channel, between 1 and 6 (brightfield)lutName
- name (case sensitive) of a LUT to use for this channel, ex: "Red"public static void setLUTs(ij.ImagePlus imp, Collection<Integer> setChannels)
imp
- hyperstack image for which to set custom LUTsetChannels
- the IM channels contained in this imp. In the imp the IM channels are sorted in reverse order to have the brightfield channel in first position when present (CO6).public static void resetDisplayRange(ij.ImagePlus hyperstack)
NOTE : this function should work well with CompositeImage. It might not work with VirtualStacks as the ImageProcessor are reloaded from disk.
The code below sets the same display range for all slices of a given channel.
Using ContrastEnhancer.stretchHistogram will not work since we are using VirtualStacks by default, instead we use the center slice as reference and set the stack display range to it's min/max.
public static String[] getLuts()
public static String[] getChannelsLuts()
public static String getLutNameForChannel(int channel)
public static void setContrastSaturation(double percentSaturation)
percentSaturation
- between 0 and 100IllegalArgumentException
- if saturation is not between 0 and 100public static ij.gui.ImageWindow createImageWindow(ij.ImagePlus imp, double magnification)
imp
- image for which to create a windowmagnification
- zoom level, e.g 0.5 for 50% (supported for ImageJ>=1.53i27)public static void updateDisplayMagnification(ij.ImagePlus imp, double magnification)
imp
- the image to resizemagnification
- zoom factor (e.g 0.5 = 50%)public static void setDefaultDisplayMagnification(double magnification)
magnification
- between 0 and 1 (ie 0.5 = 50%)public static void setHyperStackDisplayMode(Hyperstack_Maker.DisplayMode mode)