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
3964aabc
Commit
3964aabc
authored
Jun 02, 2020
by
Taylor Hanayik
Browse files
remove pnm_gui from core project
parent
932037fd
Changes
6
Hide whitespace changes
Inline
Side-by-side
fsl/gui/core.py
View file @
3964aabc
...
...
@@ -11,7 +11,6 @@ import yaml
import
fsleyes_props
as
props
import
fsl.gui.exceptions
as
fslerrs
import
fsl.gui.views
as
fslviews
import
fsl.gui.widgets
as
fslwidgets
allowedContainerWidgets
=
(
...
...
fsl/gui/guis.py
deleted
100644 → 0
View file @
932037fd
#!/usr/bin/env python
#
# bet_gui.py
#
# Author: Taylor Hanayik <hanayik@gmail.com>
import
os
import
random
import
wx
from
fsl.data
import
image
import
fsleyes_props
as
props
#from fsleyes_props.build import buildGUI
props
.
initGUI
()
import
fsl.gui.views
as
fslviews
import
fsl.gui.tools
as
fsltools
class
BaseGui
(
object
):
"""
BaseGui is the parent class for all FSL GUIs.
Common functionality and attributes are implemented here.
"""
def
__init__
(
self
):
# maybe add some other common funcionality here
pass
@
staticmethod
def
_layout_from
(
widget
):
"""
redo layout of all widgets up the parent tree from this widget.
Stop when we get to a frame. This was taken from a wx wiki post
"""
while
widget
.
GetParent
():
widget
=
widget
.
GetParent
()
widget
.
Layout
()
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
())
class
BetGui
(
BaseGui
):
"""
Bet GUI is the controller of the BetView that can interact with the BetModel
"""
def
__init__
(
self
,
parent
,
title
=
"BET"
,
model
=
None
):
super
().
__init__
()
if
model
is
None
:
# set the model
self
.
model
=
fsltools
.
Bet
()
# set the view
self
.
view
=
fslviews
.
BetView
(
parent
,
title
)
# update the view with some model data
self
.
view
.
options
.
choice_btype
.
AppendItems
(
list
(
self
.
model
.
bet_type_choices
.
keys
()))
# bind events and their handlers
self
.
view
.
Bind
(
wx
.
EVT_COLLAPSIBLEPANE_CHANGED
,
self
.
layout_from
)
self
.
view
.
options
.
choice_btype
.
Bind
(
wx
.
EVT_CHOICE
,
self
.
_on_bet_choice
)
self
.
view
.
options
.
cb_save_bet
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
_on_save_bet
)
self
.
view
.
options
.
cb_apply_thr
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
_on_apply_thr
)
self
.
view
.
options
.
cb_save_mask
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
_on_save_mask
)
self
.
view
.
options
.
cb_save_overlay
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
_on_save_overlay
)
self
.
view
.
options
.
cb_save_skull
.
Bind
(
wx
.
EVT_CHECKBOX
,
self
.
_on_save_skull
)
self
.
view
.
options
.
coordx
.
Bind
(
wx
.
EVT_SPINCTRLDOUBLE
,
self
.
_on_coord_update
)
self
.
view
.
options
.
coordy
.
Bind
(
wx
.
EVT_SPINCTRLDOUBLE
,
self
.
_on_coord_update
)
self
.
view
.
options
.
coordz
.
Bind
(
wx
.
EVT_SPINCTRLDOUBLE
,
self
.
_on_coord_update
)
self
.
view
.
action_panel
.
play_icon
.
Bind
(
wx
.
EVT_LEFT_UP
,
self
.
_on_run
)
self
.
view
.
action_panel
.
code_icon
.
Bind
(
wx
.
EVT_LEFT_UP
,
self
.
_on_code
)
self
.
view
.
input
.
file_ctrl
.
Bind
(
wx
.
EVT_TEXT
,
self
.
_on_input_edit
)
self
.
view
.
output
.
file_ctrl
.
Bind
(
wx
.
EVT_TEXT
,
self
.
_on_output_edit
)
self
.
view
.
t2_input
.
file_ctrl
.
Bind
(
wx
.
EVT_TEXT
,
self
.
_on_t2_input_edit
)
def
_on_coord_update
(
self
,
event
):
x
=
self
.
view
.
options
.
coordx
.
GetValue
()
y
=
self
.
view
.
options
.
coordy
.
GetValue
()
z
=
self
.
view
.
options
.
coordz
.
GetValue
()
self
.
model
.
center_coord
=
(
x
,
y
,
z
)
print
(
self
.
model
.
center_coord
)
def
_on_input_edit
(
self
,
event
):
widget
=
event
.
GetEventObject
()
val
=
widget
.
GetValue
()
if
not
os
.
path
.
isfile
(
val
):
return
else
:
self
.
model
.
image_in
=
val
self
.
view
.
orthoview
.
reset
()
self
.
view
.
orthoview
.
add_image
(
val
)
ext
=
image
.
getExt
(
val
)
self
.
view
.
output
.
file_ctrl
.
SetValue
(
image
.
removeExt
(
val
)
+
self
.
model
.
suffix
+
ext
)
def
_on_output_edit
(
self
,
event
):
widget
=
event
.
GetEventObject
()
val
=
widget
.
GetValue
()
if
not
os
.
path
.
isfile
(
val
):
return
else
:
self
.
model
.
image_out
=
val
def
_on_t2_input_edit
(
self
,
event
):
widget
=
event
.
GetEventObject
()
val
=
widget
.
GetValue
()
if
not
os
.
path
.
isfile
(
val
):
return
else
:
self
.
model
.
image_t2
=
val
def
_on_bet_choice
(
self
,
event
):
widget
=
event
.
GetEventObject
()
idx
=
widget
.
GetSelection
()
choice_str
=
widget
.
GetString
(
idx
)
self
.
_update_bet_type
(
choice_str
)
if
'T2w'
in
choice_str
:
self
.
view
.
t2_input
.
Show
()
self
.
_layout_from
(
self
.
view
.
t2_input
)
else
:
self
.
view
.
t2_input
.
Hide
()
self
.
_layout_from
(
self
.
view
.
t2_input
)
def
_on_save_bet
(
self
,
event
):
widget
=
event
.
GetEventObject
()
val
=
widget
.
GetValue
()
if
val
:
val
=
False
else
:
val
=
True
self
.
model
.
discard_bet
=
val
def
_on_apply_thr
(
self
,
event
):
widget
=
event
.
GetEventObject
()
self
.
model
.
applythresh
=
widget
.
GetValue
()
def
_on_save_mask
(
self
,
event
):
widget
=
event
.
GetEventObject
()
self
.
model
.
save_mask
=
widget
.
GetValue
()
def
_on_save_overlay
(
self
,
event
):
widget
=
event
.
GetEventObject
()
self
.
model
.
save_overlay
=
widget
.
GetValue
()
def
_on_save_skull
(
self
,
event
):
widget
=
event
.
GetEventObject
()
self
.
model
.
save_skull
=
widget
.
GetValue
()
def
_update_bet_type
(
self
,
btype
):
self
.
model
.
bet_type
=
self
.
model
.
bet_type_choices
[
btype
]
def
_on_code
(
self
,
event
):
self
.
model
.
fval
=
self
.
view
.
options
.
fval_control
.
GetValue
()
self
.
model
.
gval
=
self
.
view
.
options
.
gval_control
.
GetValue
()
self
.
model
.
image_out
=
self
.
view
.
output
.
file_ctrl
.
GetValue
()
print
(
self
.
model
.
command
())
def
_load_result
(
self
):
self
.
view
.
orthoview
.
reset
()
self
.
view
.
orthoview
.
add_image
(
self
.
model
.
image_in
)
self
.
view
.
orthoview
.
add_mask
(
self
.
model
.
image_out
)
def
_on_run
(
self
,
event
):
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
'low res'
in
choice_str
:
self
.
view
.
input_lowres
.
set_label
(
"Low res image*"
)
self
.
view
.
input_lowres
.
Show
()
self
.
view
.
input
.
set_label
(
"High res image*"
)
self
.
_layout_from
(
self
.
view
.
input_lowres
)
else
:
self
.
view
.
input
.
set_label
(
"Input image*"
)
self
.
view
.
input_lowres
.
Hide
()
self
.
_layout_from
(
self
.
view
.
input_lowres
)
fsl/gui/scripts/__init__.py
deleted
100644 → 0
View file @
932037fd
fsl/gui/scripts/flirt_gui.py
deleted
100644 → 0
View file @
932037fd
#!/usr/bin/env python
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/scripts/pnm_gui.py
deleted
100644 → 0
View file @
932037fd
#!/usr/bin/env python
import
sys
import
argparse
from
collections
import
OrderedDict
import
wx
import
yaml
from
fsl.utils
import
idle
import
fsleyes_props
as
props
import
fsl.gui.core
as
core
import
fsl.gui.views
as
fslViews
import
fsl.gui.tools
as
fslTools
def
run
(
p
,
button
):
print
(
'RUN COMMAND: '
)
print
(
p
.
command
())
class
Pnm
(
props
.
HasProperties
):
"""
Pnm is the data model for PnmGui
"""
physioFile
=
props
.
FilePath
(
required
=
True
,
exists
=
True
)
imageFile
=
props
.
FilePath
(
required
=
True
,
exists
=
True
)
sliceOrderChoices
=
OrderedDict
((
(
'up'
,
'Up'
),
(
'down'
,
'Down'
),
(
'iup'
,
'Interleaved Up'
),
(
'idown'
,
'Interleaved Down'
),
(
'file'
,
'User Specified File'
)
))
scannerSliceDirChoices
=
OrderedDict
((
(
'x'
,
'X'
),
(
'y'
,
'Y'
),
(
'z'
,
'Z'
)
))
idxCardiac
=
props
.
Int
(
minval
=
0
,
slider
=
False
)
idxResp
=
props
.
Int
(
minval
=
0
,
slider
=
False
)
idxTrig
=
props
.
Int
(
minval
=
0
,
slider
=
False
)
pulseOxTrig
=
props
.
Boolean
()
sampleRate
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
tr
=
props
.
Real
(
precision
=
0.01
,
slider
=
False
)
sliceOrder
=
props
.
Choice
(
choices
=
list
(
sliceOrderChoices
.
values
()))
sliceDir
=
props
.
Choice
(
choices
=
list
(
scannerSliceDirChoices
.
values
()))
sliceTimeFile
=
props
.
FilePath
(
required
=
False
,
exists
=
True
)
outputFile
=
props
.
FilePath
(
required
=
True
,
exists
=
False
)
orderCardiacEV
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
orderRespEV
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
orderCardiacIntEV
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
orderRespIntEV
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
rvt
=
props
.
Boolean
()
heartRate
=
props
.
Boolean
()
csf
=
props
.
Boolean
()
csfFile
=
props
.
FilePath
(
required
=
False
,
exists
=
True
)
cardiacSmoothSec
=
props
.
Real
(
precision
=
0.001
,
slider
=
False
)
respSmoothSec
=
props
.
Real
(
precision
=
0.001
,
slider
=
False
)
hrSmoothSec
=
props
.
Real
(
precision
=
0.001
,
slider
=
False
)
rvtSmoothSec
=
props
.
Real
(
precision
=
0.001
,
slider
=
False
)
applyCleanup
=
props
.
Boolean
()
invertRespTrace
=
props
.
Boolean
()
invertCardiacTrace
=
props
.
Boolean
()
runButton
=
props
.
Button
(
text
=
'Run'
,
callback
=
run
)
def
command
(
self
):
return
"pnm_stage1 blah blah blah"
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
def
main
():
# get an app instance
app
=
wx
.
App
()
pnm
=
Pnm
()
pnmView
=
core
.
loadSpec
(
fslViews
.
pnm
)
gui
=
core
.
buildGUI
(
pnmView
,
pnm
)
app
.
MainLoop
()
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
fsl/gui/view_specs/pnm_spec.yaml
deleted
100644 → 0
View file @
932037fd
---
# the pnm view layout specification
appName
:
PNM
windowSize
:
width
:
800
height
:
840
layout
:
-
notebook
:
-
page_Setup
:
-
group_Input
:
-
column
:
-
filepath
:
{
label
:
Physio file
,
propName
:
physioFile
}
-
filepath
:
{
label
:
Image file
,
propName
:
imageFile
}
-
group_Format
:
-
row
:
-
number
:
{
label
:
Caridac column
,
propName
:
idxCardiac
}
-
number
:
{
label
:
Respitory column
,
propName
:
idxResp
}
-
number
:
{
label
:
Scan Trig column
,
propName
:
idxTrig
}
-
row
:
-
checkbox
:
{
label
:
Pulse Ox Trig
,
propName
:
pulseOxTrig
}
-
number
:
{
label
:
Sample Rate (Hz)
,
propName
:
sampleRate
}
-
number
:
{
label
:
TR (sec)
,
propName
:
tr
}
-
row
:
-
choice
:
{
label
:
Slice Order
,
propName
:
sliceOrder
}
-
filepath
:
{
label
:
Slice time file
,
propName
:
sliceTimeFile
}
-
choice
:
{
label
:
Slice Direction
,
propName
:
sliceDir
}
-
group_Output
:
-
column
:
-
filepath
:
{
label
:
Output file
,
propName
:
outputFile
}
-
group_EVs
:
-
row
:
-
number
:
{
label
:
Cardiac EV order
,
propName
:
orderCardiacEV
}
-
number
:
{
label
:
Resp EV order
,
propName
:
orderRespEV
}
-
number
:
{
label
:
Cariac interaction EV order
,
propName
:
orderCardiacIntEV
}
-
number
:
{
label
:
Resp interaction EV order
,
propName
:
orderRespIntEV
}
-
row
:
-
checkbox
:
{
label
:
RVT
,
propName
:
rvt
}
-
checkbox
:
{
label
:
Heart Rate
,
propName
:
heartRate
}
-
checkbox
:
{
label
:
CSF
,
propName
:
csf
}
-
column
:
-
filepath
:
{
label
:
CSF mask
,
propName
:
csfFile
}
-
page_Advanced
:
-
row
:
-
number
:
{
label
:
Cardiac smooth (sec)
,
propName
:
cardiacSmoothSec
}
-
number
:
{
label
:
Resp smooth (sec)
,
propName
:
respSmoothSec
}
-
number
:
{
label
:
HR smooth (sec)
,
propName
:
hrSmoothSec
}
-
number
:
{
label
:
RVT smooth (sec)
,
propName
:
rvtSmoothSec
}
-
row
:
-
checkbox
:
{
label
:
Clean up
,
propName
:
applyCleanup
}
-
checkbox
:
{
label
:
Invert resp trace
,
propName
:
invertRespTrace
}
-
checkbox
:
{
label
:
Invert cardiac trace
,
propName
:
invertCardiacTrace
}
-
page_Plots
:
-
row
:
-
button
:
{
label
:
Run
,
propName
:
runButton
}
\ No newline at end of file
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