Skip to content

Commit c16c836

Browse files
committed
MAINT: Allow no dig
1 parent ac43da0 commit c16c836

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

mne/_fiff/_digitization.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ def _get_data_as_dict_from_dig(dig, exclude_ref_channel=True):
294294
# Split up the dig points by category
295295
hsp, hpi, elp = list(), list(), list()
296296
fids, dig_ch_pos_location = dict(), list()
297+
dig = [] if dig is None else dig
297298

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

310311
dig_coord_frames = set([d["coord_frame"] for d in dig])
312+
if len(dig_coord_frames) == 0:
313+
dig_coord_frames = set([FIFF.FIFFV_COORD_HEAD])
311314
if len(dig_coord_frames) != 1:
312315
raise RuntimeError(
313316
"Only single coordinate frame in dig is supported, "

mne/coreg.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,9 @@ def _setup_bem(self):
15511551
low_res_path = _find_head_bem(self._subject, self._subjects_dir, high_res=False)
15521552
if high_res_path is None and low_res_path is None:
15531553
raise RuntimeError(
1554-
"No standard head model was " f"found for subject {self._subject}"
1554+
"No standard head model was "
1555+
f"found for subject {self._subject} in "
1556+
f"{self._subjects_dir}"
15551557
)
15561558
if high_res_path is not None:
15571559
self._bem_high_res = _read_surface(
@@ -1988,9 +1990,9 @@ def fit_fiducials(
19881990
return self
19891991

19901992
def _setup_icp(self, n_scale_params):
1991-
head_pts = list()
1992-
mri_pts = list()
1993-
weights = list()
1993+
head_pts = [np.zeros((0, 3))]
1994+
mri_pts = [np.zeros((0, 3))]
1995+
weights = [np.zeros(0)]
19941996
if self._has_dig_data and self._hsp_weight > 0: # should be true
19951997
head_pts.append(self._filtered_extra_points)
19961998
mri_pts.append(

mne/gui/_coreg.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,11 +1063,14 @@ def _update_distance_estimation(self):
10631063
)
10641064
dists = self.coreg.compute_dig_mri_distances() * 1e3
10651065
if self._hsp_weight > 0:
1066-
value += (
1067-
"\nHSP <-> MRI (mean/min/max): "
1068-
f"{np.mean(dists):.2f} "
1069-
f"/ {np.min(dists):.2f} / {np.max(dists):.2f} mm"
1070-
)
1066+
if len(dists) == 0:
1067+
value += "\nNo head shape points found."
1068+
else:
1069+
value += (
1070+
"\nHSP <-> MRI (mean/min/max): "
1071+
f"{np.mean(dists):.2f} "
1072+
f"/ {np.min(dists):.2f} / {np.max(dists):.2f} mm"
1073+
)
10711074
self._forward_widget_command("fit_label", "set_value", value)
10721075

10731076
def _update_parameters(self):

0 commit comments

Comments
 (0)