Skip to content
Snippets Groups Projects
Commit 0fe6e45b authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Updated feat and flirt for new fsl.py structure, and to make them a bit more pep8 compliant.

parent ea2b88af
No related branches found
No related tags found
No related merge requests found
......@@ -165,7 +165,6 @@ def buildGUI(fslTool, toolCtx, fslEnvActive):
menuItem = fslMenu.Append(wxId, name)
frame.Bind(wx.EVT_MENU, func, menuItem)
toolPanel.Layout()
frame.Layout()
return frame
......
......@@ -5,8 +5,6 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import os
import sys
from collections import OrderedDict
......@@ -57,8 +55,8 @@ zRenderingOpts = OrderedDict((
('preset', 'Use preset Z min/max')))
blobOpts = OrderedDict((
('solid', 'Solid blobs'),
('transparent','Transparent blobs')))
('solid', 'Solid blobs'),
('transparent', 'Transparent blobs')))
regSearchOpts = OrderedDict((
('none', 'No search'),
......@@ -90,7 +88,9 @@ class Options(props.HasProperties):
progressWatcher = props.Boolean(default=True)
brainBackgroundThreshold = props.Percentage(default=10)
efficNoiseLevel = props.Percentage(default=0.66)
efficTemporalSmoothness = props.Double(default=0.34, minval=-1.0, maxval=1.0)
efficTemporalSmoothness = props.Double(default=0.34,
minval=-1.0,
maxval=1.0)
efficZThreshold = props.Double(default=5.3, minval=0.0)
# misc/higher level
......@@ -99,7 +99,9 @@ class Options(props.HasProperties):
#
# Data options
#
inputData = props.List(minlen=1, listType=props.FilePath(exists=True, required=True))
inputData = props.List(
minlen=1,
listType=props.FilePath(exists=True, required=True))
outputDirectory = props.FilePath(isFile=False, required=True)
totalVolumes = props.Int(minval=0)
deleteVolumes = props.Int(minval=0)
......@@ -108,8 +110,17 @@ class Options(props.HasProperties):
# data/higher level
inputDataType = props.Choice(highLevelInputTypes)
higherLevelFeatInput = props.List(minlen=3, listType=props.FilePath(isFile=False, exists=True, required=lambda i:i.inputDataType=='featDirs'))
higherLevelCopeInput = props.List(minlen=3, listType=props.FilePath( exists=True, required=lambda i:i.inputDataType=='copeImages'))
higherLevelFeatInput = props.List(
minlen=3,
listType=props.FilePath(
isFile=False,
exists=True,
required=lambda i: i.inputDataType == 'featDirs'))
higherLevelCopeInput = props.List(
minlen=3,
listType=props.FilePath(
exists=True,
required=lambda i: i.inputDataType == 'copeImages'))
#
# Pre-stats options
......@@ -119,19 +130,25 @@ class Options(props.HasProperties):
b0Unwarping = props.Boolean(default=False)
# B0 unwarping sub-options - displayed if b0Unwarping is true
b0_fieldmap = props.FilePath(exists=True, required=lambda i:i.b0Unwarping)
b0_fieldmapMag = props.FilePath(exists=True, required=lambda i:i.b0Unwarping)
b0_fieldmap = props.FilePath(exists=True,
required=lambda i: i.b0Unwarping)
b0_fieldmapMag = props.FilePath(exists=True,
required=lambda i: i.b0Unwarping)
b0_echoSpacing = props.Double(minval=0.0, default=0.7)
b0_TE = props.Double(minval=0.0, default=35)
b0_unwarpDir = props.Choice(('x','-x','y','-y','z','-z'))
b0_unwarpDir = props.Choice(('x', '-x', 'y', '-y', 'z', '-z'))
b0_signalLossThreshold = props.Percentage(default=10)
sliceTimingCorrection = props.Choice(sliceTimingOpts)
# slice timing file, displayed if the timing correction
# choice is for a custom order/timing file
sliceTimingFile = props.FilePath(exists=True, required=lambda i:i.sliceTimingCorrection=='timingFile')
sliceOrderFile = props.FilePath(exists=True, required=lambda i:i.sliceTimingCorrection=='orderFile')
sliceTimingFile = props.FilePath(
exists=True,
required=lambda i: i.sliceTimingCorrection == 'timingFile')
sliceOrderFile = props.FilePath(
exists=True,
required=lambda i: i.sliceTimingCorrection == 'orderFile')
brainExtraction = props.Boolean(default=True)
smoothingFWHM = props.Double(minval=0.0, default=5.0)
......@@ -161,7 +178,8 @@ class Options(props.HasProperties):
# Post-stats options
#
preThresholdMask = props.FilePath(exists=True)
thresholding = props.Choice(('None','Uncorrected','Voxel','Cluster'))
thresholding = props.Choice((
'None', 'Uncorrected', 'Voxel', 'Cluster'))
# Thresholding sub-options
# displayed if thresholding is not None
......@@ -328,7 +346,7 @@ dataView = props.VGroup(
label='Data',
children=(
props.VGroup(
visibleWhen=lambda i:i.analysisType == 'firstLevel',
visibleWhen=lambda i: i.analysisType == 'firstLevel',
children=(
'inputData',
'outputDirectory',
......@@ -337,11 +355,15 @@ dataView = props.VGroup(
'TR',
'highpassFilterCutoff')),
props.VGroup(
visibleWhen=lambda i:i.analysisType == 'highLevel',
visibleWhen=lambda i: i.analysisType == 'highLevel',
children=(
'inputDataType',
props.Widget('higherLevelFeatInput', visibleWhen=lambda i:i.inputDataType == 'featDirs'),
props.Widget('higherLevelCopeInput', visibleWhen=lambda i:i.inputDataType == 'copeImages'),
props.Widget(
'higherLevelFeatInput',
visibleWhen=lambda i: i.inputDataType == 'featDirs'),
props.Widget(
'higherLevelCopeInput',
visibleWhen=lambda i: i.inputDataType == 'copeImages'),
'outputDirectory'))))
prestatsView = props.VGroup(
......@@ -363,8 +385,12 @@ prestatsView = props.VGroup(
'b0_unwarpDir',
'b0_signalLossThreshold')),
'sliceTimingCorrection',
props.Widget('sliceTimingFile', visibleWhen=lambda i: i.sliceTimingCorrection == 'timingFile'),
props.Widget('sliceOrderFile', visibleWhen=lambda i: i.sliceTimingCorrection == 'orderFile'),
props.Widget(
'sliceTimingFile',
visibleWhen=lambda i: i.sliceTimingCorrection == 'timingFile'),
props.Widget(
'sliceOrderFile',
visibleWhen=lambda i: i.sliceTimingCorrection == 'orderFile'),
'brainExtraction',
'smoothingFWHM',
'intensityNorm',
......@@ -374,7 +400,7 @@ prestatsView = props.VGroup(
children=(
'perfusionSubtraction',
props.Widget('perfusionOption',
visibleWhen=lambda i: i.perfusionSubtraction))),
visibleWhen=lambda i: i.perfusionSubtraction))),
'temporalHighpass',
'melodic'))
......@@ -401,17 +427,27 @@ postStatsView = props.VGroup(
border=True,
children=(
'thresholding',
props.Widget('pThreshold', visibleWhen=lambda i:i.thresholding != 'None'),
props.Widget('zThreshold', visibleWhen=lambda i:i.thresholding == 'Cluster'),
props.Button('Contrast masking', visibleWhen=lambda i:i.thresholding != 'None'))),
props.Widget(
'pThreshold',
visibleWhen=lambda i: i.thresholding != 'None'),
props.Widget(
'zThreshold',
visibleWhen=lambda i: i.thresholding == 'Cluster'),
props.Button(
'Contrast masking',
visibleWhen=lambda i: i.thresholding != 'None'))),
props.VGroup(
label='Rendering',
border=True,
visibleWhen=lambda i: i.thresholding != 'None',
children=(
'renderZMinMax',
props.Widget('renderZMin', visibleWhen=lambda i:i.renderZMinMax == 'preset'),
props.Widget('renderZMax', visibleWhen=lambda i:i.renderZMinMax == 'preset'),
props.Widget(
'renderZMin',
visibleWhen=lambda i: i.renderZMinMax == 'preset'),
props.Widget(
'renderZMax',
visibleWhen=lambda i: i.renderZMinMax == 'preset'),
'blobTypes'))))
regView = props.VGroup(
......@@ -422,28 +458,32 @@ regView = props.VGroup(
props.HGroup(
label='Functional -> Expanded functional',
border=True,
visibleWhen=lambda i:i.expandedFunctionalImage is not None,
visibleWhen=lambda i: i.expandedFunctionalImage is not None,
children=('functionalSearch', 'functionalDof')),
'mainStructuralImage',
props.HGroup(
label='Functional -> Structural',
border=True,
visibleWhen=lambda i:i.mainStructuralImage is not None,
visibleWhen=lambda i: i.mainStructuralImage is not None,
children=('structuralSearch', 'structuralDof')),
'standardSpaceImage',
props.VGroup(
label='Structural -> Standard',
border=True,
visibleWhen=lambda i:i.standardSpaceImage is not None,
visibleWhen=lambda i: i.standardSpaceImage is not None,
children=(
props.HGroup(('standardSearch', 'standardDof')),
props.HGroup(('nonLinearReg',
props.Widget('warpResolution',visibleWhen=lambda i:i.nonLinearReg)))))))
props.HGroup((
'nonLinearReg',
props.Widget(
'warpResolution',
visibleWhen=lambda i: i.nonLinearReg)))))))
featView =props.VGroup((
featView = props.VGroup((
'analysisType',
props.Widget('analysisStages', enabledWhen=lambda i: i.analysisType == 'firstLevel'),
props.Widget('analysisStages',
enabledWhen=lambda i: i.analysisType == 'firstLevel'),
props.NotebookGroup((
miscView,
dataView,
......@@ -462,6 +502,5 @@ def interface(parent, featOpts):
FSL_TOOLNAME = 'FEAT'
FSL_HELPPAGE = 'feat'
FSL_OPTIONS = Options
FSL_CONTEXT = lambda args: Options()
FSL_INTERFACE = interface
FSL_RUNTOOL = None
......@@ -5,9 +5,6 @@
# Author: Paul McCarthy <pauldmccarthy@gmail.com>
#
import os
import sys
from collections import OrderedDict
import fsl.props as props
......@@ -52,13 +49,18 @@ sincWindowOpts = OrderedDict((
('blackman', 'Blackman')))
def inSingleMode( opts): return opts.flirtMode == 'single'
def inMultipleMode(opts): return opts.flirtMode == 'multiple'
class Options(props.HasProperties):
flirtMode = props.Choice(flirtModes)
inputImage = props.FilePath(exists=True, required=lambda i: i.flirtMode == 'single')
loResImage = props.FilePath(exists=True, required=lambda i: i.flirtMode == 'multiple')
hiResImage = props.FilePath(exists=True, required=lambda i: i.flirtMode == 'multiple')
inputImage = props.FilePath(exists=True, required=inSingleMode)
loResImage = props.FilePath(exists=True, required=inMultipleMode)
hiResImage = props.FilePath(exists=True, required=inMultipleMode)
refImage = props.FilePath(exists=True, required=True)
outputImage = props.FilePath( required=True)
......@@ -100,21 +102,29 @@ searchOptions = props.VGroup(
label='Search',
children=(
'searchMode',
props.HGroup(('searchAngleXMin', 'searchAngleXMax'), visibleWhen=lambda i:i.searchMode != 'nosearch'),
props.HGroup(('searchAngleYMin', 'searchAngleYMax'), visibleWhen=lambda i:i.searchMode != 'nosearch'),
props.HGroup(('searchAngleZMin', 'searchAngleZMax'), visibleWhen=lambda i:i.searchMode != 'nosearch')))
props.HGroup(('searchAngleXMin', 'searchAngleXMax'),
visibleWhen=lambda i: i.searchMode != 'nosearch'),
props.HGroup(('searchAngleYMin', 'searchAngleYMax'),
visibleWhen=lambda i: i.searchMode != 'nosearch'),
props.HGroup(('searchAngleZMin', 'searchAngleZMax'),
visibleWhen=lambda i: i.searchMode != 'nosearch')))
costFuncOptions = props.VGroup(
label='Cost Function',
children=(
'costFunction',
props.Widget('costHistBins', visibleWhen=lambda i:i.costFunction in ['correlation', 'mutualinfo', 'normmutualinfo'])))
props.Widget(
'costHistBins',
visibleWhen=lambda i: i.costFunction in ['correlation',
'mutualinfo',
'normmutualinfo'])))
interpOptions = props.VGroup(
label='Interpolation',
children=(
'interpolation',
props.VGroup(('sincWindow', 'sincWindowWidth'), visibleWhen=lambda i: i.interpolation == 'sinc')))
props.VGroup(('sincWindow', 'sincWindowWidth'),
visibleWhen=lambda i: i.interpolation == 'sinc')))
weightVolOptions = props.VGroup(
label='Weighting Volumes',
......@@ -125,12 +135,12 @@ weightVolOptions = props.VGroup(
flirtView = props.VGroup((
'flirtMode',
'refImage',
props.Widget('inputImage', visibleWhen=lambda i: i.flirtMode == 'single'),
props.Widget('inToRefMode', visibleWhen=lambda i: i.flirtMode == 'single'),
props.Widget('hiResImage', visibleWhen=lambda i: i.flirtMode == 'multiple'),
props.Widget('hiToRefMode', visibleWhen=lambda i: i.flirtMode == 'multiple'),
props.Widget('loResImage', visibleWhen=lambda i: i.flirtMode == 'multiple'),
props.Widget('loToHiMode', visibleWhen=lambda i: i.flirtMode == 'multiple'),
props.Widget('inputImage', visibleWhen=inSingleMode),
props.Widget('inToRefMode', visibleWhen=inSingleMode),
props.Widget('hiResImage', visibleWhen=inMultipleMode),
props.Widget('hiToRefMode', visibleWhen=inMultipleMode),
props.Widget('loResImage', visibleWhen=inMultipleMode),
props.Widget('loToHiMode', visibleWhen=inMultipleMode),
'outputImage',
'sndyImages',
props.NotebookGroup(label='Advanced Options',
......@@ -140,18 +150,18 @@ flirtView = props.VGroup((
interpOptions,
weightVolOptions))))
def runFlirt(parent, opts):
pass
def interface(parent, opts):
return props.buildGUI(
parent, opts, flirtView, labels, tooltips)
FSL_TOOLNAME = 'FLIRT'
FSL_HELPPAGE = 'flirt'
FSL_OPTIONS = Options
FSL_CONTEXT = lambda args: Options()
FSL_INTERFACE = interface
FSL_RUNTOOL = runFlirt
FSL_ACTIONS = [('Run FLIRT', runFlirt)]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment