Analyse a Case dataset - openep.case.case_routines¶
This module provides methods for analysing or extracting data from a case object, as well as interpolating electrical data from mapping points onto the 3D surface.
Extracting data from a Case¶
-
openep.case.case_routines.get_electrograms_at_points(case, within_woi=True, buffer=50, indices=None, egm_type='bipolar', return_names=True, return_lat=True)[source]¶ Extract the electrogram timeseries for a selection of points.
- Parameters
case (Case) – openep case object
within_woi (bool) – If True, only electrograms within the window of interest will be extracted. If False, all electrograms will be extracted.
buffer (float) – If within_woi is True, the woi will be extended by this time. If wihtin_woi is False, buffer is ignored.
indices (ndarray) – indices of mapping points for which electrograms will be extracted. If provided along with woi=True, only the electrograms that are both within the window of interest and selected by indices will be extracted. If provided along with woi=False, all electrograms of mapping points selected by indices will be returned.
egm_type (bool) – The electrogram traces to return. Valid options: - bipolar - unipolar - reference
return_names (bool) – If True, the internal names of the points used by the clinical electroanatomic mapping system will also be returned.
return_lat (bool) – If True, the local activation time of each mapping point will also be returned.
- Returns
traces (ndarray) – A timeseries of voltages for each selected mapping point.
names (ndarray, optional): If return_names is True, the internal names of the points used by the clinical electroanatomic mapping system will be returned.
local_activation_time (ndarray, optional): If return_lat is True, the local activation time of each mapping point will be returned.
-
openep.case.case_routines.get_woi_times(case, buffer=50, relative=False)[source]¶ Extracts the times within the window of interest.
- Parameters
case (Case) – openep case object
buffer (float) – times within the window of interest plus/minus this buffer time will be considered to be within the woi.
relative (bool) – if True, the time of the reference annotation will be subtracted from the returned times.
- Returns
times (ndarray) – times within the window of interest
Warning
This returns the sample indices that cover the window of interest for the first electrogram only. get_sample_indices_within_woi can be used to obtain a two-dimensional boolean array in which value of True indicate that the specific sample is within the specific electrogram’s window of interest.
Analyses¶
-
openep.case.case_routines.calculate_voltage_from_electrograms(case, buffer=50, bipolar=True)[source]¶ Calculates the peak-to-peak voltage from electrograms.
For each mapping point, the voltage will be calculated as the amplitude of its corresponding electrogram during the window of interest.
- Parameters
case (Case) – openep case object
buffer (float) – Amplitudes will be calculated using the window of interest plus/minus this buffer time.
bipolar (bool, optional) – If True, the bipolar voltages will calculated. If False, the unipolar voltages will be calculated.
- Returns
voltages (ndarray) – Bipolar voltages
Interpolate electrical data from mapping points onto the 3D surface¶
-
openep.case.case_routines.interpolate_voltage_onto_surface(case, buffer=50, method=scipy.interpolate.RBFInterpolator, method_kws=None, max_distance=None, bipolar=True)[source]¶ Interpolate voltage onto the points of a mesh.
For each mapping point within the window of interest, the voltage is calculated as the amplitude of an electrogram during the window of interest, plus/minus an optional buffer time.
- Parameters
case (openep.case.Case) – case from which the voltage will be calculated
buffer (float, optional) – extend the window of interest by this time. The default is 50 ms.
method (callable) – method to use for interpolation. The default is scipy.interpolate.RBFInterpolator.
method_kws (dict) – dictionary of keyword arguments to pass to method when creating the interpolator.
max_distance (float, optional) – If provided, any points on the surface of the mesh further than this distance to all mapping coordinates will have their interpolated voltages set NaN. The default it None, in which case the distance from surface points to mapping points is not considered.
bipolar (bool, optional) – If True, the bipolar voltage will be interpolated onto the surface. If False, the unipolar voltage will be used instead.
- Returns
interpolated_voltages (ndarray) – bipolar voltages, calculated from the electrograms, interpolated onto the surface of the mesh.
Tip
By default, scipy’s RBFInterpolator is used to perform the interpolation. If you prefer to use a different interpolation method, you pass an interpolator class and associated keyword arguments to the method and method_kws arugments respectively.
-
class
openep.case.case_routines.Interpolator[source]¶ Interpolate scalar values onto the points of a mesh.
- Parameters
points (np.ndarray) – (N,3) array of coordinates for which we know values of the scalar field
field (np.ndarray) – array of size N of scalar values
method (callable) – method to use for interpolation. The default is scipy.interpolate.RBFInterpolator.
method_kws (dict) – dictionary of keyword arguments to pass to method when creating the interpolator
-
__call__(surface_points, max_distance=None)[source]¶ Interpolate the scalar field onto a new set of coordinates
- Parameters
surface_points (ndarray) – Mx3 array of points onto which the field will be interpolated
max_distance (float, optional) – Surface points further than this distance from any of the original points will not be used in the interpolation. Instead, their scalar field will be set to NaN. Defaults to None, in which case all surface points will used.
- Returns
interpolated_field (ndarray) – Scalar field interpolated onto the new points.