View Issue Details

IDProjectCategoryView StatusLast Update
0003358Slicer4Core: CLI infrastructurepublic2020-01-22 12:38
Reporterfedorov Assigned Tojcfr  
PrioritylowSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version 
Target VersionSlicer 5.1.0Fixed in Version 
Summary0003358: Cannot launch CLIs by name from command line on Mac using packaged Slicer
Description

Below are two examples, one trying to launch BRAINSFit using packaged Slicer (doesn't work), and the second one for a local build (works). Looks like some paths are not set correctly. Launching CLIs using packaged Slicer works on Linux.

[fedorov@beat] /Applications/Slicer.app/Contents/MacOS/Slicer --launch BRAINSFit --help
Usage
Slicer [options]

Options
--, --ignore-rest Ignores the rest of the labeled arguments following this flag. (default: false)
-h, --help Display available command line arguments.
--testing Activate testing mode. Doesn't use user settings in that mode. (default: false)
--disable-python Disable python support. This is equivalent to build the application with Slicer_USE_PYTHONQT=OFF.
--python-script Python script to execute after slicer loads.
--python-code Python code to execute after slicer loads.
-c Python code to execute after slicer loads. By default, no modules are loaded and Slicer exits afterward.
--ignore-slicerrc Do not load the Slicer resource file (~/.slicerrc.py).
--additional-module-path Additional module path to consider when searching for modules to load.
--additional-module-paths List of additional module path to consider when searching for modules to load.
--disable-cli-modules Disables the loading of Command Line Modules.
--disable-loadable-modules Disables the loading of Loadable Modules.
--disable-scripted-loadable-modules Disables the loading of Scripted Loadable Modules.
--version Displays version information and exits.
--program-path Displays application program path and exits.
--home Displays home path and exits.
--settings-path Displays settings path and exits.
--temporary-path Displays temporary path and exits.
--verbose-module-discovery Enable verbose output during module discovery process.
--disable-settings Start application ignoring user settings.
--disable-message-handlers Start application disabling the 'terminal' message handlers.
--disable-tooltips Disables toolstips in the user interface.
--no-splash Disables the startup splash screen.
--no-main-window Disables display of the main slicer window. Use with --python-script for alternate interface
--show-python-interactor Show Python interactor at startup.
--qt-testing Enable QtTesting in the user interface

~/local/builds/Slicer4-Debug
[fedorov@beat] ~/local/builds/Slicer4-Debug/Slicer-build/Slicer --launch BRAINSFit --help
Usage
Slicer [options]

Options
--launcher-help Display help
--launcher-version Show launcher version information
--launcher-verbose Verbose mode
--launch Specify the application to launch
--launcher-detach Launcher will NOT wait for the application to finish
--launcher-no-splash Hide launcher splash
--launcher-timeout Specify the time in second before the launcher kills the application. -1 means no timeout (default: -1)
--launcher-dump-environment Launcher will print environment variables to be set, then exit
--launcher-additional-settings Additional settings file to consider
--launcher-ignore-user-additional-settings Ignore additional user settings
--launcher-generate-exec-wrapper-script Generate executable wrapper script allowing to set the environment
--launcher-generate-template Generate an example of setting file
--designer Start Qt designer using Slicer plugins
--xterm Start xterm
--gdb Start gdb

USAGE:

/Users/fedorov/local/builds/Slicer4-Debug/Slicer-build/lib/Slicer-4.2/cl
i-modules/././BRAINSFit
[--returnparameterfile
<std::string>]
[--processinformationaddress
<std::string>] [--xml] [--echo]
[--costMetric <MMI|MSE|NC|MC>]
[--permitParameterVariation
<std::vector<int>>] [-p] [-G]
[--projectedGradientTolerance
<double>]
[--costFunctionConvergenceFactor
<double>] [--debugLevel <int>]
[--forceMINumberOfThreads <int>]
[--numberOfThreads <int>]
[--writeTransformOnFailure]
[--failureExitCode <int>]
[--maximumStepLength <double>]
[--relaxationFactor <double>]
[--ROIAutoClosingSize <double>]
[--ROIAutoDilateSize <double>]
[--useExplicitPDFDerivativesMode
<AUTO|ON|OFF>]
[--useCachingOfBSplineWeightsMode
<ON|OFF>]
[--removeIntensityOutliers
<double>] [--medianFilterSize
<std::vector<int>>]
[--movingVolumeTimeIndex <int>]
[--fixedVolumeTimeIndex <int>]
[--outputTransform <std::string>]
[--transformType
<std::vector<std::string>>]
[--strippedOutputTransform
<std::string>]
[--numberOfMatchPoints <int>]
[--numberOfHistogramBins <int>]
[-e] [--maxBSplineDisplacement
<double>] [--skewScale <double>]
[--reproportionScale <double>]
[--translationScale <double>]
[--minimumStepLength
<std::vector<double>>]
[--interpolationMode
<NearestNeighbor|Linear
|ResampleInPlace|BSpline
|WindowedSinc|Hamming|Cosine|Welch
|Lanczos|Blackman>]
[--scaleOutputValues]
[--maskInferiorCutOffFromCenter
<double>] [--backgroundFillValue
<double>] [--outputVolumePixelType
<float|short|ushort|int|uint
|uchar>] [--outputMovingVolumeROI
<std::string>]
[--outputFixedVolumeROI
<std::string>]
[--movingBinaryVolume
<std::string>] [--fixedBinaryVolume
<std::string>]
[--maskProcessingMode <NOMASK
|ROIAUTO|ROI>]
[--numberOfIterations
<std::vector<int>>]
[--useROIBSpline] [--splineGridSize
<std::vector<int>>]
[--numberOfSamples <int>]
[--useComposite] [--useSyN]
[--useBSpline] [--useAffine]
[--useScaleSkewVersor3D]
[--useScaleVersor3D] [--useRigid]
[--initializeTransformMode <Off
|useMomentsAlign
|useCenterOfHeadAlign
|useGeometryAlign
|useCenterOfROIAlign>]
[--initialTransform <std::string>]
[--outputVolume <std::string>]
[--linearTransform <std::string>]
[--bsplineTransform <std::string>]
[--movingVolume <std::string>]
[--fixedVolume <std::string>] [--]
[--version] [-h]

Where:

--returnparameterfile <std::string>
Filename in which to write simple return parameters (int, float,
int-vector, etc.) as opposed to bulk return parameters (image,
geometry, transform, measurement, table).

--processinformationaddress <std::string>
Address of a structure to store process information (progress, abort,
etc.). (default: 0)

--xml
Produce xml description of command line arguments (default: 0)

--echo
Echo the command line arguments (default: 0)

--costMetric <MMI|MSE|NC|MC>
The cost metric to be used during fitting. Defaults to MMI. Options
are MMI (Mattes Mutual Information), MSE (Mean Square Error), NC
(Normalized Correlation), MC (Match Cardinality for binary images)
(default: MMI)

--permitParameterVariation <std::vector<int>>
A bit vector to permit linear transform parameters to vary under
optimization. The vector order corresponds with transform parameters,
and beyond the end ones fill in as a default. For instance, you can
choose to rotate only in x (pitch) with 1,0,0; this is mostly for
expert use in turning on and off individual degrees of freedom in
rotation, translation or scaling without multiplying the number of
transform representations; this trick is probably meaningless when
tried with the general affine transform.

-p, --promptUser
Prompt the user to hit enter each time an image is sent to the
DebugImageViewer (default: 0)

-G, --gui
Display intermediate image volumes for debugging. NOTE: This is not
part of the standard build sytem, and probably does nothing on your
installation. (default: 0)

--projectedGradientTolerance <double>
From itkLBFGSBOptimizer.h: Set/Get the ProjectedGradientTolerance.
Algorithm terminates when the project gradient is below the tolerance.
Default lbfgsb value is 1e-5, but 1e-4 seems to work well. (default:
1e-05)

--costFunctionConvergenceFactor <double>
From itkLBFGSBOptimizer.h: Set/Get the CostFunctionConvergenceFactor.
Algorithm terminates when the reduction in cost function is less than
(factor * epsmcj) where epsmch is the machine precision. Typical
values for factor: 1e+12 for low accuracy; 1e+7 for moderate accuracy
and 1e+1 for extremely high accuracy. 1e+9 seems to work well.
(default: 1e+09)

--debugLevel <int>
Display debug messages, and produce debug intermediate results. 0=OFF
, 1=Minimal, 10=Maximum debugging. (default: 0)

--forceMINumberOfThreads <int>
Force the the maximum number of threads to use for non thread safe MI
metric. (default: -1)

--numberOfThreads <int>
Explicitly specify the maximum number of threads to use. (default is
auto-detected) (default: -1)

--writeTransformOnFailure
Flag to save the final transform even if the numberOfIterations are
reached without convergence. (Intended for use when --failureExitCode
0 ) (default: 0)

--failureExitCode <int>
If the fit fails, exit with this status code. (It can be used to
force a successfult exit status of (0) if the registration fails due
to reaching the maximum number of iterations. (default: -1)

--maximumStepLength <double>
Internal debugging parameter, and should probably never be used from
the command line. This will be removed in the future. (default: 0.2)

--relaxationFactor <double>
Internal debugging parameter, and should probably never be used from
the command line. This will be removed in the future. (default: 0.5)

--ROIAutoClosingSize <double>
This flag is only relavent when using ROIAUTO mode for initializing
masks. It defines the hole closing size in mm. It is rounded up to
the nearest whole pixel size in each direction. The default is to use
a closing size of 9mm. For mouse data this value may need to be reset
to 0.9 or smaller. (default: 9)

--ROIAutoDilateSize <double>
This flag is only relavent when using ROIAUTO mode for initializing
masks. It defines the final dilation size to capture a bit of
background outside the tissue region. A setting of 10mm has been
shown to help regularize a BSpline registration type so that there is
some background constraints to match the edges of the head better.
(default: 0)

--useExplicitPDFDerivativesMode <AUTO|ON|OFF>
Using mode AUTO means OFF for BSplineDeformableTransforms and ON for
the linear transforms. The ON alternative uses more memory to
sometimes do a better job. (default: AUTO)

--useCachingOfBSplineWeightsMode <ON|OFF>
This is a 5x speed advantage at the expense of requiring much more
memory. Only relevant when transformType is BSpline. (default: ON)

--removeIntensityOutliers <double>
The half percentage to decide outliers of image intensities. The
default value is zero, which means no outlier removal. If the value of
0.005 is given, the moduel will throw away 0.005 % of both tails, so
0.01% of intensities in total would be ignored in its statistic
calculation. (default: 0)

--medianFilterSize <std::vector<int>>
The radius for the optional MedianImageFilter preprocessing in all 3
directions (in voxels). (default: 0,0,0)

--movingVolumeTimeIndex <int>
The index in the time series for the 3D moving image to fit, if
4-dimensional. (default: 0)

--fixedVolumeTimeIndex <int>
The index in the time series for the 3D fixed image to fit, if
4-dimensional. (default: 0)

--outputTransform <std::string>
(optional) Filename to which save the (optional) estimated transform.
NOTE: You must select either the outputTransform or the outputVolume
option.

--transformType <std::vector<std::string>>
Specifies a list of registration types to be used. The valid types
are, Rigid, ScaleVersor3D, ScaleSkewVersor3D, Affine, BSpline and SyN.
Specifiying more than one in a comma separated list will initialize
the next stage with the previous results. If registrationClass flag is
used, it overrides this parameter setting.

--strippedOutputTransform <std::string>
File name for the rigid component of the estimated affine transform.
Can be used to rigidly register the moving image to the fixed image.
NOTE: This value is overwritten if either bsplineTransform or
linearTransform is set.

--numberOfMatchPoints <int>
the number of match points (default: 10)

--numberOfHistogramBins <int>
The number of histogram levels (default: 50)

-e, --histogramMatch
Histogram Match the input images. This is suitable for images of the
same modality that may have different absolute scales, but the same
overall intensity profile. Do NOT use if registering images from
different modailties. (default: 0)

--maxBSplineDisplacement <double>
Sets the maximum allowed displacements in image physical coordinates
(mm) for BSpline control grid along each axis. A value of 0.0
indicates that the problem should be unbounded. NOTE: This only
constrains the BSpline portion, and does not limit the displacement
from the associated bulk transform. This can lead to a substantial
reduction in computation time in the BSpline optimizer. (default: 0)

--skewScale <double>
ScaleSkewVersor3D Skew compensation factor. Increase this to put more
skew in a ScaleSkewVersor3D search pattern. 1.0 works well with a
translationScale of 1000.0 (default: 1)

--reproportionScale <double>
ScaleVersor3D 'Scale' compensation factor. Increase this to put more
rescaling in a ScaleVersor3D or ScaleSkewVersor3D search pattern. 1.0
works well with a translationScale of 1000.0 (default: 1)

--translationScale <double>
How much to scale up changes in position compared to unit rotational
changes in radians -- decrease this to put more rotation in the search
pattern. (default: 1000)

--minimumStepLength <std::vector<double>>
Each step in the optimization takes steps at least this big. When
none are possible, registration is complete. (default: 0.005)

--interpolationMode <NearestNeighbor|Linear|ResampleInPlace|BSpline
|WindowedSinc|Hamming|Cosine|Welch|Lanczos|Blackman>
Type of interpolation to be used when applying transform to moving
volume. Options are Linear, NearestNeighbor, BSpline, WindowedSinc,
or ResampleInPlace. The ResampleInPlace option will create an image
with the same discrete voxel values and will adjust the origin and
direction of the physical space interpretation. (default: Linear)

--scaleOutputValues
If true, and the voxel values do not fit within the minimum and
maximum values of the desired outputVolumePixelType, then linearly
scale the min/max output image voxel values to fit within the min/max
range of the outputVolumePixelType. (default: 0)

--maskInferiorCutOffFromCenter <double>
For use with --initializeTransformMode useCenterOfHeadAlign (and
--maskProcessingMode ROIAUTO): the cut-off below the image centers, in
millimeters, (default: 1000)

--backgroundFillValue <double>
Background fill value for output image. (default: 0)

--outputVolumePixelType <float|short|ushort|int|uint|uchar>
The output image Pixel Type is the scalar datatype for representation
of the Output Volume. (default: float)

--outputMovingVolumeROI <std::string>
The ROI automatically found in moving image, ONLY FOR ROIAUTO mode.
(Values are zero and non-zero.)

--outputFixedVolumeROI <std::string>
The ROI automatically found in fixed image, ONLY FOR ROIAUTO mode.
(Values are zero and non-zero.)

--movingBinaryVolume <std::string>
Moving Image binary mask volume, ONLY FOR MANUAL ROI mode. (Values are
zero and non-zero.)

--fixedBinaryVolume <std::string>
Fixed Image binary mask volume, ONLY FOR MANUAL ROI mode. (Values are
zero and non-zero.)

--maskProcessingMode <NOMASK|ROIAUTO|ROI>
What mode to use for using the masks. If ROIAUTO is choosen, then the
mask is implicitly defined using a otsu forground and hole filling
algorithm. The Region Of Interest mode (choose ROI) uses the masks to
define what parts of the image should be used for computing the
transform. (default: NOMASK)

--numberOfIterations <std::vector<int>>
The maximum number of iterations to try before failing to converge.
Use an explicit limit like 500 or 1000 to manage risk of divergence
(default: 1500)

--useROIBSpline
When set, will use the bounding box of the input ROIs to define spline
grid support region. Otherwise will use the whole image. (default: 0)

--splineGridSize <std::vector<int>>
The number of subdivisions of the BSpline Grid to be centered on the
image space (in voxels). Each dimension must have at least 3
subdivisions for the BSpline to be correctly computed. (default: 14,10
,12)

--numberOfSamples <int>
The number of voxels sampled for mutual information computation.
Increase this for a slower, more careful fit. You can also limit the
sampling focus with ROI masks and ROIAUTO mask generation. (default:
100000)

--useComposite
Perform a Composite registration as part of the sequential
registration steps. This family of options superceeds the use of
transformType if any of them are set. (default: 0)

--useSyN
Perform a SyN registration as part of the sequential registration
steps. This family of options superceeds the use of transformType if
any of them are set. (default: 0)

--useBSpline
Perform a BSpline registration as part of the sequential registration
steps. This family of options superceeds the use of transformType if
any of them are set. (default: 0)

--useAffine
Perform an Affine registration as part of the sequential registration
steps. This family of options superceeds the use of transformType if
any of them are set. (default: 0)

--useScaleSkewVersor3D
Perform a ScaleSkewVersor3D registration as part of the sequential
registration steps. This family of options superceeds the use of
transformType if any of them are set. (default: 0)

--useScaleVersor3D
Perform a ScaleVersor3D registration as part of the sequential
registration steps. This family of options superceeds the use of
transformType if any of them are set. (default: 0)

--useRigid
Perform a rigid registration as part of the sequential registration
steps. This family of options superceeds the use of transformType if
any of them are set. (default: 0)

--initializeTransformMode <Off|useMomentsAlign|useCenterOfHeadAlign
|useGeometryAlign|useCenterOfROIAlign>
Determine how to initialize the transform center. GeometryAlign on
assumes that the center of the voxel lattice of the images represent
similar structures. MomentsAlign assumes that the center of mass of
the images represent similar structures. useCenterOfHeadAlign
attempts to use the top of head and shape of neck to drive a center of
mass estimate. Off assumes that the physical space of the images are
close, and that centering in terms of the image Origins is a good
starting point. This flag is mutually exclusive with the
initialTransform flag. (default: Off)

--initialTransform <std::string>
Filename of transform used to initialize the registration. This CAN
NOT be used with either CenterOfHeadLAlign, MomentsAlign,
GeometryAlign, or initialTransform file.

--outputVolume <std::string>
(optional) Output image for registration. NOTE: You must select either
the outputTransform or the outputVolume option.

--linearTransform <std::string>
(optional) Filename to which save the estimated transform. NOTE: You
must set at least one output object (either a deformed image or a
transform. NOTE: USE THIS ONLY IF THE FINAL TRANSFORM IS ---NOT---
BSpline

--bsplineTransform <std::string>
(optional) Filename to which save the estimated transform. NOTE: You
must set at least one output object (either a deformed image or a
transform. NOTE: USE THIS ONLY IF THE FINAL TRANSFORM IS BSpline

--movingVolume <std::string>
The moving image for registration by mutual information optimization.

--fixedVolume <std::string>
The fixed image for registration by mutual information optimization.

--, --ignore_rest
Ignores the rest of the labeled arguments following this flag.

--version
Displays version information and exits.

-h, --help
Displays usage information and exits.

Description: Register a three-dimensional volume to a reference volume
(Mattes Mutual Information by default). Full documentation avalable
here:
http://wiki.slicer.org/slicerWiki/index.php/Documentation/4.1/Modules/BR
AINSFit. Method described in BRAINSFit: Mutual Information Registrations
of Whole-Brain 3D Images, Using the Insight Toolkit, Johnson H.J.,
Harris G., Williams K., The Insight Journal, 2007.
http://hdl.handle.net/1926/1291

Author(s): Hans J. Johnson, hans-johnson -at- uiowa.edu,
http://www.psychiatry.uiowa.edu

Acknowledgements: Hans Johnson(1,3,4); Kent Williams(1); Gregory
Harris(1), Vincent Magnotta(1,2,3); Andriy Fedorov(5) 1=University of
Iowa Department of Psychiatry, 2=University of Iowa Department of
Radiology, 3=University of Iowa Department of Biomedical Engineering,
4=University of Iowa Department of Electrical and Computer Engineering,
5=Surgical Planning Lab, Harvard

TagsNo tags attached.

Activities

jcfr

jcfr

2013-09-02 12:28

administrator   ~0009780

This is explained by the fact the macosx package does NOT provide the launcher.

Propose fix:

  • On MacOSX, a "--launch" option could be added to Slicer itself. After ensuring the env is properly setup, it would then start any program as it is done by the launcher.
jcfr

jcfr

2014-03-07 11:33

administrator   ~0011386

This would be nice to fix - but we think it's low priority right now.

Let us know if it is high priority for you or if you.

fedorov

fedorov

2014-07-01 12:56

developer   ~0012117

This means that scripts using Slicer that are used on Linux need to be changed if they need to be run on Mac.

jcfr

jcfr

2014-07-03 06:07

administrator   ~0012128

The solution would be to install the launcher in Contents/bin/

It means, that Slicer could be started as usual without the Slicer using:

Slicer.app/Contents/MacOSX/Slicer

or by clicking on the Slicer.app on your desktop.

On the other hand, script would be able to start Slicer or start executable in the Slicer path using the launcher located in:

Slicer.app/Contents/bin/Slicer

Issue History

Date Modified Username Field Change
2013-09-02 12:24 fedorov New Issue
2013-09-02 12:24 fedorov Status new => assigned
2013-09-02 12:24 fedorov Assigned To => millerjv
2013-09-02 12:24 fedorov Assigned To millerjv => jcfr
2013-09-02 12:26 jcfr Target Version => Slicer 4.3.1
2013-09-02 12:28 jcfr Note Added: 0009780
2013-09-17 11:22 jcfr Target Version Slicer 4.3.1 => Slicer 4.3.2
2014-03-06 10:15 nicole Target Version Slicer 4.3.2 => Slicer 4.4.0
2014-03-07 11:33 jcfr Note Added: 0011386
2014-03-07 11:33 jcfr Status assigned => acknowledged
2014-03-07 11:33 jcfr Target Version Slicer 4.4.0 =>
2014-07-01 12:56 fedorov Note Added: 0012117
2014-07-03 06:03 jcfr Priority normal => low
2014-07-03 06:03 jcfr Target Version => Slicer 4.4.0
2014-07-03 06:07 jcfr Note Added: 0012128
2014-07-29 09:45 jcfr Target Version Slicer 4.4.0 => Slicer 4.5.0-1
2015-11-02 08:38 jcfr Target Version Slicer 4.5.0-1 => Slicer 4.5.1
2016-10-12 02:30 jcfr Target Version Slicer 4.5.1 => Slicer 4.7.0
2017-09-27 14:46 lassoan Target Version Slicer 4.7.0 => backlog
2017-10-11 00:42 jcfr Status acknowledged => assigned
2017-10-11 00:42 jcfr Target Version backlog => Slicer 4.7.0
2017-10-18 01:08 jcfr Target Version Slicer 4.7.0 => Slicer 4.9.0
2018-09-11 14:07 jcfr Target Version Slicer 4.9.0 => Slicer 4.11.0
2020-01-22 12:38 jcfr Target Version Slicer 4.11.0 => Slicer 5.1.0