Skip to content

Commit

Permalink
cv + divergence import and export fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
vinush-vignes committed Jan 18, 2024
1 parent c04050e commit 60c4b74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
11 changes: 7 additions & 4 deletions openep/data_structures/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,15 @@ def extract_surface_data(surface_data):
pacing_site = None

try:
conduction_velocity = surface_data['conduction_velocity'].astype(float)
conduction_velocity = surface_data['signalMaps']['conduction_velocity_field']['value'].astype(float)
except KeyError as e:
conduction_velocity = None


try:
cv_divergence = surface_data['signalMaps']['divergence_field']['value'].astype(float)
except KeyError as e:
cv_divergence = None

try:
mesh_normals = surface_data['mesh_normals'].astype(float)
except KeyError as e:
Expand Down Expand Up @@ -253,8 +258,6 @@ def empty_fields(n_points=0, n_cells=0):
longitudinal_fibres,
transverse_fibres,
pacing_site,
conduction_velocity,
mesh_normals,
)

return fields
17 changes: 8 additions & 9 deletions openep/io/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,31 +211,32 @@ def export_openep_mat(
oned_as='column',
)


def _add_surface_maps(surface_data, **kwargs):
cv_field = kwargs.get('cv_field')
div_field = kwargs.get('divergence_field')

if not surface_data.get('signalMaps'):
surface_data['signalMaps'] = {}

# TODO: connect propSetting from user setting
# TODO: handle with None values as matlab cannot handle
# TODO: connect propSetting from user setting in UI
if cv_field is not None:
surface_data['signalMaps']['conduction_velocity_field'] = {
'name' : 'Conduction Velocity Field',
'name': 'Conduction Velocity Field',
'value': cv_field,
# 'propSettings':None,
'propSettings': {},
}

if div_field is not None:
surface_data['signalMaps']['divergence_field'] = {
'name' : 'Divergence Field',
'name': 'Divergence Field',
'value': div_field,
# 'propSettings':None,
'propSettings': {},
}

return surface_data


def _add_electric_signal_props(electric_data, **kwargs):
conduction_velocity = kwargs.get('conduction_velocity')
divergence = kwargs.get('divergence')
Expand All @@ -249,7 +250,6 @@ def _add_electric_signal_props(electric_data, **kwargs):
signal_props = electric_data['annotations']['signalProps']

if conduction_velocity:
#TODO: connect propSetting from user setting
signal_props['conduction_velocity'] = {
'name' : 'Conduction Velocity Values',
'value': conduction_velocity.values,
Expand All @@ -260,14 +260,14 @@ def _add_electric_signal_props(electric_data, **kwargs):
}

if divergence:
#TODO: connect propSetting from user setting
signal_props['divergence'] = {
'name' : 'Divergence Values',
'value': divergence.values,
}

return electric_data


def export_vtk(
case: Case,
filename: str,
Expand Down Expand Up @@ -366,7 +366,6 @@ def _extract_surface_data(
surface_data['longitudinal'] = fields.longitudinal_fibres if fields.longitudinal_fibres is not None else empty_float_array
surface_data['transverse'] = fields.transverse_fibres if fields.transverse_fibres is not None else empty_float_array
surface_data['pacing_site'] = fields.pacing_site if fields.pacing_site is not None else empty_int_array
surface_data['conduction_velocity'] = fields.conduction_velocity if fields.conduction_velocity is not None else empty_int_array
surface_data['mesh_normals'] = fields.mesh_normals if fields.mesh_normals is not None else empty_int_array

# Remove arrays that are full of NaNs
Expand Down

0 comments on commit 60c4b74

Please # to comment.