Visualization

class Visualization.CanvasFrame(InputList, CommID, SelectRegion, SelectPoints, Plugin='Display', WindowSize=(960, 540))

This is the overall display module that is used to display images. It makes use of pyqtgraph to display images and contains some extra bits of code created by Rogier and Jonne to pre-cache parts of the image in case the single wavelength mode is used. This frame should always be accompanied by a control frame when used. No control over the image exists within this frame. (changing the wavelength for instance)

Parameters:
  • InputList (list with string of the format : [[Image1,Image2],[Image1,Image2],[Image1],...]) – The list with input FILEPATHS. The list is a 2D list with the first axis reserved for plots and the 2nd axis reserved for images.
  • CommID (string) – The communication ID that is used by the window. Normally this is quickly generated by taking the system time or something.
  • SelectRegion (Bool) – Parameter that determines whether region selection is enabled or disabled.
  • SelectPoints (Bool) – Parameter that determines whether point selection is enabled or disabled.
  • WindowSize (tuple with int's (width,height)) – The initial window size.
Parma Plugin:

Which plugin uses the CanvasFrame class

AddImageItem(msg)

With this function the user can add an image item after the window has been started. In order to use this function some input variables are required. Mainly the following: ImagePath : The filepath to the image to be added. (string) PlotNumber: The plot that the image should be added to. The top plot is plot 0 and counts down from there. Imagechannel: The channel that the image should be added to. If you do not work with multiple channels just use 0. ImageZvalue: The Z value of the image, which determines the layering. If you want the image to be on-top of everything else give it a high value. ImageAlphavalue: The alpha channel of the image. between 0 and 1 where 0 is fully transparent and 1 is opaque.

Parameters:msg (list of the kind: [string,int,int,int,float]) – This variable contains all the parameters needed in this order: [ImagePath,PlotNumber,ImageChannel,ImageZvalue,ImageAlphavalue]
ChangeAlpha(msg)

Change the alpha value of an image item.

Parameters:msg ([int,int,float]) – [PlotNumber,ImageNumber,Alpha]
ChangeDivider(msg)

Changes the divider. The divider is simply a value that every other value in the displayed arrays is divided by. This is mainly useful in the visualisation of images with very high intensities.

Parameters:msg (int) – The divider value
ChangeROIColour(msg)

Function that will change the ROI colour. Only call if regionselect has been enabled previously!

Parameters:msg ((int,int,int)) – New Colour in the form of (R,G,B) where R,G and B are integers from 0 to 255.
Return type:None
InitMultiProcessing()

Internal function. Sets up multiprocessing.

MouseClicked(evt)

Internal Function. This function is called when the mouse is clicked in a window.

OnPointChange(msg)

Change the selected points for the selected plotnumber. Send a list with the plot number and a list with all the points to be selected.

Parameters:msg ([int,[[int,int],[int,int],...]]) – [Plot,[[x,y],[x,y],...]]
OnROIChange(msg)

Internal function. If the ROI is changed this function will emit the changed values.

ROICoordinateChange()

This function is called when a region selector is moved/changed etc. It emmits a list with new regions in coordinates of it’s left, right top and bottom line coordinates. In PYQTGraph it is currently not possible to figure out which ROI caused the event, thus it will emmit the full list of regionselectors.

The ‘margins’ emitted are simply integer coordinates and labeled as follows: Left Margin (LM) Right Margin (RM) Top Margin (TM) Bottom Margin (BM)

Returns:[[LM,RM,TM,BM],[LM,RM,TM,BM],...] for every regionselector
Return type:list with list with int ([[int,int,int,int],[int,int,int,int],...]
RemoveImageItem(msg)

With this function the user can remove an image item after the window has been started. In order to use this function some input variables are required. Mainly the following: Plot: The plot from which the image should be removed. Image: The image number which should be removed. Where the first image is 0, the 2nd image is 1 etc...

Parameters:msg (list of the kind: [int,int]) – This variable contains all the parameters needed in this order: [Plot,Image]
SetImageItemPosition(msg)

This function can be used to set the position of a specific Image Item. It moves the coordinates of the top-left corner.

Parameters:msg (list [int,int,(int,int)]) – A list with the following shape: [PlotNumber,ImageNumber,Position] where PlotNumber and ImageNumber are int’s and position is a tuple (x,y)
Return type:None
SplitArray(Metadata)

Internal Function. Determines the begin and end positions of the caches based on the amount of RAM and number of images. Also determines if the full image can be loaded.

Returns:A list with: a list (with cache bounderies), list(bands), int (Channel), int (amount of max caches)
Return type:list
TogglePointSelect(msg)

Toggles the point selection function for the plot. In order to toggle it send a list as a msg with [PlotNumber,Toggle] where if Toggle is True the regionselector is enabled and if it is false it is disabled.

Parameters:msg ([int,Bool]) – List with [PlotNumber,Toggle]
ToggleRegionSelect(msg)

Toggles the regionselector for the plot. In order to toggle the regionselector send a list as msg with [PlotNumber,Toggle] where if Toggle is True the regionselector is enabled and if it is false it is disabled.

Parameters:msg ([int,Bool]) – List with [plot,Toggle]
TrueColor(msg)

Function used for the True Colour function. Note that it is currently not accurate.

UpdateImage(msg)

Internal function. Sets the imageitem to a cached array received from the update thread.

WavelengthChange(msg)

This function will change the currently displayed band on the image. Call this function by sending [band,channel] to it and all images that are on the respective channel will have their bands changed.

Parameters:msg ([int,int]) – [Band,Channel]
closeEvent(event)

Internal function. Shut down all the thread and processes.

closeFromControl(msg)

Internal function. Closes the window.

tickStringsx(CanvasFrame, self, values, scale, spacing)

Internal function that overwrites the labels of the thicks, if the plot has the key in metadata “Horizontal Dimension (px/mm)”. This function can be overwritten if other thick labels are required. This definition has two selfs from two classes

Parameters:
  • CanvasFrame (Visualization.CanvasFrame) – The CanvasFrame class
  • self (pyqtgraph.graphicsItems.AxisItem.AxisItem) – The self.PlotList[plot].getPlotItem().getAxis(item) class
  • values (list) – A list of tick values
  • scale (float) – The scale argument is used when the axis label is displaying units which may have an SI scaling prefix. When determining the text to display, use value*scale to correctly account for this prefix. For example, if the axis label’s units are set to ‘V’, then a tick value of 0.001 might be accompanied by a scale value of 1000. This indicates that the label is displaying ‘mV’, and thus the tick should display 0.001 * 1000 = 1.
  • spacing (float) – The spacing between ticks (this is required since, in some instances, there may be only one tick and thus no other way to determine the tick spacing)
Returns:

A list of strings that should be placed next to ticks.

tickStringsy(CanvasFrame, self, values, scale, spacing)

Internal function that overwrites the labels of the thicks , if the plot has the key in metadata “Vertical Dimension (px/mm)”. This function can be overwritten if other thick labels are required. This definition has two selfs from two classes

Parameters:
  • CanvasFrame (Visualization.CanvasFrame) – The CanvasFrame class
  • self (pyqtgraph.graphicsItems.AxisItem.AxisItem) – The self.PlotList[plot].getPlotItem().getAxis(item) class
  • values (list) – A list of tick values
  • scale (float) – The scale argument is used when the axis label is displaying units which may have an SI scaling prefix. When determining the text to display, use value*scale to correctly account for this prefix. For example, if the axis label’s units are set to ‘V’, then a tick value of 0.001 might be accompanied by a scale value of 1000. This indicates that the label is displaying ‘mV’, and thus the tick should display 0.001 * 1000 = 1.
  • spacing (float) – The spacing between ticks (this is required since, in some instances, there may be only one tick and thus no other way to determine the tick spacing)
Returns:

A list of strings that should be placed next to ticks.

class Visualization.ExportdialogNew(scene, dimensionsLst, CommID)

The class below redefines the export dialog used by pyqtgraph. The reason this is necessary is because by default pyqtgraph does NOT add the imageitem as an exportable, thus by redefining these functions it DOES get added to it, allowing for much simpler image exporting.