Class MultiContrastAnalysisFrame

java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
com.xinapse.util.ImageOrganiserFrame
com.xinapse.util.MultiContrastAnalysisFrame
All Implemented Interfaces:
MessageShower, PreferencesSettable, ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
AbstractDynamicFrame

public abstract class MultiContrastAnalysisFrame extends com.xinapse.util.ImageOrganiserFrame
A JFrame for performing an analysis of images where the contrast changes from one image to the next. Examples include perfusion and DCE-MRI analysis, and time-series registration.
See Also:
  • Field Details

    • ROAM_COMMAND

      public static final String ROAM_COMMAND
      The command string for the roaming response menu item.
      See Also:
    • roamingResponseDialog

      public com.xinapse.util.RoamingResponseDialog roamingResponseDialog
      The RoamingResponseDialog used to display the roaming response, if non-null.
    • imageInputPanel

      public final com.xinapse.util.MultiContrastSelectionPanel imageInputPanel
      The JPanel that contains the input configuration widgets.
  • Constructor Details

    • MultiContrastAnalysisFrame

      public MultiContrastAnalysisFrame(com.xinapse.displayer.ImageDisplayer displayer, String title, String contrastDescription, int defaultNContrasts, String prefsNodeName)
      Creates a new MultiContrastAnalysisFrame connected with a displayer, with the given title.
      Parameters:
      displayer - the ImageDisplayer that displays one of the images to be analysed.
      title - the title of the MultiContrastAnalysisFrame.
      contrastDescription - a description of the type of contrast that varies from one image to the next.
      defaultNContrasts - the default number of contrasts to show on startup.
      prefsNodeName - the node name for the user Preferences node where preferences are stored to set up this MultiContrastAnalysisFrame.
  • Method Details

    • getInputImages

      public ReadableImage[] getInputImages(boolean clearCache) throws InvalidArgumentException
      Returns the set of input images set in this MultiContrastAnalysisFrame.
      Parameters:
      clearCache - true if the cache of input images should be cleared, forcing a new set of ReadableImages to be instantiated. If false, the cached set of input images will be returned, which will cause a problem if the images previously returned have been closed by the application.
      Returns:
      the input images set in this MultiContrastSelectionPanel.
      Throws:
      InvalidArgumentException - if the image(s) have not been set, or if the input image(s) cannot be opened.
    • getNContrasts

      public int getNContrasts() throws InvalidArgumentException
      Returns the number of image contrasts set in this MultiContrastAnalysisFrame.
      Returns:
      the number of contrasts.
      Throws:
      InvalidArgumentException - if the number of contrasts cannot be determined from the input images.
    • getNContrasts

      public static int getNContrasts(ReadableImage[] inputImages, Integer nContrasts, boolean contiguousContrasts, String contrastDescription) throws InvalidArgumentException
      Returns the number of image contrasts in a set of input images.
      Parameters:
      inputImages - the array of input images.
      nContrasts - if non-null, the number of contrasts (which must be supplied in the case of a single input image containing multiple contrasts).
      contiguousContrasts - whether the separate image contrasts are contiguous in the input image(s).
      contrastDescription - a short description of the image contrast.
      Returns:
      the number of contrasts.
      Throws:
      InvalidArgumentException - if the number of contrasts cannot be determined from the input images.
    • getNSliceLocations

      public int getNSliceLocations() throws InvalidArgumentException
      Returns the number of image slice locations for the images set in this MultiContrastAnalysisFrame.
      Returns:
      the number of physical slice locations.
      Throws:
      InvalidArgumentException - if the number of slice locations cannot be determined from the input images.
    • getNSliceLocations

      public static int getNSliceLocations(ReadableImage[] inputImages, Integer nContrasts, boolean contiguousContrasts, String contrastDescription) throws InvalidArgumentException
      Returns the number of physical image slice locations for a set of images.
      Parameters:
      inputImages - the set images.
      nContrasts - the number of different contrasts in the input images.
      contiguousContrasts - a flag which is set to true if the different contrasts are contuguous in the input images, or false if the different slice locations are contuguous.
      contrastDescription - a short description of the image contrast.
      Returns:
      the number of physical slice locations.
      Throws:
      InvalidArgumentException - if the number of slice locations cannot be determined from the input images.
    • getContiguousContrasts

      public boolean getContiguousContrasts()
      Note: getContiguousContrasts has a different meaning, depending on whether a single input image is used, or whether multiple input images are used: For a single input image, getContiguousContrasts() == true indicates that all contrasts for one slice are adjacent, before moving on to the next slice. For multiple input images, it indicates that one image contains all contrasts for one slice location.
      Returns:
      true if contrasts are set to be contiguous; false otherwise.
    • setNContrasts

      public void setNContrasts(int nContrasts)
      Set the number of contrasts.
      Parameters:
      nContrasts - the number of contrasts.
    • isSingleInputImage

      public boolean isSingleInputImage()
      Tests whether there is a single or multiple input images.
      Returns:
      true if there is a single input image; false if there are multiple input images.
    • getXStart

      public abstract float getXStart()
      Returns the minimum x-value for a pop-up plot.
      Returns:
      the minimum x-value.
    • getDeltaX

      public abstract float getDeltaX() throws ParseException
      Returns the δ x-value between adjacent points on a pop-up plot.
      Returns:
      the Δ x-value.
      Throws:
      ParseException - if the x-value between adjacent points cannot be parsed.
    • getXAxisLabel

      public abstract String getXAxisLabel()
      Returns the x-axis label for a pop-up plot.
      Returns:
      the x-axis label.
    • unloadImage

      public void unloadImage()
      Do things that need to be done when the current image is unloaded.
    • addChangeListener

      public void addChangeListener(ChangeListener l)
      Adds a ChangeListener to the MultiContrastAnalysisFrame.
      Parameters:
      l - the listener to be added.
    • removeChangeListener

      public void removeChangeListener(ChangeListener l)
      Remove a ChangeListener from the MultiContrastAnalysisFrame.
      Parameters:
      l - the listener to be removed;
    • updateRoamingResponse

      public void updateRoamingResponse(boolean suppressPopupErrors)
      Update the roaming response graph.
      Parameters:
      suppressPopupErrors - whether pop-up errors generated when creating the graph data are to be suppressed.
    • getDynamicModel

      Returns the DynamicModel set in this MultiContrastAnalysisFrame. This class returns null. Sub-classes may return the DynamicModel that they use.
      Returns:
      the DynamicModel used, or null if none is used.
      Throws:
      InvalidArgumentException - if an invalid argument has been set for the DynamicModel.
      InvalidImageException - if the image may be used to create the DynamicModel is invalid.
    • setDefaults

      public void setDefaults()
      Put the default settings to this MultiContrastAnalysisFrame.
      Specified by:
      setDefaults in interface PreferencesSettable
      Overrides:
      setDefaults in class com.xinapse.util.ImageOrganiserFrame
    • savePreferences

      public void savePreferences(Preferences prefs) throws InvalidArgumentException
      Save the current setting to the user preferences.
      Specified by:
      savePreferences in interface PreferencesSettable
      Overrides:
      savePreferences in class com.xinapse.util.ImageOrganiserFrame
      Parameters:
      prefs - the Preferences node to which to save the settings.
      Throws:
      InvalidArgumentException - if the current settings are not valid.
    • getSliceDataType

      public static PixelDataType getSliceDataType(int slice, int contrast, ReadableImage[] inputImages, boolean contiguousContrasts, int nSliceLocations, boolean asFloat) throws InvalidArgumentException, InvalidImageException
      Returns the PixelDataTypefor one physical slice location and one image contrast.
      Parameters:
      slice - the physical slice location index.
      contrast - an index to the image contrast.
      inputImages - can be either an array of length 1, if all slices/contrasts are in one file, or an array of length equal to the number of physical slices or the number of contrasts.
      contiguousContrasts - true if, in a single input image, the contrasts are contiguous and vary fastest, i.e. the slices are in the order:
      slice-location-1: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-2: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-3: contrast-1, contrast-2 contrast-3 ... contrast-N

      For multiple input images, this indicates that a single input images contains all contrasts for a single physical slice.

      nSliceLocations - the number of physical slice locations.
      asFloat - whether pixel values will be returned as a float[], regardless of the pixel data type of the input images.
      Returns:
      the PixelDataTypefor one physical slice location and one image contrast.
      Throws:
      InvalidArgumentException - the setup of the input images is not valid.
      InvalidImageException - if the PixelDataType cannot be gotten from the input image.
    • getVolumePix

      public static Object getVolumePix(int contrast, ReadableImage[] inputImages, boolean contiguousContrasts, int nSliceLocations, Integer nContrasts, com.xinapse.apps.mask.BinaryMask binaryMask, String contrastDescription, boolean asFloat) throws InvalidArgumentException, InvalidImageException
      Returns the pixels for one particular 3-D volume.
      Parameters:
      contrast - the image contrast to select.
      inputImages - the set of input images.
      contiguousContrasts - whether image contrasts are contiguous.
      nSliceLocations - the number of physical slice locations.
      nContrasts - the number of image contrasts.
      binaryMask - if non-null, a mask for the volume.
      contrastDescription - of the description of the contrast requested.
      asFloat - whether to return the pixel values in single-precision floating-point format.
      Returns:
      the set of pixels corresponding to the particular image contrast.
      Throws:
      InvalidArgumentException - if any of the arguments is invalid.
      InvalidImageException - if any of the input images is invalid.
    • getSlicePix

      public static Object getSlicePix(int slice, int contrast, ReadableImage[] inputImages, boolean contiguousContrasts, int nSliceLocations, com.xinapse.apps.mask.BinaryMask binaryMask, String contrastDescription, boolean asFloat) throws InvalidArgumentException, InvalidImageException
      Returns the pixel values for one physical slice location and one image contrast.
      Parameters:
      slice - the physical slice location index.
      contrast - an index to the image contrast.
      inputImages - can be either an array of length 1, if all slices/contrasts are in one file, or an array of length equal to the number of physical slices or the number of contrasts.
      contiguousContrasts - true if, in a single input image, the contrasts are contiguous and vary fastest, i.e. the slices are in the order:
      slice-location-1: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-2: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-3: contrast-1, contrast-2 contrast-3 ... contrast-N

      For multiple input images, this indicates that a single input images contains all contrasts for a single physical slice.

      nSliceLocations - the number of physical slice locations.
      binaryMask - if non-null a BinaryMask that acts as mask for the input images. Pixels outside the mask are returned with a zero intensity.
      contrastDescription - a description of the way that contrast differs between the input images.
      asFloat - whether to return the pixel values as a float[], regardless of the pixel data type of the input images.
      Returns:
      the pixel values for one physical slice location and one image contrast.
      Throws:
      InvalidArgumentException - the setup of the input images is not valid.
      InvalidImageException - if the pixel values cannot be gotten from an input image.
    • putSlicePix

      public static void putSlicePix(float[] slicePix, int slice, int contrast, WritableImage[] outputImages, boolean contiguousContrasts, int nSliceLocations, String contrastDescription) throws InvalidArgumentException, InvalidImageException, IOException
      Puts the pixel values to one physical slice location and one image contrast.
      Parameters:
      slicePix - the pixel values to put.
      slice - the physical slice location index.
      contrast - an index to the image contrast.
      outputImages - can be either an array of length 1, if all slices/contrasts are in one file, or an array of length equal to the number of physical slices or the number of contrasts.
      contiguousContrasts - true if, in a single input image, the contrasts are contiguous and vary fastest, i.e. the slices are in the order:
      slice-location-1: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-2: contrast-1, contrast-2 contrast-3 ... contrast-N
      slice-location-3: contrast-1, contrast-2 contrast-3 ... contrast-N

      For multiple input images, this indicates that a single input images contains all contrasts for a single physical slice.

      nSliceLocations - the number of physical slice locations.
      contrastDescription - a description of the way that contrast differs between the input images.
      Throws:
      InvalidArgumentException - the setup of the output images is not valid.
      InvalidImageException - if the pixel values cannot be put to an input image.
      IOException - if an I/O error occurs when writing the pixel values.
    • busyCursors

      public void busyCursors()
      Description copied from class: com.xinapse.util.ImageOrganiserFrame
      Call this method to indicate that the ImageOrganiserFrame is busy processing.
      Specified by:
      busyCursors in interface MessageShower
      Overrides:
      busyCursors in class com.xinapse.util.ImageOrganiserFrame
    • readyCursors

      public void readyCursors()
      Description copied from class: com.xinapse.util.ImageOrganiserFrame
      Call this method to indicate that the ImageOrganiserFrame is ready to do further processing.
      Specified by:
      readyCursors in interface MessageShower
      Overrides:
      readyCursors in class com.xinapse.util.ImageOrganiserFrame
    • showRoamingResponseDialog

      protected void showRoamingResponseDialog()
      Causes a RoamingResponseDialog to pop up.
    • drawRoamingResponseGraphs

      public void drawRoamingResponseGraphs(List<com.xinapse.graph.XYDataSet> dataSets)
      Draws the graphs into the RoamingResponseDialog.
      Parameters:
      dataSets - the datasets for the graphs to draw.
    • setVisible

      public void setVisible(boolean b)
      Description copied from class: com.xinapse.util.ImageOrganiserFrame
      Shows or hides this ImageOrganiserFrame depending on the value of parameter b. If b is false, then the user will be asked if any Threads the were generated by this ImageOrganiserFrame should be stopped. If the user indicates to stop the Threads, then the threads are stopped at the next available opportunity. If, after these checks, no Threads are running, then the quitMe flag is set, and this ImageOrganiserFrame is hidden.
      Overrides:
      setVisible in class com.xinapse.util.ImageOrganiserFrame
      Parameters:
      b - if true, shows this ImageOrganiserFrame; otherwise, hides this ImageOrganiserFrame.