Skip to content

Commit

Permalink
Various small CoregistrationUI improvements extracted from #10242 (#1…
Browse files Browse the repository at this point in the history
…0245)

* Use overwrite='read' when checking for file to read

* Picking fiducials -> Placing MRI fiducials

* Limit dock width to 350px

* Set file filter and initial directory for trans file pickers
  • Loading branch information
hoechenberger authored Jan 26, 2022
1 parent 585e444 commit 9396ca7
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions mne/gui/_coreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from functools import partial
import os
import os.path as op
from pathlib import Path
import time
import queue
import threading
Expand Down Expand Up @@ -284,7 +285,7 @@ def _get_default(var, val):

def _set_subjects_dir(self, subjects_dir):
self._subjects_dir = _check_fname(
subjects_dir, overwrite=True, must_exist=True, need_dir=True)
subjects_dir, overwrite='read', must_exist=True, need_dir=True)

def _set_subject(self, subject):
self._subject = subject
Expand All @@ -296,7 +297,7 @@ def _set_fiducials_file(self, fname):
if not self._check_fif('fiducials', fname):
return
self._fiducials_file = _check_fname(
fname, overwrite=True, must_exist=True, need_dir=False)
fname, overwrite='read', must_exist=True, need_dir=False)

def _set_current_fiducial(self, fid):
self._current_fiducial = fid.lower()
Expand All @@ -314,15 +315,15 @@ def _set_info_file(self, fname):
self._widgets["info_file"].set_value(0, '')
return

fname = _check_fname(fname, overwrite=True) # convert to str
fname = _check_fname(fname, overwrite='read') # convert to str

# ctf ds `files` are actually directories
if fname.endswith(('.ds',)):
self._info_file = _check_fname(
fname, overwrite=True, must_exist=True, need_dir=True)
fname, overwrite='read', must_exist=True, need_dir=True)
else:
self._info_file = _check_fname(
fname, overwrite=True, must_exist=True, need_dir=False)
fname, overwrite='read', must_exist=True, need_dir=False)

def _set_omit_hsp_distance(self, distance):
self._omit_hsp_distance = distance
Expand Down Expand Up @@ -466,7 +467,7 @@ def _lock_fids_changed(self, change=None):
else:
self._forward_widget_command(locked_widgets, "set_enabled", False)
self._forward_widget_command(fits_widgets, "set_enabled", False)
self._display_message("Picking fiducials - "
self._display_message("Placing MRI fiducials - "
f"{self._current_fiducial.upper()}")
self._set_sensors_visibility(self._lock_fids)
self._forward_widget_command("lock_fids", "set_value", self._lock_fids)
Expand All @@ -486,7 +487,7 @@ def _current_fiducial_changed(self, change=None):
self._update_fiducials()
self._follow_fiducial_view()
if not self._lock_fids:
self._display_message("Picking fiducials - "
self._display_message("Placing MRI fiducials - "
f"{self._current_fiducial.upper()}")

@observe("_info_file")
Expand Down Expand Up @@ -1101,7 +1102,9 @@ def _check_fif(self, filetype, fname):
return True

def _configure_dock(self):
self._renderer._dock_initialize(name="Input", area="left")
self._renderer._dock_initialize(
name="Input", area="left", max_width="350px"
)
mri_subject_layout = self._renderer._dock_add_group_box("MRI Subject")
self._widgets["subjects_dir"] = self._renderer._dock_add_file_button(
name="subjects_dir",
Expand Down Expand Up @@ -1237,7 +1240,9 @@ def _configure_dock(self):
)
self._renderer._dock_add_stretch()

self._renderer._dock_initialize(name="Parameters", area="right")
self._renderer._dock_initialize(
name="Parameters", area="right", max_width="350px"
)
mri_scaling_layout = \
self._renderer._dock_add_group_box(name="MRI Scaling")
self._widgets["scaling_mode"] = self._renderer._dock_add_combo_box(
Expand Down Expand Up @@ -1353,6 +1358,8 @@ def _configure_dock(self):
input_text_widget=False,
tooltip="Save the transform file to disk",
layout=save_trans_layout,
filter='Head->MRI transformation (*-trans.fif *_trans.fif)',
initial_directory=str(Path(self._info_file).parent),
)
self._widgets["load_trans"] = self._renderer._dock_add_file_button(
name="load_trans",
Expand All @@ -1361,6 +1368,8 @@ def _configure_dock(self):
input_text_widget=False,
tooltip="Load the transform file from disk",
layout=save_trans_layout,
filter='Head->MRI transformation (*-trans.fif *_trans.fif)',
initial_directory=str(Path(self._info_file).parent),
)
self._widgets["reset_trans"] = self._renderer._dock_add_button(
name="Reset",
Expand Down

0 comments on commit 9396ca7

Please sign in to comment.