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
4e53b71a
Commit
4e53b71a
authored
May 26, 2020
by
Taylor Hanayik
Browse files
add notebooks and pages
parent
847dc781
Changes
7
Hide whitespace changes
Inline
Side-by-side
fsl/gui/core.py
View file @
4e53b71a
...
...
@@ -16,6 +16,7 @@ import fsl.gui.widgets as fslwidgets
allowedContainerWidgets
=
(
'column'
,
'row'
,
'group'
,
'page'
,
'notebook'
)
allowedWidgets
=
(
...
...
@@ -35,7 +36,7 @@ allowedKeys = (
)
def
isGroup
(
key
):
def
isGroup
Key
(
key
):
"""
returns True is key == "group"
...
...
@@ -46,7 +47,18 @@ def isGroup(key):
else
:
return
False
def
isContainer
(
key
):
def
isPageKey
(
key
):
"""
returns True is key == "group"
returns False otherwise
"""
if
key
==
"page"
:
return
True
else
:
return
False
def
isContainerKey
(
key
):
"""
returns True if this key is associated with a container widget
from allowedContainerWidgets.
...
...
@@ -117,8 +129,20 @@ def parseWidgetKey(key):
n
=
""
return
n
,
t
def
parentIsGroup
(
parent
):
if
isinstance
(
parent
.
GetSizer
(),
wx
.
StaticBoxSizer
):
def
isGroup
(
widget
):
if
isinstance
(
widget
.
GetSizer
(),
wx
.
StaticBoxSizer
):
return
True
else
:
return
False
def
isNotebook
(
widget
):
if
isinstance
(
widget
,
wx
.
Notebook
):
return
True
else
:
return
False
def
isPage
(
widget
):
if
isinstance
(
widget
.
GetParent
(),
wx
.
Notebook
):
return
True
else
:
return
False
...
...
@@ -127,6 +151,10 @@ def addWidgetToGroup(parent, widget):
w
=
widget
(
parent
.
GetSizer
().
GetStaticBox
())
return
w
def
addPageToNotebook
(
parent
,
widget
,
name
):
parent
.
AddPage
(
widget
,
name
)
return
widget
def
widgetFromKey
(
key
):
"""
...
...
@@ -148,14 +176,18 @@ def makeWidget(parent, propObj, key, tag, value):
"""
if
key
in
allowedWidgets
:
wid
=
widgetFromKey
(
key
)
print
(
'making widget: '
,
key
)
if
isinstance
(
value
,
dict
):
w
=
wid
(
parent
,
propObj
,
**
value
)
else
:
if
isGroup
(
key
):
if
isGroup
Key
(
key
):
w
=
wid
(
parent
,
tag
)
else
:
if
parentI
sGroup
(
parent
):
if
i
sGroup
(
parent
):
w
=
addWidgetToGroup
(
parent
,
wid
)
elif
isNotebook
(
parent
):
w
=
wid
(
parent
)
w
=
addPageToNotebook
(
parent
,
w
,
tag
)
else
:
w
=
wid
(
parent
)
return
w
...
...
@@ -168,9 +200,10 @@ def layout(parent, buildSpec, propObj):
for
k
,
v
in
entry
.
items
():
k
,
t
=
parseWidgetKey
(
k
)
w
=
makeWidget
(
parent
,
propObj
,
k
,
t
,
v
,)
parent
.
GetSizer
().
Add
(
w
,
proportion
=
0
,
flag
=
wx
.
ALL
|
wx
.
EXPAND
,
border
=
5
)
if
not
isPage
(
w
):
parent
.
GetSizer
().
Add
(
w
,
proportion
=
0
,
flag
=
wx
.
ALL
|
wx
.
EXPAND
,
border
=
5
)
layoutFrom
(
w
)
if
isContainer
(
k
):
if
isContainer
Key
(
k
):
if
type
(
v
)
is
list
:
layout
(
w
,
v
,
propObj
)
parent
.
Layout
()
...
...
fsl/gui/scripts/bet_gui.py
View file @
4e53b71a
#!/usr/bin/env python
import
wx
import
sys
from
fsl.gui.guis
import
BetGui
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
class
Bet
(
props
.
HasProperties
):
"""
Bet is the data model for Bet Gui
"""
betRunChoices
=
OrderedDict
((
(
'default'
,
'Default Brain extraction'
),
(
'robust'
,
'Robust'
),
(
'eyeClean'
,
'Eye and optic nerve cleanup'
),
(
'biasAndNeckClean'
,
'Bias field and neck Clean'
),
(
'smallZ'
,
'Brain has small Z FOV'
),
(
'4d'
,
'Apply to 4D fMRI'
),
(
'withBetSurf'
,
'Also run betsurf'
),
(
'withBetSurfT2'
,
'Run betsurf with additional T2 image'
)
))
inputFile
=
props
.
FilePath
(
required
=
True
,
exists
=
True
)
outputFile
=
props
.
FilePath
(
required
=
True
,
exists
=
False
)
fval
=
props
.
Real
(
precision
=
0.001
,
minval
=
0
,
maxval
=
1
,
clamped
=
True
)
betRunType
=
props
.
Choice
(
choices
=
list
(
betRunChoices
.
values
()))
parser
=
argparse
.
ArgumentParser
(
description
=
"FSL's brain extraction tool"
)
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
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
)
betgui
=
BetGui
(
frame
,
"BET"
)
sizer
.
Add
(
betgui
.
view
,
proportion
=
1
,
flag
=
wx
.
EXPAND
|
wx
.
ALL
,
border
=
5
)
frame
.
SetSizer
(
sizer
)
frame
.
Centre
()
frame
.
Show
()
bet
=
Bet
()
betView
=
core
.
loadSpec
(
fslViews
.
bet
)
gui
=
core
.
buildGUI
(
betView
,
bet
)
app
.
MainLoop
()
if
__name__
==
"__main__"
:
sys
.
exit
(
main
())
fsl/gui/scripts/pnm_gui.py
View file @
4e53b71a
...
...
@@ -48,8 +48,8 @@ class Pnm(props.HasProperties):
sampleRate
=
props
.
Int
(
minVal
=
0
,
slider
=
False
)
tr
=
props
.
Real
(
precision
=
0.01
,
slider
=
False
)
sliceOrder
=
props
.
Choice
(
choices
=
list
(
sliceOrderChoices
.
key
s
()))
sliceDir
=
props
.
Choice
(
choices
=
list
(
scannerSliceDirChoices
.
key
s
()))
sliceOrder
=
props
.
Choice
(
choices
=
list
(
sliceOrderChoices
.
value
s
()))
sliceDir
=
props
.
Choice
(
choices
=
list
(
scannerSliceDirChoices
.
value
s
()))
sliceTimeFile
=
props
.
FilePath
(
required
=
False
,
exists
=
True
)
outputFile
=
props
.
FilePath
(
required
=
True
,
exists
=
False
)
...
...
fsl/gui/view_specs/bet_spec.yaml
0 → 100644
View file @
4e53b71a
---
# the pnm view layout specification
appName
:
BET
windowSize
:
width
:
800
height
:
500
layout
:
-
notebook
:
-
page_Setup
:
-
group_Files
:
-
column
:
-
filepath
:
{
label
:
Input file
,
propName
:
inputFile
}
-
filepath
:
{
label
:
Output file
,
propName
:
outputFile
}
-
row
:
-
number
:
{
label
:
F value
,
propName
:
fval
,
showLimits
:
0
}
-
page_Options
:
-
column
:
-
choice
:
{
label
:
BET run type
,
propName
:
betRunType
}
-
page_Viewer
:
\ No newline at end of file
fsl/gui/view_specs/pnm_spec.yaml
View file @
4e53b71a
...
...
@@ -5,47 +5,50 @@ windowSize:
width
:
800
height
:
840
layout
:
-
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
}
-
group_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
}
-
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
fsl/gui/views.py
View file @
4e53b71a
...
...
@@ -281,6 +281,7 @@ class FlirtView(wx.Panel):
VIEW_PATH
=
join
(
abspath
(
dirname
(
__file__
)),
'view_specs'
)
pnm
=
join
(
VIEW_PATH
,
'pnm_spec.yaml'
)
bet
=
join
(
VIEW_PATH
,
'bet_spec.yaml'
)
...
...
fsl/gui/widgets.py
View file @
4e53b71a
...
...
@@ -64,6 +64,23 @@ def group(parent, label):
panel
.
SetSizer
(
bsizer
)
return
panel
def
notebook
(
parent
):
"""
noetbook
"""
notebook
=
wx
.
Notebook
(
parent
)
return
notebook
def
page
(
parent
):
"""
page
"""
panel
=
wx
.
Panel
(
parent
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
panel
.
SetSizer
(
sizer
)
panel
.
SetBackgroundColour
(
wx
.
NullColour
)
return
panel
def
filepath
(
parent
,
propobj
,
**
kwargs
):
if
kwargs
.
get
(
'label'
)
==
None
:
raise
fslerrs
.
MissingRequiredKey
(
"A 'label' key must be provided to a FilePath"
)
...
...
@@ -92,9 +109,9 @@ def number(parent, propobj, **kwargs):
raise
fslerrs
.
MissingRequiredKey
(
"A 'label' key must be provided to a Checkbox"
)
panel
=
wx
.
Panel
(
parent
)
panel
.
SetSizer
(
wx
.
BoxSizer
(
wx
.
HORIZONTAL
))
st
=
wx
.
StaticText
(
panel
,
label
=
kwargs
[
'label'
]
)
st
=
wx
.
StaticText
(
panel
,
label
=
kwargs
.
pop
(
'label'
)
)
panel
.
GetSizer
().
Add
(
st
,
proportion
=
0
,
flag
=
wx
.
ALL
|
wx
.
ALIGN_CENTER_VERTICAL
,
border
=
2
)
prp
=
props
.
widgets
.
makeWidget
(
panel
,
propobj
,
kwargs
[
'propName'
]
)
prp
=
props
.
widgets
.
makeWidget
(
panel
,
propobj
,
**
kwargs
)
panel
.
GetSizer
().
Add
(
prp
,
proportion
=
0
,
flag
=
wx
.
ALL
|
wx
.
EXPAND
,
border
=
5
)
return
panel
...
...
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