Skip to content

Commit

Permalink
ppath: return NA if not photons are dected
Browse files Browse the repository at this point in the history
  • Loading branch information
harmening committed Apr 11, 2024
1 parent ea64e2e commit 56f375d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cedalion/imagereco/forward_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class TwoSurfaceHeadModel:
segmentation_masks: xr.DataArray
brain: cdc.Surface
scalp: cdc.Surface
landmarks: cdt.LabeledPointCloud
landmarks: Optional[cdt.LabeledPointCloud]
t_ijk2ras: cdt.AffineTransform
t_ras2ijk: cdt.AffineTransform
voxel_to_vertex_brain: scipy.sparse.spmatrix
Expand Down Expand Up @@ -253,8 +253,10 @@ def _get_ppath_from_mcx(self, i_optode: int, j_optode, nphoton: int):
}

result = pmcx.mcxlab(cfg)

return result["detp"]["ppath"]
if 'detp' in result.keys():
return result["detp"]["ppath"]
else:
return None

def _fluence_at_optodes(self, fluence, emitting_opt):
"""Fluence caused by one optode at the positions of all other optodes."""
Expand Down Expand Up @@ -358,8 +360,11 @@ def compute_ppath(self, n_photon: int = 1e8):

# run MCX
ppath = self._get_ppath_from_mcx(s_idx, d_idx, nphoton=n_photon)
#ppath_all[count, :, :] = ppath
ppath_all[count, :] = np.mean(ppath, axis=0)
if ppath is not None:
ppath_all[count, :] = np.mean(ppath, axis=0)
#ppath_all[count, :, :] = ppath
else:
ppath_all[count, :] = np.array([np.nan for i in range(n_tissues)])

count += 1

Expand Down

0 comments on commit 56f375d

Please sign in to comment.