Reference

MainWindow

The MainWindow module is the main class that provides interaction between GUI and the user. This class integrates all the other functionality.

Reference

class MainWindow.Main(args=['/usr/bin/sphinx-build', '-b', 'html', '-d', '_build/doctrees', '.', '_build/html'])
_create_connections()

Creates connections in MainWindow

_dock_clin_info_toggle()

Set clinical information dock widget visible or invisible

_dock_clin_info_visibility()

Clinical information dock visibility has changed, set the property of checkbox

_dock_databrowse_toggle()

Set docks widget visible or invisible

_dock_databrowse_visibility()

Visibility of data browser has changed, set the property of checkbox.

_get_paper_format()
Returns:paper format
Return type:str
_open_file()

Open file in gui. Files are filtered based on extension

_open_folder_data_browser(sdir)

Open folder in gui.

_toolbar_ann_changed()

Annotations were changed. Enable saving button.

_toolbar_ann_toogle()

Set toolbar visible or invisible

plot_file(sfile)

Plot physionet or matlab file

Parameters:sfile (str) – input file
plot_matlab_file(sfile)

Obsolete function - use plot file instead

Parameters:sfile
Returns:
plot_physionet_file(sfile)

Obsolete function - use plot file instead

Parameters:sfile
Returns:

PyQwtWidgetGui

The PyQwtWidgetGui module provides the plotting widget base class. This class ensures:
  • proper ratio of scales cm/min, bpm/cm
  • appearance of all derived plot

Reference

class PyQwtWidgetGui.PyQwtWidgetGui(parent=None, name='')

Base class plotting widget based on PyQwt.

Parameters:parent
ann_delete_all(replot=True, emit_signal=True)

Delete all annotations (basal, baseline, recovery, notes)

Parameters:
  • replot – replot current plot
  • emit_signal – emit signal that plot has changed
Returns:

ann_ellipse(pos, curve_type='ellipsenote', s='')

Add ellipse to a signal

Parameters:pos (QPointF) – x and y position
ann_note(pos, s)

Add comment to signal (note)

Parameters:
  • pos (QPointF) – x and y position
  • s (str) – text for annotation
ann_plot_curves()

Plot all annotations (basal, baseline, recovery, notes)

clear_plot()

When a plot is cleared a signal is emitted in order to allow the Plot to reinit

findClosestXPoint(point, nDirection=None)

Not used so far.

getMarginsXPx()

Get margins of x axis of this plot - length (in pixels) between end of an axis and end of plot widget.

Return type:int,int
getMarginsYPx()

Get margins of y axis of current plot - length (in pixels) between end of an axis and end of plot widget.

Returns:returns margins of current plot (in pixels)
Return type:int,int
plot(x, y, timestring=None)

Plot data. Numpy arrays should be used instead of list, the plotting speed is about 20x faster. Time string is used for plotting time on X axis. Prior plotting either minutes or hours are located based on user preference.

Parameters:
  • x (numpy.array | list()) – x axis values
  • y (numpy.array | list()) – y axis values
  • timestring (list()) – time strings for x axis labels
plotTemp(x, y)

Temporary code showing how to plot an additional line

plot_first_stage_line(stage1pos_samp)

Plot the first stage of labour

Parameters:stage1pos_samp
Returns:
plot_second_stage_line(stage2pos_samp)

Plot the second stage of labour

Parameters:stage2pos_samp
Returns:
runTimeLocator()

Locates time points at the X axis. The points could be minutes or hours. If both equal to -1 the time is guessed.

setXAxis(center_point=None, breplot=True)

Set scale of X axis. First get width of this plot. Then use preset cm/min ratio and use it to compute X axis scale.

Parameters:
setYAxis(height=None, bReplot=True)

Set scale of Y axis. First get height of this plot. Then use preset bmp/cm ratio and use it to compute y axis scale

Parameters:height (int) – height of the widget
sizePlotArea()

Return sizeof canvas, i.e. the size of actual plot. When this class is initialized use build in function QWidget.size() instead of getMarginsXPx()

Return type:QSize(width, height)
updateAxis()

Update X and Y axis. Replot after both axes were set.

viewXMaxSample()

Returns maximum of x axis for current view (display)

xAxisViewMaxSample()

Returns a maximum sample that will be plotted. The calculation of max samples is based on preset dpi and bpm/cm ratio

Return type:int
xlabel(text='')

set the x axis label

ylabel(text='')

set the y axis label. The font is based on application font

class PyQwtWidgetGui.TimeScaleDraw(plot)

Subclass of QwtScaleDraw because of time axis. Note: function axisScaleDiv will invalidate manually set ticks.

Parameters:plot (PyQwtWidgetGui) – parent
getTimeString()

