Skip to content

Commit

Permalink
Merge pull request #853 from invesalius/brain-mapping-dims-size-prefe…
Browse files Browse the repository at this point in the history
…rences

Brain mapping dims size preferences
  • Loading branch information
rmatsuda authored Sep 30, 2024
2 parents b0dbaf1 + ef746eb commit 1c4b99f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions invesalius/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@
"mep_colormap": "Viridis",
"gaussian_sharpness": 0.4,
"gaussian_radius": 20,
"dimensions_size": 20,
"bounds": None,
"colormap_range_uv": {"min": 50, "low": 200, "mid": 600, "max": 1000},
}
Expand Down
4 changes: 1 addition & 3 deletions invesalius/data/visualization/mep_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ def __init__(self):

self.is_navigating = False

self.dims_size = 20

self._config_params = deepcopy(const.DEFAULT_MEP_CONFIG_PARAMS)
self.__bind_events()
self._LoadUserParameters()
Expand Down Expand Up @@ -193,7 +191,7 @@ def InterpolateData(self):
bounds = np.array(self._config_params["bounds"])
gaussian_sharpness = self._config_params["gaussian_sharpness"]
gaussian_radius = self._config_params["gaussian_radius"]
dims_size = self.dims_size
dims_size = self._config_params["dimensions_size"]
dims = np.array([dims_size, dims_size, dims_size])

box = vtkImageData()
Expand Down
29 changes: 29 additions & 0 deletions invesalius/gui/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,29 @@ def InitMEPMapping(self, event):
]
)

# Dimensions size line
lbl_dims_size = wx.StaticText(bsizer_mep.GetStaticBox(), -1, _("Dimensions size:"))
self.spin_dims_size = wx.SpinCtrl(bsizer_mep.GetStaticBox(), -1, "", size=wx.Size(64, 23))
self.spin_dims_size.Enable(1)
self.spin_dims_size.SetIncrement(5)
self.spin_dims_size.SetRange(10, 100)
self.spin_dims_size.SetValue(self.conf.get("dimensions_size"))

self.spin_dims_size.Bind(
wx.EVT_TEXT, partial(self.OnSelectDimsSize, ctrl=self.spin_dims_size)
)
self.spin_dims_size.Bind(
wx.EVT_SPINCTRL, partial(self.OnSelectDimsSize, ctrl=self.spin_dims_size)
)

line_dims_size = wx.BoxSizer(wx.HORIZONTAL)
line_dims_size.AddMany(
[
(lbl_dims_size, 1, wx.EXPAND | wx.GROW | wx.TOP | wx.RIGHT | wx.LEFT, 0),
(self.spin_dims_size, 0, wx.ALL | wx.EXPAND | wx.GROW, 0),
]
)

# Select Colormap Line
lbl_colormap = wx.StaticText(bsizer_mep.GetStaticBox(), -1, _("Select Colormap:"))
lbl_colormap.SetFont(wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.BOLD))
Expand Down Expand Up @@ -477,6 +500,7 @@ def InitMEPMapping(self, event):
(surface_sel_sizer, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5),
(line_gaussian_radius, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5),
(line_std_dev, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5),
(line_dims_size, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5),
(colormap_sizer, 0, wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5),
]
)
Expand Down Expand Up @@ -515,6 +539,11 @@ def OnSelectGaussianRadius(self, evt, ctrl):
# Save the configuration
self.session.SetConfig("mep_configuration", self.conf)

def OnSelectDimsSize(self, evt, ctrl):
self.conf["dimensions_size"] = ctrl.GetValue()
# Save the configuration
self.session.SetConfig("mep_configuration", self.conf)

def OnSelectColormapRange(self, evt, ctrl, key):
self.conf["colormap_range_uv"][key] = ctrl.GetValue()
self.session.SetConfig("mep_configuration", self.conf)
Expand Down

0 comments on commit 1c4b99f

Please sign in to comment.