Skip to content

Commit

Permalink
MAINT: Allow no dig
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Oct 1, 2023
1 parent ac43da0 commit c16c836
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions mne/_fiff/_digitization.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ def _get_data_as_dict_from_dig(dig, exclude_ref_channel=True):
# Split up the dig points by category
hsp, hpi, elp = list(), list(), list()
fids, dig_ch_pos_location = dict(), list()
dig = [] if dig is None else dig

for d in dig:
if d["kind"] == FIFF.FIFFV_POINT_CARDINAL:
Expand All @@ -308,6 +309,8 @@ def _get_data_as_dict_from_dig(dig, exclude_ref_channel=True):
dig_ch_pos_location.append(d["r"])

dig_coord_frames = set([d["coord_frame"] for d in dig])
if len(dig_coord_frames) == 0:
dig_coord_frames = set([FIFF.FIFFV_COORD_HEAD])
if len(dig_coord_frames) != 1:
raise RuntimeError(
"Only single coordinate frame in dig is supported, "
Expand Down
10 changes: 6 additions & 4 deletions mne/coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,9 @@ def _setup_bem(self):
low_res_path = _find_head_bem(self._subject, self._subjects_dir, high_res=False)
if high_res_path is None and low_res_path is None:
raise RuntimeError(
"No standard head model was " f"found for subject {self._subject}"
"No standard head model was "
f"found for subject {self._subject} in "
f"{self._subjects_dir}"
)
if high_res_path is not None:
self._bem_high_res = _read_surface(
Expand Down Expand Up @@ -1988,9 +1990,9 @@ def fit_fiducials(
return self

def _setup_icp(self, n_scale_params):
head_pts = list()
mri_pts = list()
weights = list()
head_pts = [np.zeros((0, 3))]
mri_pts = [np.zeros((0, 3))]
weights = [np.zeros(0)]
if self._has_dig_data and self._hsp_weight > 0: # should be true
head_pts.append(self._filtered_extra_points)
mri_pts.append(
Expand Down
13 changes: 8 additions & 5 deletions mne/gui/_coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,14 @@ def _update_distance_estimation(self):
)
dists = self.coreg.compute_dig_mri_distances() * 1e3
if self._hsp_weight > 0:
value += (
"\nHSP <-> MRI (mean/min/max): "
f"{np.mean(dists):.2f} "
f"/ {np.min(dists):.2f} / {np.max(dists):.2f} mm"
)
if len(dists) == 0:
value += "\nNo head shape points found."
else:
value += (
"\nHSP <-> MRI (mean/min/max): "
f"{np.mean(dists):.2f} "
f"/ {np.min(dists):.2f} / {np.max(dists):.2f} mm"
)
self._forward_widget_command("fit_label", "set_value", value)

def _update_parameters(self):
Expand Down

0 comments on commit c16c836

Please sign in to comment.