Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fslgui
Commits
0479059a
Commit
0479059a
authored
Mar 20, 2020
by
Taylor Hanayik
Browse files
fine tune bet and start flirt gui
parent
3fc46784
Changes
5
Hide whitespace changes
Inline
Side-by-side
fsl/gui/guis.py
View file @
0479059a
...
...
@@ -165,3 +165,31 @@ class BetGui(BaseGui):
self
.
_on_code
(
None
)
self
.
model
.
run
(
self
.
_load_result
)
class
FlirtGui
(
BaseGui
):
"""
The FlirtGui is the controller for the FlirtView that
can interact with the flirt model
"""
def
__init__
(
self
,
parent
,
title
=
"FLIRT"
,
model
=
None
):
super
().
__init__
()
if
model
is
None
:
self
.
model
=
fsltools
.
Flirt
()
self
.
view
=
fslviews
.
FlirtView
(
parent
,
title
)
self
.
view
.
mode_choice
.
AppendItems
(
self
.
model
.
flirt_type_choices
)
# bind events
self
.
view
.
mode_choice
.
Bind
(
wx
.
EVT_CHOICE
,
self
.
_on_mode_choice
)
def
_on_mode_choice
(
self
,
event
):
widget
=
event
.
GetEventObject
()
idx
=
widget
.
GetSelection
()
choice_str
=
widget
.
GetString
(
idx
)
if
'lowres'
in
choice_str
:
self
.
view
.
input_lowres
.
Show
()
self
.
_layout_from
(
self
.
view
.
input_lowres
)
else
:
self
.
view
.
input_lowres
.
Hide
()
self
.
_layout_from
(
self
.
view
.
input_lowres
)
\ No newline at end of file
fsl/gui/scripts/Flirt_gui
0 → 100755
View file @
0479059a
#!/usr/bin/env pythonw
import
wx
import
sys
from
fsl.gui.guis
import
FlirtGui
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
"FSL's FLIRT"
)
parser
.
add_argument
(
'-input'
,
default
=
""
,
type
=
str
,
required
=
False
,
help
=
"an input image file"
)
def
main
():
args
=
parser
.
parse_args
()
# get an app instance
app
=
wx
.
App
()
frame
=
wx
.
Frame
(
None
,
size
=
(
800
,
600
))
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
flirt_gui
=
FlirtGui
(
frame
,
"FLIRT"
)
sizer
.
Add
(
flirt_gui
.
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
())
\ No newline at end of file
fsl/gui/tools.py
View file @
0479059a
...
...
@@ -13,7 +13,7 @@ from fsl.utils import idle
class
Bet
:
class
Bet
(
object
)
:
"""
A BetModel contains the data and methods necessary to setup and run FSL's bet tool.
The BetModel can be queried and properties can be set via a controller of a GUI view object
...
...
@@ -36,7 +36,7 @@ class Bet:
bet_type
=
""
,
fval
=
0.5
,
gval
=
0
,
center_coord
=
(),
center_coord
=
(
0
,
0
,
0
),
discard_bet
=
False
,
save_mask
=
False
,
applythresh
=
False
,
...
...
@@ -270,3 +270,12 @@ class Bet:
cmd
.
append
(
self
.
bet_type
)
print
(
" "
.
join
(
cmd
))
return
cmd
class
Flirt
(
object
):
flirt_type_choices
=
[
"highres to standard"
,
"lowres to highres to standard"
]
def
__init__
(
self
,
in_highres
=
""
):
pass
\ No newline at end of file
fsl/gui/views.py
View file @
0479059a
...
...
@@ -139,15 +139,53 @@ class BetView(wx.Panel):
self
.
SetSizer
(
sizer
)
class
FlirtView
():
class
FlirtView
(
wx
.
Panel
):
"""
FlirtView defines the graphical layout of widgets used in Flirt
"""
def
__init__
(
self
,
parent
,
title
=
"FLIRT"
,
**
kwargs
):
super
().
__init__
(
parent
,
**
kwargs
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
# title panel
#------------
self
.
title_panel
=
fslwidgets
.
Title
(
self
,
title
)
sizer
.
Add
(
self
.
title_panel
,
proportion
=
0
,
flag
=
wx
.
ALIGN_CENTER
|
wx
.
ALL
,
border
=
5
)
# mode selection panel
#---------------------
mode_panel
=
wx
.
Panel
(
self
)
mode_sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
mode_st
=
wx
.
StaticText
(
mode_panel
,
label
=
"Mode"
)
# make mode_choice an attribute to be updated by the controller
self
.
mode_choice
=
wx
.
Choice
(
mode_panel
,
choices
=
[])
mode_sizer
.
Add
(
mode_st
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
mode_sizer
.
Add
(
self
.
mode_choice
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
mode_panel
.
SetSizer
(
mode_sizer
)
sizer
.
Add
(
mode_panel
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
# low res input panel (hidden when mode is highres to standard)
self
.
input_lowres
=
fslwidgets
.
Input
(
self
).
set_label
(
"Lowres image*"
)
sizer
.
Add
(
self
.
input_lowres
,
proportion
=
0
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
self
.
input_lowres
.
Hide
()
# high res input panel
self
.
input_highres
=
fslwidgets
.
Input
(
self
).
set_label
(
"Highres image*"
)
sizer
.
Add
(
self
.
input_highres
,
proportion
=
0
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
# reference image picker panel
self
.
input_reference
=
fslwidgets
.
ReferencePicker
(
self
).
set_label
(
"Reference image*"
)
sizer
.
Add
(
self
.
input_reference
,
proportion
=
0
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
self
.
SetSizer
(
sizer
)
class
FslView
():
"""
FslView is the main FSL start window.
FslView is the main FSL start window. not to be
confused with the deprecated image viewer fslview (RIP)
"""
fsl/gui/widgets.py
View file @
0479059a
...
...
@@ -3,6 +3,7 @@ the widges module provides common widgets that are intended
to be embedded within other FSL guis.
"""
import
os
import
subprocess
import
wx
import
fsleyes.overlay
as
fsloverlay
...
...
@@ -12,6 +13,8 @@ from fsleyes.main import embed
import
fsleyes.profiles
as
profiles
import
fsleyes.profiles.profilemap
as
profilemap
from
fsleyes.frame
import
FSLeyesFrame
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
...
...
@@ -27,15 +30,31 @@ def layout_from(widget):
if
widget
.
IsTopLevel
():
break
class
FileDropTextCtrl
(
wx
.
FileDropTarget
):
"""
Drop target specifically for wx.TextCtrl widgets.
It's specific because it expects window to have a SetValue method
"""
def
__init__
(
self
,
window
):
wx
.
FileDropTarget
.
__init__
(
self
)
self
.
window
=
window
def
OnDropFiles
(
self
,
x
,
y
,
filenames
):
# only use the first file if multiple are dropped at once
self
.
window
.
SetValue
(
filenames
[
0
])
return
True
class
Input
(
wx
.
Panel
):
def
__init__
(
self
,
*
ar
gs
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
def
__init__
(
self
,
p
ar
ent
,
**
kwargs
):
wx
.
Panel
.
__init__
(
self
,
parent
)
self
.
file_path
=
""
#sizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, "Input image*")
self
.
box
=
wx
.
StaticBox
(
self
,
label
=
""
)
sizer
=
wx
.
StaticBoxSizer
(
self
.
box
)
self
.
button
=
wx
.
Button
(
self
.
box
,
label
=
"Choose"
)
self
.
file_ctrl
=
wx
.
TextCtrl
(
self
.
box
,
value
=
""
)
drop_target
=
FileDropTextCtrl
(
self
.
file_ctrl
)
self
.
file_ctrl
.
SetDropTarget
(
drop_target
)
sizer
.
Add
(
self
.
file_ctrl
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
sizer
.
Add
(
self
.
button
,
0
,
wx
.
ALL
,
5
)
self
.
SetSizer
(
sizer
)
...
...
@@ -61,6 +80,75 @@ class Input(wx.Panel):
self
.
file_path
=
os
.
path
.
abspath
(
fd
.
GetPath
())
self
.
set_text
(
self
.
file_path
)
class
ReferencePicker
(
wx
.
Panel
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
file_path
=
""
#sizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, "Input image*")
self
.
box
=
wx
.
StaticBox
(
self
,
label
=
"Reference image"
)
sizer
=
wx
.
StaticBoxSizer
(
self
.
box
,
orient
=
wx
.
VERTICAL
)
input_panel
=
wx
.
Panel
(
self
.
box
)
input_panel_sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
choose_button
=
wx
.
Button
(
input_panel
,
label
=
"Choose"
)
self
.
file_ctrl
=
wx
.
TextCtrl
(
input_panel
,
value
=
""
)
input_panel_sizer
.
Add
(
self
.
file_ctrl
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
input_panel_sizer
.
Add
(
self
.
choose_button
,
0
,
wx
.
ALL
,
5
)
input_panel
.
SetSizer
(
input_panel_sizer
)
button_panel
=
wx
.
Panel
(
self
.
box
)
button_panel_sizer
=
wx
.
BoxSizer
(
wx
.
HORIZONTAL
)
self
.
btn_1mm_brain
=
wx
.
Button
(
button_panel
,
label
=
"standard_1mm_brain"
)
self
.
btn_2mm_brain
=
wx
.
Button
(
button_panel
,
label
=
"standard_2mm_brain"
)
button_panel_sizer
.
Add
(
self
.
btn_1mm_brain
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
button_panel_sizer
.
Add
(
self
.
btn_2mm_brain
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
button_panel
.
SetSizer
(
button_panel_sizer
)
sizer
.
Add
(
input_panel
,
proportion
=
0
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
sizer
.
Add
(
button_panel
,
proportion
=
0
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
self
.
SetSizer
(
sizer
)
self
.
choose_button
.
Bind
(
wx
.
EVT_LEFT_UP
,
self
.
_on_choose
)
self
.
btn_1mm_brain
.
Bind
(
wx
.
EVT_LEFT_UP
,
self
.
_on_1mm_brain
)
self
.
btn_2mm_brain
.
Bind
(
wx
.
EVT_LEFT_UP
,
self
.
_on_2mm_brain
)
def
set_label
(
self
,
text
):
self
.
box
.
SetLabel
(
text
)
layout_from
(
self
.
box
)
return
self
def
set_text
(
self
,
text
):
self
.
file_ctrl
.
SetValue
(
text
)
return
self
def
get_path
(
self
):
return
self
.
file_ctrl
.
GetValue
()
def
_on_choose
(
self
,
event
):
with
wx
.
FileDialog
(
self
,
"Choose input file"
,
style
=
wx
.
FD_OPEN
)
as
fd
:
if
fd
.
ShowModal
()
==
wx
.
ID_CANCEL
:
return
self
.
file_path
=
os
.
path
.
abspath
(
fd
.
GetPath
())
self
.
set_text
(
self
.
file_path
)
def
_on_1mm_brain
(
self
,
event
):
self
.
file_path
=
os
.
path
.
join
(
fslplatform
.
fsldir
,
"data"
,
"standard"
,
"MNI152_T1_1mm_brain.nii.gz"
)
self
.
set_text
(
self
.
file_path
)
def
_on_2mm_brain
(
self
,
event
):
self
.
file_path
=
os
.
path
.
join
(
fslplatform
.
fsldir
,
"data"
,
"standard"
,
"MNI152_T1_2mm_brain.nii.gz"
)
self
.
set_text
(
self
.
file_path
)
class
Output
(
wx
.
Panel
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -218,9 +306,32 @@ class OrthoView(wx.CollapsiblePane):
None
)
self
.
op
.
SetMinSize
((
-
1
,
300
))
self
.
op
.
Show
()
sizer
.
Add
(
self
.
op
,
1
,
wx
.
EXPAND
|
wx
.
ALL
,
5
)
self
.
btn_fsleyes
=
wx
.
Button
(
pane
,
label
=
"Open in FSLeyes"
)
sizer
.
Add
(
self
.
btn_fsleyes
,
proportion
=
0
,
flag
=
wx
.
ALL
,
border
=
5
)
sizer
.
Add
(
self
.
op
,
proportion
=
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
pane
.
SetSizer
(
sizer
)
# bind events
self
.
btn_fsleyes
.
Bind
(
wx
.
EVT_BUTTON
,
self
.
launch_fsleyes
)
def
_run_fsleyes
(
self
):
imgs
=
[
img
.
dataSource
for
img
in
self
.
overlayList
]
# print([img.dataSource for img in self.overlayList])
cmd
=
[
os
.
path
.
join
(
fslplatform
.
fsldir
,
'bin'
,
'fsleyes'
),
" "
.
join
(
imgs
)
]
subprocess
.
run
(
" "
.
join
(
cmd
),
shell
=
True
,
check
=
True
)
def
launch_fsleyes
(
self
,
event
):
thread_id
=
idle
.
run
(
self
.
_run_fsleyes
)
def
reset
(
self
):
self
.
overlayList
.
clear
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment