Commit b53da43e authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

script updates

parent e538e4fb
......@@ -5,6 +5,7 @@
# Author: Taylor Hanayik <hanayik@gmail.com>
import os
import random
import wx
from fsl.data import image
......@@ -34,6 +35,19 @@ class BaseGui(object):
if widget.IsTopLevel():
break
@staticmethod
def _set_rainbow(widget):
"""
set the background of all panels to a random colour... I call it random unicorn mode
"""
win = wx.GetTopLevelParent(widget)
while win.GetChildren():
children = win.GetChildren()
for win in children:
attr = getattr(win, 'SetBackgroundColour', None)
if callable(attr):
win.SetBackgroundColour(wx.Colour(random.randint(0,255), random.randint(0,255), random.randint(0,255)))
def layout_from(self, event):
self._layout_from(event.GetEventObject())
......@@ -178,6 +192,7 @@ class FlirtGui(BaseGui):
self.model = fsltools.Flirt()
self.view = fslviews.FlirtView(parent, title)
self.view.mode_choice.AppendItems(self.model.flirt_type_choices)
# bind events
......
#!/usr/bin/env python
import wx
import sys
from fsl.gui.guis import BetGui
import argparse
parser = argparse.ArgumentParser(description="FSL's brain extraction tool")
parser.add_argument(
'-input',
default="",
type=str,
required=False,
help="an input image file"
)
parser.add_argument(
"-output",
default="",
required=False,
type=str,
help="the output name for the brain extracted image(s)"
)
parser.add_argument(
"-o",
action='store_false',
required=False,
help="generate brain surface outline overlaid onto original image"
)
parser.add_argument(
"-m",
action='store_false',
required=False,
help="generate binary brain mask"
)
parser.add_argument(
"-s",
action='store_false',
required=False,
help="generate approximate skull image"
)
parser.add_argument(
"-n",
action='store_false',
required=False,
help="do not save segmented brain image"
)
parser.add_argument(
"-f",
default=0.5,
type=float,
required=False,
help="do not save segmented brain image"
)
def main():
args = parser.parse_args()
# get an app instance
app = wx.App()
# get our wx.Frame (this bet window will not be embedded in a panel)
# betview = BetView(
# parent=None,
# in_img=args.input,
# out_img=args.output,
# o_opt=args.o,
# m_opt=args.m,
# s_opt=args.s,
# n_opt=args.n,
# f_opt=args.f) # parent=None will return a wx.Frame
# betview.window.Show()
frame = wx.Frame(None, size=(800, 600))
sizer = wx.BoxSizer(wx.VERTICAL)
controller = BetGui(frame, "BET")
sizer.Add(controller.view, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
frame.SetSizer(sizer)
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/env python
import wx
import sys
from fsl.gui.guis import BetGui
import argparse
parser = argparse.ArgumentParser(description="FSL's brain extraction tool")
def main():
args = parser.parse_args()
app = wx.App()
frame = wx.Frame(None, size=(800, 600))
sizer = wx.BoxSizer(wx.VERTICAL)
betgui = BetGui(frame, "BET")
sizer.Add(betgui.view, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
frame.SetSizer(sizer)
frame.Centre()
frame.Show()
app.MainLoop()
if __name__ == "__main__":
sys.exit(main())
......@@ -6,19 +6,83 @@ import os
import subprocess
import wx
import fsleyes
import fsleyes.overlay as fsloverlay
import fsleyes.displaycontext as fsldc
import fsleyes.views.orthopanel as orthopanel
from fsleyes.main import embed
import fsleyes.profiles as profiles
import fsleyes.profiles.profilemap as profilemap
from fsleyes.frame import FSLeyesFrame
import fsleyes.colourmaps as colourmaps
from fsl.utils.platform import platform as fslplatform
from fsl.utils import idle
import fsl.data.image as fslimage
import fsl.gui.icons as fslicons
def _embed(parent=None, make_fsleyesframe=True, **kwargs):
"""Initialise FSLeyes and create a :class:`.FSLeyesFrame`, when
running within another application.
.. note:: If a ``wx.App`` does not exist, one is created.
:arg parent: ``wx`` parent object
:arg make_fsleyesframe: bool, default is True to make a new :class:`.FSLeyesFrame`
:returns: A tuple containing:
- The :class:`.OverlayList`
- The master :class:`.DisplayContext`
- The :class:`.FSLeyesFrame` or None if make_fsleyesframe=False
All other arguments are passed to :meth:`.FSLeyesFrame.__init__`.
"""
import fsleyes_props as props
import fsleyes.gl as fslgl
import fsleyes.frame as fslframe
import fsleyes.overlay as fsloverlay
import fsleyes.displaycontext as fsldc
app = wx.GetApp()
ownapp = app is None
if ownapp:
app = FSLeyesApp()
fsleyes.initialise()
colourmaps.init()
props.initGUI()
called = [False]
ret = [None]
def until():
return called[0]
def ready():
frame = None
fslgl.bootstrap()
overlayList = fsloverlay.OverlayList()
displayCtx = fsldc.DisplayContext(overlayList)
if make_fsleyesframe:
frame = fslframe.FSLeyesFrame(
parent, overlayList, displayCtx, **kwargs)
if ownapp:
app.SetOverlayListAndDisplayContext(overlayList, displayCtx)
# Keep a ref to prevent the app from being GC'd
if make_fsleyesframe:
frame._embed_app = app
called[0] = True
ret[0] = (overlayList, displayCtx, frame)
fslgl.getGLContext(parent=parent, ready=ready)
idle.block(10, until=until)
if ret[0] is None:
raise RuntimeError('Failed to start FSLeyes')
return ret[0]
def layout_from(widget):
"""
redo layout of all widgets up the parent tree from this widget.
......@@ -285,17 +349,16 @@ class ViewProfile(profiles.Profile):
profilemap.profiles[orthopanel.OrthoPanel].insert(0, 'minview')
profilemap.profileHandlers[orthopanel.OrthoPanel, 'minview'] = ViewProfile
def nomenu(*a):
pass
FSLeyesFrame._FSLeyesFrame__makeMenuBar = nomenu
# def nomenu(*a):
# pass
# FSLeyesFrame._FSLeyesFrame__makeMenuBar = nomenu
class OrthoView(wx.CollapsiblePane):
def __init__(self, parent, **kwargs):
super().__init__(parent, **kwargs)
pane = self.GetPane()
self.overlayList, masterDisplayCtx, frame = embed(None)
frame = None
self.overlayList, masterDisplayCtx, _ = _embed(None, make_fsleyesframe=False)
self.displayCtx = fsldc.DisplayContext(self.overlayList, parent=masterDisplayCtx)
sizer = wx.BoxSizer(wx.VERTICAL)
......
......@@ -9,7 +9,7 @@ PyOpenGL>=3.1.0
pyparsing==2.*
scipy>=0.18
wxPython>=3.0.2.0
fslpy>=2.8.4
fslpy>=3.0.0
fsleyes>=0.32.3
fsleyes-props>=1.6.7
fsleyes-widgets>=0.8.4
......
......@@ -7,7 +7,7 @@ with open('requirements.txt', 'rt') as f:
setup(
name='fslgui',
version='0.0.0.dev7',
version='0.0.0.dev8',
description='fslgui',
url='https://git.fmrib.ox.ac.uk/fsl/fslgui',
author='Taylor Hanayik',
......@@ -27,8 +27,8 @@ setup(
include_package_data=True,
entry_points={
'console_scripts' : [
'bet_gui = fsl.gui.scripts.Bet_gui:main',
'flirt_gui = fsl.gui.scripts.Flirt_gui:main'
'bet_gui = fsl.gui.scripts.bet_gui:main',
'flirt_gui = fsl.gui.scripts.flirt_gui:main'
]
},
package_data={
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment