fsleyes.parseargs
¶
This module encapsulates the logic for parsing command line arguments which
specify a scene to be displayed in FSLeyes. This logic is shared between
the fsleyes
and render
tools. This module make use of the
command line generation features of the props
package. Broadly
speaking, this module can be used to do three things:
- _Parse_ command line arguments, generating an
argparse.Namespace
object which contains the parsed options.- _Apply_ the options contained in an
argparse.Namespace
option to the objects which describe a scene - aSceneOpts
instance, aDisplayContext
instance, and theDisplay
andDisplayOpts
instances for each overlay.- _Generate_ command line arguments that can be used to describe an existing scene.
There are a lot of command line arguments made available to the user, broadly split into the following groups:
- Main arguments control the overall scene display, such as the display type (e.g. orthographic or lightbox), the displayed location, and whether to show a colour bar. These arguemnts generally correspond to properties of the
SceneOpts
,OrthoOpts
,LightBoxOpts
andDisplayContext
classes.- Display arguments control the display for a single overlay file (e.g. a NIFTI image), such as interpolation, colour map, etc. These arguments correspond to properties of the
Display
class, and sub-classes ofDisplayOpts
.
This module provides the following functions:
parseArgs |
Parses the given command line arguments, returning an argparse.Namespace object containing all the arguments. |
applyMainArgs |
Applies top-level arguments that are not specific to the scene or any overlays. |
applySceneArgs |
Configures the scene displayed by the given DisplayContext instance according to the arguments that were passed in on the command line. |
applyOverlayArgs |
Loads and configures any overlays which were specified on the command line. |
generateSceneArgs |
Generates command line arguments which describe the current state of the provided displayCtx and sceneOpts instances. |
generateOverlayArgs |
Generates command line arguments which describe the display of the current overlay. |
Usage¶
Call the parseArgs()
function to parse all command line arguments. Then
create a DisplayContext
and OverlayList
, and pass them,
along with the argparse.Namespace
object, to the applyMainArgs()
,
applySceneArgs()
and applyOverlayArgs()
functions. applyMainArgs()
should be called first, but the order of the
latter two does not matter.
argparse
modifications¶
The argparse
module is quite frustrating to work with for the command
line interface that I want to provide. Therefore, this module modifies
the behaviour of argparse.ArgumentParser
instances (by monkey-patching
instances - not the class itself) such that:
- Prefix matching (a.k.a. abbreviation) is disabled
- An error is raised when invalid arguments are passed, rather than the program exiting.
Command line parsing procedure¶
- FSLeyes command line arguments are processed using the following procedure
(implemented in the
parseArgs()
function):- All overlay paths are identified.
- Main arguments are separated out from the display arguments for every overlay.
- Main arguments are parsed.
- The display arguments for each overlay are parsed, using a parser that is only configured to identify the overlay type.
- The display arguments for each overlay are parsed again, using a parser that is configured to handle arguments specific to the overlay type.
Adding new command line options¶
Many classes in FSLeyes derive from the HasProperties
class of the
props
package. Therefore, with only a couple of exceptions, the
processing of nearly all FSLeyes command line arguments is completely
automatic.
Therefore, adding a new command line option is fairly easy. For example,
let’s say you have added a new property on the MeshOpts
class,
called rotation
:
class MeshOpts(fsldisplay.DisplayOpts):
# .
# .
# .
rotation = props.Int(minval=0, maxval=360, clamped=True)
# .
# .
# .
To make this new propery settable via the command line, you need to:
Add an entry to the
OPTIONS
dictionary:OPTIONS = td.TypeDict({ # . # . # . 'MeshOpts' : ['colour', 'outline', 'outlineWidth', 'refImage', 'rotation'], # . # . # . })Specify the command line flags to use, in the
ARGUMENTS
dictionary:ARGUMENTS = td.TypeDict({ # . # . # . 'MeshOpts.rotation' : ('mr', 'meshRotation', True), # . # . # . })Add a description in the
HELP
dictionary:HELP = td.TypeDict({ # . # . # . 'MeshOpts.rotation' : 'Rotate the mesh by this much', # . # . # . })If the property specifies a file/path name (e.g.
VolumeOpts.clipImage
), add an entry in theFILE_OPTIONS
dictionary. In the present example, this is not necessary, but if it were, theFILE_OPTIONS
entry might look like this:FILE_OPTIONS = td.TypeDict({ # . # . # . 'MeshOpts' : ['refImage', 'rotation'], # . # . # . })
Adding special (non-property) options¶
If you need to add an option which does not directly map to a
SceneOpts
or DisplayOpts
property, or if you need to perform
some custom/extra processing for a property, you need to do some extra
work. For example, let’s say we wish to add a custom option clipAndDisplay
to modify both the clippingRange
and displayRange
properties of the
VolumeOpts
class.
Following steps 1-3 above, we add
'clipAndDisplay'
to theOPTIONS['VolumeOpts']
list, and add a'VolumeOpts.clipAndDisplay'
entries to theARGUMENTS
andHELP
dictionaries.Add a function which configures the argument parser for your option. The function must have the following signature:
def _configSpecial_[target]_[option]( target, # The class with which the option is associated parser, # The ArgumentParser to be configured shortArg, # String to use as the short form argument longArg, # String to use as the longform argument helpText # Help text )
where
target
is the name of theDisplayOpts
class you are adding an option for (e.g.'VolumeOpts'
), andoption
is the option name. In our example, we would add a function:def _configSpecial_VolumeOpts_clipAndDisplay(...):
This function simply needs to add the option to the
ArgumentParser
instance.Add a function which applies parsed command line arguments for your option. The function must have the following signature:
def _applySpecial_[target]_[option]( args, # argparse.Namespace object containing parsed arguments overlayList, # The OverlayList instance displayCtx, # The DisplayContext instance target # The target instance (e.g. a VolumeOpts instance) )
Apply functions should typically return
None
orFalse
, which indicates that the argument has been fully processed. However, if you have a property for which you need to perform some pre-processing, but you also want to be handled byfsleyes_props.applyArguments()
, you can have your apply function returnTrue
, which indicates that the arguemnt should be passed through toapplyArguments
, in addition to being handled by your apply function.Add a function which, given a
target
instance, will generate command line arguments that can reproduce thetarget
state. This function must have the following signature:def _generateSpecial_[target]_[option]( overlayList, # The OverlayList instance displayCtx, # The DisplayContext instance source, # The source instance longArg # String to use as the long form argument )
In a similar vein to the apply function, described above, a generate function may return a value of
False
, indicating that the argument should be passed through to thefsleyes_props.generateArguments()
function.
-
fsleyes.parseargs.
_get_option_tuples
(self, option_string)¶ By default, the
argparse
module uses a prefix matching strategy, which allows the user to (unambiguously) specify only part of an argument.While this may be a good idea for simple programs with a small number of arguments, it is very disruptive to the way that I have designed this module.
To disable this prefix matching functionality, this function is monkey-patched into all ArgumentParser instances created in this module.
Note
This is unnecessary in python 3.5 and above, due to the addition of the
allow_abbrev
option.See http://stackoverflow.com/questions/33900846/ disable-unique-prefix-matches-for-argparse-and-optparse
-
exception
fsleyes.parseargs.
ArgumentError
¶ Bases:
Exception
Custom
Exception
class raised byArgumentParser
instances created and used in this module.-
__module__
= 'fsleyes.parseargs'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
fsleyes.parseargs.
ArgumentParser
(*args, **kwargs)¶ Wrapper around the
argparse.ArgumentParser` constructor which creates, monkey-patches, and returns an ``ArgumentParser
instance.
-
class
fsleyes.parseargs.
FSLeyesHelpFormatter
(prog, indent_increment=2, max_help_position=24, width=None)¶ Bases:
argparse.RawDescriptionHelpFormatter
A custom
argparse.HelpFormatter
class which customises a few annoying things about defaultargparse
behaviour.-
_format_usage
(usage, actions, groups, prefix)¶
-
__module__
= 'fsleyes.parseargs'¶
-
-
fsleyes.parseargs.
OPTIONS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary defines all of the options which are exposed on the command line.
With the exception of
Main
, every key is the name of aHasProperties
class, and the list of values are the names of properties on that class.
-
fsleyes.parseargs.
GROUPNAMES
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ Command line arguments are grouped according to the class to which they are applied (see the
ARGUMENTS
dictionary). This dictionary defines descriptions for each command line group.
-
fsleyes.parseargs.
GROUPDESCS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary contains descriptions for each argument group.
-
fsleyes.parseargs.
GROUPEPILOGS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary contains epilogs for some types - information to be shown after the help for that type. Use the
groupEpilog()
function to access this dictionary.
-
fsleyes.parseargs.
groupEpilog
(target)¶ Return a formatted value from the
GROUPEPILOGS
dictionary. Thetarget
must be a type.
-
fsleyes.parseargs.
ARGUMENTS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary defines the short and long command line flags to be used for every option. Each value has the form:
(shortForm, longForm, expectsArguments)
where
expectsArguments
isTrue
if the flag is to be followed by one or more arguments,False
otherwise.Note
- There cannot be any collisions between the main options, the
SceneOpts
options, theOrthOpts
options, theLightBoxOpts
options, and theScene3DOpts
options. - There cannot be any collisions between the
Display
options and any one set ofDisplayOpts
options. - There can be collisions between these two groups, and
between the options for different
DisplayOpts
types.
- There cannot be any collisions between the main options, the
-
fsleyes.parseargs.
HELP
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary defines the help text for all command line options.
-
fsleyes.parseargs.
SHORT_HELP
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary defines the help text for some properties, used when the user requests a short (abbreviated) version of the command line help.
-
fsleyes.parseargs.
getExtra
(target, propName, default=None)¶ This function returns defines any extra settings to be passed through to the
props.addParserArguments()
function for the given type and property.
-
fsleyes.parseargs.
FILE_OPTIONS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary contains all arguments which accept file or path names. These arguments need special treatment - for these arguments, the user may specify a file which refers to an overlay that may or may not have already been loaded, so we need to figure out what to do.
-
fsleyes.parseargs.
_imageTrans
(i, **kwargs)¶
-
fsleyes.parseargs.
_boolTrans
(b, **kwargs)¶
-
fsleyes.parseargs.
_colourTrans
(c, **kwargs)¶
-
fsleyes.parseargs.
TRANSFORMS
= <MagicMock name='mock.utils.typedict.TypeDict()' id='140655054538120'>¶ This dictionary defines any transformations for command line options where the value passed on the command line cannot be directly converted into the corresponding property value. See the
props.applyArguments()
andprops.generateArguments()
functions.
-
fsleyes.parseargs.
_setupMainParser
(mainParser)¶ Sets up an argument parser which handles options related to the scene. This function configures the following argument groups:
- Main: Top level optoins
- SceneOpts: Common scene options
- OrthoOpts: Options related to setting up a orthographic display
- LightBoxOpts: Options related to setting up a lightbox display
- Scene3DOpts: Options related to setting up a 3D display
-
fsleyes.parseargs.
_configParser
(target, parser, propNames=None, shortHelp=False)¶ Configures the given parser so it will parse arguments for the given target.
-
fsleyes.parseargs.
_configMainParser
(mainParser)¶ Adds options to the given parser which allow the user to specify main FSLeyes options.
-
fsleyes.parseargs.
_setupOverlayParsers
(forHelp=False, shortHelp=False)¶ Creates a set of parsers which handle command line options for
Display
instances, and for allDisplayOpts
instances.Parameters: - forHelp – If
False
(the default), each of the parsers created to handle options for theDisplayOpts
sub-classes will be configured so that the can also handle options forDisplay
properties. Otherwise, theDisplayOpts
parsers will be configured to only handleDisplayOpts
properties. This option is available to make it easier to separate the help sections when printing help. - shortHelp – If
False
(the default), help text will be taken from theHELP
dictionary. Otherwise, help text will be taken from theSHORT_HELP
dictionary.
Returns: A tuple containing:
- An
ArgumentParser
which parses arguments specifying theDisplay
properties. This parser is not actually used to parse arguments - it is only used to generate help text. - An
ArgumentParser
which just parses arguments specifying theDisplay.overlayType
property. - An
ArgumentParser
which parses arguments specifyingDisplay
andDisplayOpts
properties.
- forHelp – If
-
fsleyes.parseargs.
parseArgs
(mainParser, argv, name, prolog=None, desc=None, usageProlog=None, argOpts=None, shortHelpExtra=None)¶ Parses the given command line arguments, returning an
argparse.Namespace
object containing all the arguments.The display options for individual overlays are parsed separately. The
Namespace
objects for each overlay are returned in a list, stored as an attribute, calledoverlays
, of the returned top-levelNamespace
instance. Each of the overlayNamespace
instances also has an attribute, calledoverlay
, which contains the full path of the overlay file that was speciied.A
SystemExit
exception is raised if invalid arguments have been passed in or, for example, the user simply requested command line help.Parameters: - mainParser – A
argparse.ArgumentParser
which should be used as the top level parser. - argv – The arguments as passed in on the command line.
- name – The name of the tool - this function might be called
by either the
fsleyes
tool or therender
tool. - prolog – A string to print before any usage text is printed.
- desc – A description of the tool.
- usageProlog – A string describing the tool-specific options (those options which are handled by the tool, not by this module).
- argOpts – If the
mainParser
has already been configured to parse arguments which accept one or more parameters, you must provide a list of their short and long forms here. Otherwise, the parameters may be incorrectly identified as a path to an overlay. - shortHelpExtra – If the caller of this function has already added
arguments to the
mainParser
, the long forms of those arguemnts may be passed here as a list to have them included in the short help text.
- mainParser – A
-
fsleyes.parseargs.
_printVersion
(name)¶ Prints the current FSLeyes version.
Parameters: name – Name of the tool (probably either fsleyes
orrender
).
-
fsleyes.parseargs.
_printShortHelp
(mainParser, extra=None)¶ Prints out help for a selection of arguments.
Parameters: - mainParser – The top level
ArgumentParser
. - extra – List containing long forms of any extra main arguments to be included in the short help text.
- mainParser – The top level
-
fsleyes.parseargs.
_printFullHelp
(mainParser)¶ Prints out help for all arguments.
Parameters: mainParser – The top level ArgumentParser
.
-
fsleyes.parseargs.
_applyArgs
(args, overlayList, displayCtx, target, propNames=None, **kwargs)¶ Applies the given command line arguments to the given target object. The target object is added as a keyword argument to pass through to any transform functions.
-
fsleyes.parseargs.
_generateArgs
(overlayList, displayCtx, source, propNames=None)¶ Does the opposite of
_applyArgs()
- generates command line arguments which can be used to configure anothersource
instance in the same way as the provided one.
-
fsleyes.parseargs.
applyMainArgs
(args, overlayList, displayCtx)¶ Applies top-level arguments that are not specific to the scene or any overlays. This should be called before either
applySceneArgs()
orapplyOverlayArgs()
.Parameters: - args –
argparse.Namespace
object containing the parsed command line arguments. - overlayList – A
OverlayList
instance. - displayCtx – A
DisplayContext
instance.
- args –
-
fsleyes.parseargs.
applySceneArgs
(args, overlayList, displayCtx, sceneOpts)¶ Configures the scene displayed by the given
DisplayContext
instance according to the arguments that were passed in on the command line.Note
The scene arguments are applied asynchronously using
idle.idle()
. This is done because theapplyOverlayArgs()
function also applies its arguments asynchrnously, and we want the order of application to match the order in which these functions were called.Parameters: - args –
argparse.Namespace
object containing the parsed command line arguments. - overlayList – A
OverlayList
instance. - displayCtx – A
DisplayContext
instance. - sceneOpts – A
SceneOpts
instance.
- args –
-
fsleyes.parseargs.
generateSceneArgs
(overlayList, displayCtx, sceneOpts, exclude=None)¶ Generates command line arguments which describe the current state of the provided
displayCtx
andsceneOpts
instances.Parameters: - overlayList – A
OverlayList
instance. - displayCtx – A
DisplayContext
instance. - sceneOpts – A
SceneOpts
instance. - exclude – A list of property names to exclude.
- overlayList – A
-
fsleyes.parseargs.
generateOverlayArgs
(overlay, overlayList, displayCtx)¶ Generates command line arguments which describe the display of the current overlay.
Parameters: - overlay – An overlay object.
- overlayList – The
OverlayList
- displayCtx – A
DisplayContext
instance.
-
fsleyes.parseargs.
applyOverlayArgs
(args, overlayList, displayCtx, loadOverlays=True, **kwargs)¶ Loads and configures any overlays which were specified on the command line.
Warning
This function uses the
loadoverlay.loadOverlays()
function which in turn usesidle.idle()
to load the overlays. This means that the overlays are loaded and configured asynchronously, meaning that they may not be loaded by the time that this function returns. See theloadoverlay.loadOverlays()
documentation for more details.Parameters: - args – A
Namespace
instance, as returned by theparseArgs()
function. - overlayList – An
OverlayList
instance, to which the overlays should be added. - displayCtx – A
DisplayContext
instance, which manages the scene and overlay display. - loadOverlays – Defaults to
True
. IfFalse
, it is assumed that the overlays are already loaded - in this case, the arguments are applied synchronously.
All other keyword arguments are passed through to the
loadoverlay.loadOverlays()
function (unlessloadOverlays``is ``False
).- args – A
-
fsleyes.parseargs.
wasSpecified
(namespace, obj, propName)¶ Returns
True
if the givenpropName
on the given object was specified on the command line,False
otherwise.
-
fsleyes.parseargs.
_findOrLoad
(overlayList, overlayFile, overlayType, relatedTo=None)¶ Searches for the given
overlayFile
in theoverlayList
. If not present, it is created using the givenoverlayType
constructor, and inserted into theoverlayList
. The new overlay is inserted into theoverlayList
before therelatedTo
overlay if provided, otherwise appended to the end of the list.
-
fsleyes.parseargs.
fsleyesUrlToArgs
(url)¶ Parses a
fsleyes://
url and returns a list of equivalent command line arguments.
-
fsleyes.parseargs.
_configSpecialOption
(target, parser, optName, shortArg, longArg, helpText)¶ Called by the
_configParser
function for any options which do not map directly to aSceneOpts
orDisplayOpts
property. Calls the_configSpecial
function for the option.Parameters: - target – The
Opts
class with which the option is associated - parser – the
ArgumentParser
to be configured - optNmae – Name of the option
- shortArg – Short form argument for the option
- longArg – Long form argument for the option
- helpText – Help text
- target – The
-
fsleyes.parseargs.
_applySpecialOption
(args, overlayList, displayCtx, target, optName, longArg)¶ Called by the
_applyArgs
function for any options which do not map directly to aSceneOpts
orDisplayOpts
property. Calls the_applySpecial
function for the option.Parameters: - args – The
argparse.Namespace
containing parsed arguments - overlayList – The
OverlayList
- displayCtx – The
DisplayContext
instance - target – The
Opts
instance with which the option is associated - optNmae – Name of the option
- longArg – Name of the corresponding command line argument
- args – The
-
fsleyes.parseargs.
_generateSpecialOption
(overlayList, displayCtx, source, optName, longArg)¶ Called by the
_generateArgs()
function for any options which do not map directly to aSceneOpts
,Display
orDisplayOpts
instance. Calls the_generateSpecial
function for the option.Parameters: - overlayList – The
OverlayList
- displayCtx – The
DisplayContext
instance - source – The
Opts
instance with which the option is associated - optNmae – Name of the option
- longArg – String to use as the long form argument
- overlayList – The
-
fsleyes.parseargs.
_isSpecialConfigOption
(target, optName)¶ Returns
True
if the given option has a special configuration function,False
otherwise.
-
fsleyes.parseargs.
_isSpecialApplyOption
(target, optName)¶ Returns
True
if the given option has a special apply function,False
otherwise.
-
fsleyes.parseargs.
_isSpecialGenerateOption
(target, optName)¶ Returns
True
if the given option has a special generation function,False
otherwise.
-
fsleyes.parseargs.
_getSpecialFunction
(target, optName, prefix)¶ Searches for a function in this module with the name
_prefix_target_option
, searching the class hierarchy fortarget
.
-
fsleyes.parseargs.
_configSpecial_OrthoOpts_xcentre
(target, parser, shortArg, longArg, helpText)¶ Configures the
xcentre
option for theOrthoOpts
class.
-
fsleyes.parseargs.
_configSpecial_OrthoOpts_ycentre
(target, parser, shortArg, longArg, helpText)¶ Configures the
ycentre
option for theOrthoOpts
class.
-
fsleyes.parseargs.
_configSpecial_OrthoOpts_zcentre
(target, parser, shortArg, longArg, helpText)¶ Configures the
zcentre
option for theOrthoOpts
class.
-
fsleyes.parseargs.
_applySpecial_OrthoOpts_xcentre
(args, overlayList, displayCtx, target)¶ Applies the
OrthoOpts.xcentre
option.
-
fsleyes.parseargs.
_applySpecial_OrthoOpts_ycentre
(args, overlayList, displayCtx, target)¶ Applies the
OrthoOpts.ycentre
option.
-
fsleyes.parseargs.
_applySpecial_OrthoOpts_zcentre
(args, overlayList, displayCtx, target)¶ Applies the
OrthoOpts.zcentre
option.
-
fsleyes.parseargs.
_applySpecialOrthoOptsCentre
(centre, displayCtx, xax, yax, canvas)¶ Shared by the
xcentre
,ycentre
, andzcentre
functions.
-
fsleyes.parseargs.
_generateSpecial_OrthoOpts_xcentre
(overlayList, displayCtx, source, longArg)¶ Generates CLI arguments for the
OrthoOpts.xcentre
option.
-
fsleyes.parseargs.
_generateSpecial_OrthoOpts_ycentre
(overlayList, displayCtx, source, longArg)¶ Generates CLI arguments for the
OrthoOpts.ycentre
option.
-
fsleyes.parseargs.
_generateSpecial_OrthoOpts_zcentre
(overlayList, displayCtx, source, longArg)¶ Generates CLI arguments for the
OrthoOpts.zcentre
option.
-
fsleyes.parseargs.
_generateSpecialOrthoOptsCentre
(displayCtx, xax, yax, canvas)¶ Used by the generation functions for the
xcentre
,ycentre
, andzcentre
options.
-
fsleyes.parseargs.
_applySpecial_SceneOpts_movieSyncRefresh
(args, overlayList, displayCtx, target)¶ Applies the
SceneOpts.movieSyncRefresh
option.
-
fsleyes.parseargs.
_configSpecial_Volume3DOpts_clipPlane
(target, parser, shortArg, longArg, helpText)¶ Configures the
clipPlane
option for theVolumeOpts
class. This option allows a clip plane to be defined - the user provides the position, azimuth and inclination as a single argument.
-
fsleyes.parseargs.
_applySpecial_Volume3DOpts_clipPlane
(args, overlayList, displayCtx, target)¶ Applies the
Volume3DOpts.clipPlane
option.
-
fsleyes.parseargs.
_configSpecial_Volume3DOpts_dithering
(target, parser, shortArg, longArg, helpText)¶ Handle the deprecated
Volume3DOpts.dithering
property.
-
fsleyes.parseargs.
_applySpecial_Volume3DOpts_dithering
(args, overlayList, displayCtx, target)¶ Handle the deprecated
Volume3DOpts.dithering
property.
-
fsleyes.parseargs.
_generateSpecial_Volume3DOpts_dithering
(overlayList, displayCtx, source, longArg)¶ Handle the deprecated
Volume3DOpts.dithering
property.
-
fsleyes.parseargs.
_generateSpecial_Volume3DOpts_clipPlane
(overlayList, displayCtx, source, longArg)¶ Generates arguemnts for the
Volume3DOpts.clipPlane
option.
-
fsleyes.parseargs.
_configSpecial_Scene3DOpts_cameraRotation
(target, parser, shortArg, longArg, helpText)¶ Configures the
Scene3DOpts.cameraRotation
option.
-
fsleyes.parseargs.
_applySpecial_Scene3DOpts_cameraRotation
(args, overlayList, displayCtx, target)¶ Applies the
Scene3DOpts.cameraRotation
option.
-
fsleyes.parseargs.
_generateSpecial_Scene3DOpts_cameraRotation
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
Scene3DOpts.cameraRotation
option.
-
fsleyes.parseargs.
_applySpecial_VectorOpts_orientFlip
(args, overlayList, displayCtx, target)¶ Applies the
VectorOpts.orientFlip
option.The
VectorOpts.orientFlip
property is initialised toFalse
for images with a radiological storage order, andTrue
for images with a neurological storage order. So if this argument is specified, we need to invert its initial value - apply the flip for radiologically stored images, but not for neurologically stored images.
-
fsleyes.parseargs.
_generateSpecial_VectorOpts_orientFlip
(overlayList, displayCtx, source, longArg)¶ Generates the
VectorOpts.orientFlip
option.
-
fsleyes.parseargs.
_applySpecial_MeshOpts_vertexData
(args, overlayList, displayCtx, target)¶ Applies the
MeshOpts.vertexData
option.
-
fsleyes.parseargs.
_applySpecial_MeshOpts_vertexSet
(args, overlayList, displayCtx, target)¶ Applies the
MeshOpts.vertexSet
option.
-
fsleyes.parseargs.
_applySpecial_VolumeOpts_overrideDataRange
(args, overlayList, displayCtx, target)¶ Applies the
VolumeOpts.overrideDataRange
option.If the
overrideDataRange
command line argument has been provided, we need to set theVolumeOpts.enableOverrideDataRange
property.
-
fsleyes.parseargs.
_generateSpecial_VolumeOpts_overrideDataRange
(overlayList, displayCtx, source, longArg)¶ Generates the
VolumeOpts.overrideDataRange
option.If the
VolumeOpts.enableOverrideDataRange
property isFalse
, no arguments are generated.
-
fsleyes.parseargs.
_applySpecial_VolumeOpts_clippingRange
(args, overlayList, displayCtx, target)¶ Applies the
VolumeOpts.clippingRange
option.The
VolumeOpts.clippingRange
property can be specified on the command line normally (as two numbers), or can be specified as a percentile by appending a'%'
character to the high range value.
-
fsleyes.parseargs.
_applySpecial_VolumeOpts_displayRange
(args, overlayList, displayCtx, target)¶ Applies the
VolumeOpts.displayRange
option.The
VolumeOpts.displayRange
property can be specified on the command line normally (as two numbers), or can be specified as a percentile by appending a'%'
character to the high range value.
-
fsleyes.parseargs.
_applyVolumeOptsRange
(arange, target)¶ This function is used to parse display/clipping range arguments.
-
fsleyes.parseargs.
_applySpecial_ColourMapOpts_cmap
(args, overlayList, displayCtx, target)¶ Handles the
ColourMapOpts.cmap
option. See_applyColourMap()
.
-
fsleyes.parseargs.
_applySpecial_ColourMapOpts_negativeCmap
(args, overlayList, displayCtx, target)¶ Handles the
ColourMapOpts.negativeCmap
option. See_applyColourMap()
.
-
fsleyes.parseargs.
_applySpecial_VectorOpts_cmap
(args, overlayList, displayCtx, target)¶ Handles the
VectorOpts.cmap
option. See_applyColourMap()
.
-
fsleyes.parseargs.
_applyColourMap
(cmap, overlayList, displayCtx)¶ Handles a colour map argument. If the specified colour map is a file, it is loaded and registered with the
colourmaps
module. Returns a new value for the colour map argument.
-
fsleyes.parseargs.
_generateSpecial_ColourMapOpts_cmap
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
ColourMapOpts.cmap
argument.
-
fsleyes.parseargs.
_generateSpecial_ColourMapOpts_negativeCmap
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
ColourMapOpts.negativeCmap
argument.
-
fsleyes.parseargs.
_generateSpecial_VectorOpts_cmap
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
VectorOpts.lut
argument.
-
fsleyes.parseargs.
_generateColourMap
(longArg, cmap)¶ Generates a command line argument for the given colour map. This be different depending on whether the colour map is installed as a FSLeyes colour map, or has been manualy specified from a colour map file.
-
fsleyes.parseargs.
_applySpecial_LabelOpts_lut
(args, overlayList, displayCtx, target)¶ Handles the
LabelOpts.lut
option. See_applyLookupTable()
.
-
fsleyes.parseargs.
_applySpecial_MeshOpts_lut
(args, overlayList, displayCtx, target)¶ Handles the
MeshOpts.lut
option. See_applyLookupTable()
.
-
fsleyes.parseargs.
_applyLookupTable
(lut, overlayList, displayCtx)¶ Handles a lookup table argument. If the specified lookup table is a file, it is loaded and registered with the
colourmaps
module. Returns a new value for the lookup table argument.
-
fsleyes.parseargs.
_generateSpecial_LabelOpts_lut
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
LabelOpts.lut
argument.
-
fsleyes.parseargs.
_generateSpecial_MeshOpts_lut
(overlayList, displayCtx, source, longArg)¶ Generates arguments for the
MeshOpts.lut
argument.
-
fsleyes.parseargs.
_generateLookupTable
(longArg, lut)¶ Generates a command line argument for the given lookup table. This will be different depending on whether the lookup table is installed as a FSLeyes lookup tablea, or has been manualy specified from a lookup table file.