multicut module

GUI modules

class lys.mcut.MultiCutGUI.MultiCut(wave, subWindow=True)[source]

Bases: QObject

This is central class of MultiCut.

Although MultiCut is mainly GUI interface, it is also possible to manipulate it programatically through methods.

Filters, axes ranges, free lines, child waves are controlled via MultiCutCUI via cui property.

Canvases in grid and independent Graphs are added by display() method of this class.

After adding the canvases, they are managed by CanvasManager class.

CanvasManager also manages interactive annotations in the canvas.

closed

Emited when the MultiCut window is closed.

property cui

MultiCutCUI class that manages filters, axes ranges, free lines, child waves.

display(wave, type='grid', pos=None, wid=None, **kwargs)[source]

Display wave data created by addWave method of cui.

Parameters:
  • wave (_ChildWave) – The child wave data created by addWave method of cui.

  • type ('grid' or 'graph') – Specifi the wave is displayed in grid or independent graph.

  • pos (length 2 sequence) – The position in the grid where the wave is displayed. If type is ‘graph’, it is ignored.

  • wid (length 2 sequence) – The width of the graph displayed in grid. If type is ‘graph’, it is ignored.

loadDefaultTemplate()[source]

Load default template for the current filtered wave. Call this method soon after the GUI is initialized when you want to initialize the multicut widget with default template.

Returns:

the dictionary that contains the default template parameters.

Return type:

dict

loadFromDictionary(d, **kwargs)[source]

Load the present state from dictionary.

openMultiCutSetting()[source]

Open multicut setting window in side bar.

saveAsDictionary(**kwargs)[source]

Save the present state as dictionary.

property widget

Get the widget associated with the MultiCut instance.

class lys.mcut.CanvasManager.CanvasManager(cui, color)[source]

Bases: list

addAnnotations(c, annotations, syncLine=False, overwrite=False)[source]

Add annotations to the canvas.

This method is internal use only. Do not call.

addCross(c=None, overwrite=True)[source]

Add cross annotation to canvas.

The added annotation is synchronized with axes range of MultiCut.

Parameters:
  • c (canvas) – The canvas to which the annotation is added. If it is omitted, frontCanvas is used.

  • overwrite (bool) – If it is True, the axis range type is changed to “point”.

addFreeLine(c=None, line=None, syncAnnot=False)[source]

Add free line annotation to canvas.

The added annotation is synchronized with axes range of MultiCut.

Parameters:

c (canvas) – The canvas to which the annotation is added. If it is omitted, frontCanvas is used.

addLine(c=None, orientation='vertical', overwrite=True)[source]

Add infinite line annotation to canvas.

The added annotation is synchronized with axes range of MultiCut.

Parameters:
  • c (canvas) – The canvas to which the annotation is added. If it is omitted, frontCanvas is used.

  • overwrite (bool) – If it is True, the axis range type is changed to “point”.

addRect(c=None, overwrite=True)[source]

Add rectangle annotation to canvas.

The added annotation is synchronized with axes range of MultiCut.

Parameters:
  • c (canvas) – The canvas to which the annotation is added. If it is omitted, frontCanvas is used.

  • overwrite (bool) – If it is True, the axis range type is changed to “range”.

addRegion(c=None, orientation='vertical', overwrite=True)[source]

Add region annotation to canvas.

The added annotation is synchronized with axes range of MultiCut.

Parameters:
  • c (canvas) – The canvas to which the annotation is added. If it is omitted, frontCanvas is used.

  • overwrite (bool) – If it is True, the axis range type is changed to “range”.

clear(removeGraphs=False)[source]

Clear all canvases managed by this class.

createCanvas(axes, *args, graph=False, **kwargs)[source]

Create canvas that is associated with axes. All canvas managed by MultiCut should be instanciated by this method.

Parameters:
  • axes (list of int) – The axes that is associated with the canvas. This is required to specify the axes range from the interactive annotations.

  • graph (bool) – If True, the canvas is created as independent graph window. Otherwise it is in the grid.

  • args (any) – This is passed to display method of lys. See lys.functions.display().

  • kwargs (any) – This is passed to display method of lys. See lys.functions.display().

getAnnotations(c)[source]

Return all annotations managed by this class.

Parameters:

c (canvas) – The targe tcanvas.

interactiveWidget()[source]

Return interactive widget in GUI.

This method is internal use only. Do not call.

CUI modules

class lys.mcut.MultiCutCUI.MultiCutCUI(wave)[source]

Bases: QObject

MultiCutCUI is a class that manage contents of lys.multicut.MultiCutGUI.MultiCut.

The instance of this class is automatically generated by lys.multicut.MultiCutGUI.MultiCut and therefore users should not instantiate this class.

The functionarities of this class is composed of MultiCutWave, ChildWaves, AxesRangeManger, and FreeLineManager.

The methods of above classes can be accessed directly from this class.

Parameters:

wave (Wave or DaskWave) – The wave to be analyzed by MultiCut.

loadFromDictionary(d, **kwargs)[source]

Load the state stored in the dictionary.

saveAsDictionary(**kwargs)[source]

Save present state as dictionary.

class lys.mcut.MultiCutCUI.MultiCutWave(wave)[source]

Bases: QObject

This class manage wave and filter for analysis.

All methods in this class can be accessed from MultiCutCUI.

Parameters:

wave (Wave or DaskWave) – The wave to be analyzed.

