Reference¶
Annotator¶
Reference¶
-
class
Annotator.
Annotator
¶ Class Annotator manages loading and saving of annotations stored in an .ann file.
Annotation format: id; plot_name; annotation type; x1; x2; y1; y2; text
For example: 5;fhr;basal;1;298316;160;160; id = 5 plot_name = fhr (fhr or toco) annotation type = basal x1 = 1 (begin) x2 = 298316 (end) y1 = 160 y2 = 160 text = (empty)
Special cases: floating baseline: The text field contains point of floating baseline in a format x1-y1; x2-y2 ; .... ; xn-yn
-
_Annotator__load_annotations
()¶ Load annotations from .ann file.
Returns: annotations in dict() Return type: dict()
-
-
class
Annotator.
CanvasPickerAnnotator
(p_plot)¶ Pick events generated by user such as draw basal, baseline, recovery, etc. The CanvasPickerAnnotator calls super function to plot the events
Parameters: p_plot ( FhrPlot
) – pointer toFhrPlot
-
eventFilter
(obj, event)¶ Filter mouse and key events: * Single click event * Double click event * MouseMove * MouseRelease
-
perform_double_click_event
(event)¶ Perform event related to a double click (edit the annotations)
-
perform_single_click_event
(event)¶ Perform event related to a single click on plot :param event: :type event:
-
AnnotationObject¶
Reference¶
-
class
AnnotationObject.
AnnotationObject
(parent_name='', curve_type=None, x1=None, x2=None, y1=None, y2=None, s='')¶ The AnnotationObject is predecessor object that implements several functions that are in common for various types of annotation objects.
-
correct_y1_y2
()¶ Basal, baseline, Recovery, No-recovery, Uterine contraction should have the same y1 adn y2 value
-
newid
= <method-wrapper 'next' of itertools.count object>¶
-
-
class
AnnotationObject.
PyQwtPlotCurveAnnotator
(parent_name='', curve_type=None, x1=None, x2=None, y1=None, y2=None, s='')¶ Definitions for basal heart rate, baseline, recovery, and no recovery
-
class
AnnotationObject.
PyQwtPlotMarkerAnnotator
(parent_name='', curve_type=None, x1=None, x2=None, y1=None, y2=None, s='')¶ Definition of annotation box. This class is base class for note.
-
correct_val_order
()¶ Not used
-
correct_y1_y2
()¶ Not used
-
draw_my
(x=None, y=None)¶ auxially function
-
-
class
AnnotationObject.
PyQwtPlotEllipseAnnotator
(parent_name='', curve_type=None, x1=None, x2=None, y1=None, y2=None, s='')¶ Definitions for an ellipse
-
correct_y1_y2
()¶ Not used
-
draw
(painter, xMap, yMap, canvasRect)¶ Parameters: painter (QtGui.QPainter) –
-
draw_my
(x=None, y=None)¶ auxially function
-
newid
= <method-wrapper 'next' of itertools.count object>¶
-
-
class
AnnotationObject.
PyQwtPlotFloatingBaseline
(parent_name='', curve_type=None, x1=None, x2=None, y1=None, y2=None, s='')¶ Definition and drawing of floating baseline
-
add_point_xy
(x, y)¶ Add x and y points to floating baseline. Correct value orders and save first and last points
-
correct_val_order
()¶ Sort values in fbaseline
-
correct_y1_y2
()¶ Not used - do not make y1 = y2
-
draw_my
(x=None, y=None)¶ auxially function
-
get_baseline_points_to_save_in_str
()¶ :rtype str
-
newid
= <method-wrapper 'next' of itertools.count object>¶
-
set_baseline_points_from_str
(s)¶ :param s input string in format x1-y1,x2-y2,x3-y3 :type s str
-
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 ctgViewerLite1) open via menu bar in ctgViewerLite2) call ctgViewerLite from command prompt, see REFERENCE NEEDED: for details3) 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
:param sfile: input file :type sfile: str :return adata: dict of data like FHR, UC, etc :rtype dict
-
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
-
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'])¶ -
_ann_set_action
(a='select')¶ Set what annotation action will be performed. The possible actions are defined in
EnumAnnType
-
_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.
-
_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
-
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
- curve_type – EnumAnnType
- s – text fo annotation
-
ann_note
(pos, s)¶ Add annotation type Note
Parameters: - pos (QPointF) – x and y position
- s (str) – text for annotation
-
ann_plot_curves
(bplot=True)¶ 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_bith_line
(pos_samp)¶ Plot line indicating birth time
Parameters: pos_samp – Returns:
-
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:
-
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: - center_point (int) – user’s clicked point at
PyQwtNavigationPlot
- breplot – boolean replot
- center_point (int) – user’s clicked point at
-
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
-
size_plot_area
()¶ 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.