Picking

Coordinate

class datavis.models.Coordinate(x, y, label='Manual', **kwargs)

Simple class that holds values for x and y position and a optional label. The label can be used to group different type of coordinates within a Micrograph. Other attributes can be set dynamically.

set(**kwargs)

Set different properties of this coordinates. .. rubric:: Example

c = Coordinate(x, y, label=’Auto’) c.set(x=1, y=100, label=’None’) # … c.set(label=’Auto’)

Micrograph

class datavis.models.Micrograph(micId=None, path=None)

Micrograph is the base element managed by the PickerModel class (See PickerModel documentation).

getId()

Returns the micrograph Id.

getPath()

Returns the path of the micrograph.

setId(micId)

Set the micrograph Id.

setPath(path)

Set the micrograph path.

PickerModel

class datavis.models.PickerModel(boxSize=64)

Handles information about Coordinates and Micrographs.

The PickerModel class contains a set of micrographs, where each micrograph contains a set of coordinates. Coordinates are essentially (x, y) position and can also have a given label. Labels are created by the PickerModel and will be used to classify different types of coordinates (e.g based on quality).

Result.__init__(currentMicChanged=False, currentCoordsChanged=False, tableModelChanged=False)

Create a new instance with the provided values.

This class is used as the return of many methods from the PickerModel to notify back the underlying data that has changed after the operation.

Parameters
  • currentMicChanged – True if the data of the micrograph changed.

  • currentCoordsChanged – True if the coordinates of the current micrograph changed

  • tableModelChanged – True if the whole table with micrographs info changed and should be reloaded.

class Result(currentMicChanged=False, currentCoordsChanged=False, tableModelChanged=False)

Simple result object (although it might be more complex in the future) to notify about changes in the data model after an external action

addCoordinates(micId, coords)

Add coordinates to a given micrograph.

Parameters
  • micId – The micrograph identifier.

  • coords – An iterable with the coordinates that will be added.

Returns

Result instance

addMicrograph(mic)

Add a new Micrograph to the model.

Parameters

mic – Input Micrograph to be added. If the micrograph ID is -1 then a new ID will be assigned to the micrograph.

Raises

Exception if the input is not an instance of Micrograph.

changeParam(micId, paramName, paramValue, getValuesFunc)

Notify the picker model about changes in the parameters.

By calling this method, the model is notified about changes in one of the parameters. This method should be re-implemented in subclasses that want to react to changes in parameters.

Parameters
  • micId – micrograph ID

  • paramName – name of the parameter that generated the change

  • paramValue – current value of the parameter

  • getValuesFunc – function that will return all values as dict

Returns

Result instance

clearMicrograph(micId)

Remove all coordinates from this micrograph.

Returns

Result instance

createCoordinate(x, y, label, **kwargs)

Return a Coordinate object. This is the preferred way to create Coordinates objects, ensuring that the object contains all the additional properties related to the model. Subclasses should implement this method

getBoxSize()

Return the current box size of the coordinates.

getColumns()

Return a Column list that will be used to display micrographs.

getColumnsCount()

Return the number of columns for displaying the micrographs table.

getData(micId)

Return a numpy array with this micrograph binary data.

Parameters

micId – The micrograph ID

Returns

A 2D numpy array with the micrograph data.

getImageInfo(micId)

Return some specified info from the given image path. dim : Image dimensions ext : File extension data_type: Image data type

Parameters

micId – (int) The micrograph Id

Returns

dict with info

getLabel(labelName)

Returns the label with this labelName.

getLabels()

Return the existing Coordinate’s labels defined by this model.

getMicrograph(micId)

Returns the micrograph with the given ID.

getMicrographByIndex(micIndex)

Return the micrograph at this given index.

getMicrographMask(micId)

Return the mask that should be applied to visualise the micrograph

Parameters

micId – The micrograph ID

Returns

A 2D numpy array with the micrograph mask.

getMicrographMaskColor(mic)

Return the color to visualise the micrograph mask

Parameters

micId – The micrograph ID

Returns

#AARRGGBB or QColor. Example: ‘#552200FF’, QColor(r=3, g=56, b=200, a=128)

Return type

str in ARGB html format

getParams()

Return a Form instance with parameters used by the picker.

This method will be used by that can be used by the GUI to create widgets for each parameter. The GUI will then notify the model about changes in these parameters caused by user inputs.

getRowsCount()

Return the number of rows (i.e the number of micrographs).

getValue(row, col)

Return the value in this (row, column) from the micrographs table.

iterColumns()

Return an iterator for model columns

iterCoordinates(micId)

Iterate over the micrograph coordinates.

This iteration can yield a subset of the total coordinates depending on parameters such as threshold, or associate different labels to the coordinates.

removeCoordinates(micId, coords)

Remove coordinates from a given micrograph.

Parameters
  • micId – The micrograph ID.

  • coords – An iterable over the input coordinates.

Returns

Result instance.

selectMicrograph(newMicId)

Select a new micrograph as ‘active’.

While interacting with the GUI, usually there is a micrograph selected. By calling this method, the GUI notifies that the selected micrographs was changed. The model can respond to this change if necessary.

Returns

Result instance

setBoxSize(newSizeX)

Set the box size for the coordinates.