applyFilter(filt)[source]

Apply filter to the wave.

Parameters:

filt (Filter) – The filter to be applied.

dimensionChanged

Emitted when the dimension of the filtered wave is changed.

filterApplied

Emitted when filter is applied.

getFilteredWave()[source]

Get filtered wave instance.

Returns:

The filtered wave.

Return type:

DaskWave or Wave

getRawWave()[source]

Get raw wave instance.

Returns:

The instance of the raw wave.

Return type:

DaskWave

rawDataChanged

Emitted when the raw data is changed.

setRawWave(wave)[source]

Set the raw wave. The existing raw wave will be replaced if it exists. Use updateRawWave() method for fast update of the data.

Parameters:

wave (Wave or DaskWave) – The raw wave.

updateRawWave(data=None, axes=None, update=True)[source]

Update raw wavefor fast update of the data.

Parameters:
  • data (dict) – The dictionary that contains change of the data. The key of the dictionary should be index of the array. RawWave[key] will be replaced by data[key]

  • axes (list) – The new axes. If None, the axes will not be changed.

  • update (bool) – If True, the MultiCut result will be replaced by new data. Set False only when you want to continuously update the data before updating GUIs.

useDask(b)[source]

Specify whether the DaskWave is used for processing.

Parameters:

b (bool) – If True, DaskWave is used for processing.

class lys.mcut.MultiCutCUI.AxesRangeManager(wave)[source]

Bases: QObject

AxesRangeManager manage axes range that determines the result of MultiCut.

This class is automatically instanciated by MultiCutCUI.

Do not directly instanciate this class.

axesRangeChanged

Emitted after setAxisRange() is called.

getAxisRange(axis)[source]

Get the integrated range for MultiCut.

Parameters:

axis (int) – The axis.

Returns:

See setAxisRange().

Return type:

float or length 2 sequence

getAxisRangeType(axis)[source]

Get the axis range type for the specified axis.

Returns:

The axis range type.

Return type:

‘point’ or ‘range’

loadFromDictionary(d, useRange=False, axesMap=None, **kwargs)[source]

Load the state from the dictionary.

Parameters:
  • d (dict) – The dictionary.

  • useRange (bool) – If True, the range is loaded.

reset(wave)[source]

Reset all axes ranges to default.

saveAsDictionary(useRange=False, **kwargs)[source]

Save the present state as dictionary.

Parameters:

useRange (bool) – If True, save the ranges.

setAxisRange(*args, **kwargs)
class lys.mcut.MultiCutCUI.FreeLineManager[source]

Bases: QObject

FreeLineManager manages free lines in MultiCut.

Methods in this class can be accessed from MultiCutCUI.

Do not instantiate this class except in MultiCutCUI.

addFreeLine(axes, position=[[0, 0], [1, 1]], width=1, name=None)[source]

Add free line to MultiCut.

Parameters:
  • axes (length 2 sequence) – The axes for which the free line is added.

  • position (2*2 array) – The position of the free line in the form of [(x1,y1), (x2,y2)]

  • width (float) – The width of the free line.

  • name (str) – The name of the free line. If omitted, the line name is automatically generated.

Returns:

The free line object.

Return type:

_FreeLine

clear()[source]

Clear all free lines.

freeLineChanged

Emitted when free lines are added or removed.

freeLineMoved

Emitted when one of the free line is moved.

getFreeLine(name)[source]

Get free line from name.

Parameters:

name (str) – The name of free line.

Returns:

The free line object.

Return type:

_FreeLine

getFreeLines()[source]

Return list of free lines.

Returns:

The list of free lines.

Return type:

list

loadFromDictionary(d, useLine=False, axesMap=None, **kwargs)[source]

Load information of free lines from dictionary.

Parameters:
  • d (dict) – The dictionary that is generated by saveAsDictionary method.

  • useLine (bool) – It determines to load position and width of the free lines.

removeFreeLine(obj)[source]

Remove free line.

Parameters:

obj (_FreeLine) – The free line to be removed.

saveAsDictionary(useLine=False, **kwargs)[source]

Save information of free lines as dictionary.

Parameters:

useLine – If it is False, the position and width is not saved.

Returns:

The dictonary that contains the information of free line.

Return type:

dict

class lys.mcut.MultiCutCUI.ChildWaves(cui)[source]

Bases: QObject

This class manages child waves in MultiCut.

addWave(axes, filter=None, name=None)[source]

Add new wave to MultiCut. The child waves that is generated by this method is automatically updated when axes range of free lines are changed.

Parameters:
  • axes (list of int) – The axes of the child wave.

  • filter (filter) – The filter for postprocess.

  • name (str) – The name of the child wave.

Returns:

The object that include information of the child wave.

Return type:

_ChildWave

childWavesChanged

Emitted when the child waves are added or removed.

clear()[source]
property cui

Return the cui of MultiCut.

getChildWaves()[source]

Return the list of child waves:

Returns:

The list of child waves.

Return type:

list of _ChildWave

loadFromDictionary(d, axesMap=None, **kwargs)[source]

Load the state stored in the dictionary.

remove(obj)[source]

Remove a child wave.

Parameters:

obj (_ChildWave) – The child wave to be removed.

saveAsDictionary(**kwargs)[source]

Save the present state as dictionary.

setSumType(sumType)[source]

Set the sum type.

Parameters:

sumType ("Sum", "Mean", "Median", "Max", or "Min") – The sum type.