Get a time axis.

Return type:list()
setTimeString(timeString, fs)

Set a time string used for X axis.

Parameters:
  • timeString (list()) – list of time strings, e.g [‘11:41:50’,‘11:41:51’]
  • fs – sampling frequency
class PyQwtWidgetGui.EnumPlotSpeed

Plot/paper speed enum - defines cm/min ratio.

class PyQwtWidgetGui.EnumPlotBpm

Plot/paper bpm size enum - defines bpm/cm ratio.

LoadWriteData

Load and write data in several formats.
  • text files
  • matlab files
  • csv files
  • txt: mb: loading csv directly from TXT/CSV file generated from BDI

Reference

class LoadWriteData.EnumVariableName

Class EnumVariableName contains description and names of variables in a matlab file that can be used in python

Examples of variables in mat-file (others not supported yet):

Parameters:
  • fhr (numeric vector) – fetal heart rate signal
  • uc (numeric vector) – uterine contractions signal
  • timestamp (numeric vector) – time stamp giving samples that are valid
Example of matlab file:
fhr = [150,150,151,152,150]
uc = [7,10,10,9,8]
timestamp = [1,2,3,10,11] % timestamp represents timesamples; that is during time: 4,5,6,7,8,9 there is no recording.
Do not substitute with artifacts! The timestamp is used for situations when the recording was stopped and started again.

save(‘temp.mat’,’fhr’,’uc’,’timestamp’)

View file in ctgViewerLite
1) open via menu bar in ctgViewerLite
2) call ctgViewerLite from command prompt, see REFERENCE NEEDED: for details
3) call ctgViewerLite from matlab, see REFERENCE NEEDED: for details
class LoadWriteData.LoadData

Load data from various types of files

read_bdi_txtfile(infile)

load data from txt file (generated from BDI file), the structure of csv is expected as: timestamp, fhr, uc (fields: 1, 4, 11) :param: infile: input file :type: infile: str()

read_csv_file(infile)

load data from csv file, the structure of csv is expected as: timestamp, fhr, uc

read_data(infile)

Interface function for reading data :param infile: input file dat, mat, hea :return:

read_matlab_file(sfile)

read a signal in matlab format, for specification of matlab file see EnumVariableName

read_physionet_header(infile)

Read a file header in physionet format

Parameters:infile (string) – filename to read
Return lheader:
Rtype lheader:list of dict
read_physionet_header_for_dat(infile)

Read a physionet header when the name of signal is provided.

Parameters:infile (string) – filename of signal, which header is desired
Returns:list of parameters
read_physionet_signal16(in_file, l_header=None)

read a signal in physionet format, only format 16 is supported

transform_lyon_info(cdata, n)

Transform loaded matlab file into compatible format for CTGViewerLite

Parameters:
  • cdata (loaded matlab structure) – metainfo from Lyon database
  • n – length of the FHR data
Returns:

datadict: diconary with clinical information to be displayed

write_csv_file(infile, data, sheader=None)

write data into csv file. the function is not using the python csv module because of unable to setup float precision

PyQwtNavigationPlot

The navigation plot shows overview of complete signals. By clicking on this plot the controled plots are moved to the clicked position. The area of visible signal is highlighted using py:class:´PyQwtNavigationPlotHighlight´

Reference

class PyQwtNavigationPlot.PyQwtNavigationPlot(parent=None, l_controled_plots=None)

The navigation plot shows overview of complete signals. By clicking on this plot a signal is emitted with clicked point position.

Parameters:
  • parent (QWidget) –
  • l_controled_plots (PyQwtWidgetGui) – list of controled plots
change_selected_pointleft(step=None)
change_selected_pointright(step=None)
clear_selected_point()
correct_point_boundaries()

If a point is inside boundaries. Point is restricted to be within r = (xmax - xmin)/2, [r, max_view - r]

get_selected_point()

When user clicked on the plot, this variable holds x-coordinate of a point

Return type:QPointF
get_toco_offset()
reinit()
setXAxis(center_point=None, breplot=True)
setYAxis(height=None, bReplot=True)
set_selected_point(point)

Set point clicked by a user.

Parameters:point (QPointF) – clicked point
class PyQwtNavigationPlot.PyQwtNavigationPlotHighlight(p_navplot)

The navigation plot highlight is used for highlighting area where user clicked with mouse. This class is inherited from Qwt.QwtPlotCurve.

Parameters:p_navplot (PyQwtWidgetGui) – navigation plot widget
drawFromTo(painter, xmap, ymap, start, stop)

Draws rectangles around a point where user clicked

Parameters:
  • painter (QPainter) –
  • xmap
  • ymap
  • start
  • stop

Table Of Contents

Previous topic

Development