Commit e2c39d009468f5f6f5a2b036ebd8fa7a6959ca10
1 parent
34cd93f5
Exists in
command-line
Create option to open InVesalius without gui
Showing
5 changed files
with
62 additions
and
25 deletions
Show diff stats
app.py
| ... | ... | @@ -198,7 +198,8 @@ class SplashScreen(wx.SplashScreen): |
| 198 | 198 | self.control = Controller(self.main) |
| 199 | 199 | |
| 200 | 200 | self.fc = wx.FutureCall(1, self.ShowMain) |
| 201 | - wx.FutureCall(1, parse_comand_line) | |
| 201 | + options, args = parse_comand_line() | |
| 202 | + wx.FutureCall(1, use_cmd_optargs, options, args) | |
| 202 | 203 | |
| 203 | 204 | # Check for updates |
| 204 | 205 | from threading import Thread |
| ... | ... | @@ -224,6 +225,24 @@ class SplashScreen(wx.SplashScreen): |
| 224 | 225 | if self.fc.IsRunning(): |
| 225 | 226 | self.Raise() |
| 226 | 227 | |
| 228 | + | |
| 229 | +def non_gui_startup(options, args): | |
| 230 | + lang = 'en' | |
| 231 | + _ = i18n.InstallLanguage(lang) | |
| 232 | + | |
| 233 | + from invesalius.control import Controller | |
| 234 | + from invesalius.project import Project | |
| 235 | + | |
| 236 | + session = ses.Session() | |
| 237 | + if not session.ReadSession(): | |
| 238 | + session.CreateItens() | |
| 239 | + session.SetLanguage(lang) | |
| 240 | + session.WriteSessionFile() | |
| 241 | + | |
| 242 | + control = Controller(None) | |
| 243 | + | |
| 244 | + use_cmd_optargs(options, args) | |
| 245 | + | |
| 227 | 246 | # ------------------------------------------------------------------ |
| 228 | 247 | |
| 229 | 248 | |
| ... | ... | @@ -241,6 +260,10 @@ def parse_comand_line(): |
| 241 | 260 | action="store_true", |
| 242 | 261 | dest="debug") |
| 243 | 262 | |
| 263 | + parser.add_option('--no-gui', | |
| 264 | + action='store_true', | |
| 265 | + dest='no_gui') | |
| 266 | + | |
| 244 | 267 | # -i or --import: import DICOM directory |
| 245 | 268 | # chooses largest series |
| 246 | 269 | parser.add_option("-i", "--import", |
| ... | ... | @@ -254,7 +277,10 @@ def parse_comand_line(): |
| 254 | 277 | help="To open a project and export it to STL for all mask presets.") |
| 255 | 278 | |
| 256 | 279 | options, args = parser.parse_args() |
| 280 | + return options, args | |
| 281 | + | |
| 257 | 282 | |
| 283 | +def use_cmd_optargs(options, args): | |
| 258 | 284 | # If debug argument... |
| 259 | 285 | if options.debug: |
| 260 | 286 | Publisher.subscribe(print_events, Publisher.ALL_TOPICS) |
| ... | ... | @@ -333,8 +359,13 @@ def main(): |
| 333 | 359 | """ |
| 334 | 360 | Initialize InVesalius GUI |
| 335 | 361 | """ |
| 336 | - application = InVesalius(0) | |
| 337 | - application.MainLoop() | |
| 362 | + options, args = parse_comand_line() | |
| 363 | + | |
| 364 | + if options.no_gui: | |
| 365 | + non_gui_startup(options, args) | |
| 366 | + else: | |
| 367 | + application = InVesalius(0) | |
| 368 | + application.MainLoop() | |
| 338 | 369 | |
| 339 | 370 | if __name__ == '__main__': |
| 340 | 371 | #Is needed because of pyinstaller | ... | ... |
invesalius/constants.py
| ... | ... | @@ -686,19 +686,19 @@ BTNS_IMG_MKS = {IR1: {0: 'LEI'}, |
| 686 | 686 | IR2: {1: 'REI'}, |
| 687 | 687 | IR3: {2: 'NAI'}} |
| 688 | 688 | |
| 689 | -TIPS_IMG = [wx.ToolTip(_("Select left ear in image")), | |
| 690 | - wx.ToolTip(_("Select right ear in image")), | |
| 691 | - wx.ToolTip(_("Select nasion in image"))] | |
| 689 | +TIPS_IMG = [_("Select left ear in image"), | |
| 690 | + _("Select right ear in image"), | |
| 691 | + _("Select nasion in image")] | |
| 692 | 692 | |
| 693 | 693 | BTNS_TRK = {TR1: {3: _('LET')}, |
| 694 | 694 | TR2: {4: _('RET')}, |
| 695 | 695 | TR3: {5: _('NAT')}, |
| 696 | 696 | SET: {6: _('SET')}} |
| 697 | 697 | |
| 698 | -TIPS_TRK = [wx.ToolTip(_("Select left ear with spatial tracker")), | |
| 699 | - wx.ToolTip(_("Select right ear with spatial tracker")), | |
| 700 | - wx.ToolTip(_("Select nasion with spatial tracker")), | |
| 701 | - wx.ToolTip(_("Show set coordinates in image"))] | |
| 698 | +TIPS_TRK = [_("Select left ear with spatial tracker"), | |
| 699 | + _("Select right ear with spatial tracker"), | |
| 700 | + _("Select nasion with spatial tracker"), | |
| 701 | + _("Show set coordinates in image")] | |
| 702 | 702 | |
| 703 | 703 | CAL_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'CalibrationFiles')) |
| 704 | 704 | MAR_DIR = os.path.abspath(os.path.join(FILE_PATH, '..', 'navigation', 'mtc_files', 'Markers')) | ... | ... |
invesalius/data/slice_.py
| ... | ... | @@ -353,19 +353,22 @@ class Slice(object): |
| 353 | 353 | |
| 354 | 354 | # TODO: merge this code with apply_slice_buffer_to_mask |
| 355 | 355 | b_mask = self.buffer_slices["AXIAL"].mask |
| 356 | - n = self.buffer_slices["AXIAL"].index + 1 | |
| 357 | - self.current_mask.matrix[n, 1:, 1:] = b_mask | |
| 358 | - self.current_mask.matrix[n, 0, 0] = 1 | |
| 356 | + if b_mask: | |
| 357 | + n = self.buffer_slices["AXIAL"].index + 1 | |
| 358 | + self.current_mask.matrix[n, 1:, 1:] = b_mask | |
| 359 | + self.current_mask.matrix[n, 0, 0] = 1 | |
| 359 | 360 | |
| 360 | 361 | b_mask = self.buffer_slices["CORONAL"].mask |
| 361 | - n = self.buffer_slices["CORONAL"].index + 1 | |
| 362 | - self.current_mask.matrix[1:, n, 1:] = b_mask | |
| 363 | - self.current_mask.matrix[0, n, 0] = 1 | |
| 362 | + if b_mask: | |
| 363 | + n = self.buffer_slices["CORONAL"].index + 1 | |
| 364 | + self.current_mask.matrix[1:, n, 1:] = b_mask | |
| 365 | + self.current_mask.matrix[0, n, 0] = 1 | |
| 364 | 366 | |
| 365 | 367 | b_mask = self.buffer_slices["SAGITAL"].mask |
| 366 | - n = self.buffer_slices["SAGITAL"].index + 1 | |
| 367 | - self.current_mask.matrix[1:, 1:, n] = b_mask | |
| 368 | - self.current_mask.matrix[0, 0, n] = 1 | |
| 368 | + if b_mask: | |
| 369 | + n = self.buffer_slices["SAGITAL"].index + 1 | |
| 370 | + self.current_mask.matrix[1:, 1:, n] = b_mask | |
| 371 | + self.current_mask.matrix[0, 0, n] = 1 | |
| 369 | 372 | |
| 370 | 373 | if to_reload: |
| 371 | 374 | Publisher.sendMessage('Reload actual slice') |
| ... | ... | @@ -882,8 +885,8 @@ class Slice(object): |
| 882 | 885 | self.current_mask.matrix[n+1, 1:, 1:] = m |
| 883 | 886 | else: |
| 884 | 887 | slice_ = self.buffer_slices[orientation].image |
| 885 | - print ">>>", slice_, index | |
| 886 | - self.buffer_slices[orientation].mask = (255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max))).astype('uint8') | |
| 888 | + if slice_: | |
| 889 | + self.buffer_slices[orientation].mask = (255 * ((slice_ >= thresh_min) & (slice_ <= thresh_max))).astype('uint8') | |
| 887 | 890 | |
| 888 | 891 | # Update viewer |
| 889 | 892 | #Publisher.sendMessage('Update slice viewer') | ... | ... |
invesalius/data/vtk_utils.py
| ... | ... | @@ -44,7 +44,10 @@ def ShowProgress(number_of_filters = 1, |
| 44 | 44 | progress = [0] |
| 45 | 45 | last_obj_progress = [0] |
| 46 | 46 | if (dialog_type == "ProgressDialog"): |
| 47 | - dlg = ProgressDialog(100) | |
| 47 | + try: | |
| 48 | + dlg = ProgressDialog(100) | |
| 49 | + except wx._core.PyNoAppError: | |
| 50 | + return lambda obj, label: 0 | |
| 48 | 51 | |
| 49 | 52 | |
| 50 | 53 | # when the pipeline is larger than 1, we have to consider this object | ... | ... |
invesalius/gui/task_navigator.py
| ... | ... | @@ -247,7 +247,7 @@ class NeuronavigationPanel(wx.Panel): |
| 247 | 247 | n = btns_img[k].keys()[0] |
| 248 | 248 | lab = btns_img[k].values()[0] |
| 249 | 249 | self.btns_coord[n] = wx.ToggleButton(self, k, label=lab, size=wx.Size(45, 23)) |
| 250 | - self.btns_coord[n].SetToolTip(tips_img[n]) | |
| 250 | + self.btns_coord[n].SetToolTip(wx.ToolTip(tips_img[n])) | |
| 251 | 251 | self.btns_coord[n].Bind(wx.EVT_TOGGLEBUTTON, self.OnImageFiducials) |
| 252 | 252 | |
| 253 | 253 | # Push buttons for tracker fiducials |
| ... | ... | @@ -258,7 +258,7 @@ class NeuronavigationPanel(wx.Panel): |
| 258 | 258 | n = btns_trk[k].keys()[0] |
| 259 | 259 | lab = btns_trk[k].values()[0] |
| 260 | 260 | self.btns_coord[n] = wx.Button(self, k, label=lab, size=wx.Size(45, 23)) |
| 261 | - self.btns_coord[n].SetToolTip(tips_trk[n-3]) | |
| 261 | + self.btns_coord[n].SetToolTip(wx.ToolTip(tips_trk[n-3])) | |
| 262 | 262 | # Excepetion for event of button that set image coordinates |
| 263 | 263 | if n == 6: |
| 264 | 264 | self.btns_coord[n].Bind(wx.EVT_BUTTON, self.OnSetImageCoordinates) |
| ... | ... | @@ -796,4 +796,4 @@ class MarkersPanel(wx.Panel): |
| 796 | 796 | while len(selection) != self.lc.GetSelectedItemCount(): |
| 797 | 797 | index = self.lc.GetNextSelected(index) |
| 798 | 798 | selection.append(index) |
| 799 | - return selection | |
| 800 | 799 | \ No newline at end of file |
| 800 | + return selection | ... | ... |