**3DSlicer**之Python脚本储存库翻译_1.命令行启动

本文档详细介绍了如何在命令行中使用Slicer,包括启动Slicer、打开图像和场景文件,以及运行Python命令和脚本。通过--python-code选项可以加载文件并执行自定义的Python命令,而--python-script则用于运行存储在外部脚本文件中的Python代码。在不显示图形用户界面的情况下,这些命令使得Slicer的自动化和脚本化操作更为便捷。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Script repository译: 脚本存储库

Note译: 注意

Usage: Copy-paste the code lines displayed below or the linked .py file contents into Python console in Slicer. Or save them to a .py file and run them using execfile.译: **用法:将下面显示的代码行或链接的.py文件内容复制粘贴到Slicer中的Python控制台中。 或者将它们保存到.py文件中,然后使用execfile运行它们。

Launch Slicer译: 启动Slicer

Open a file with Slicer at the command line译: 在命令行

Open imagefile.nrrd file in Slicer:译: 上使用Slicer打开文件在Slicer中打开imagefile.nrrd文件:

Slicer.exe /full/path/to/imagefile.nrrd

Note译: 注意

It may be necessary to specify full path to the Slicer executable and to the file that needs to be loaded.译: 可能需要指定Slicer可执行文件的完整路径,并 到需要加载的文件。

To load a file with non-default options, you can use --python-code option to run slicer.util.load... commands.译: 要加载具有非默认选项的文件,可以使用–python-code选项来运行slicer.util.load …命令。

Open an .mrb file with Slicer at the command line译: 在命令行上使用Slicer打开.mrb文件

Slicer.exe --python-code "slicer.util.loadScene('f:/2013-08-23-Scene.mrb')"

Run Python commands in the Slicer environment译: 在Slicer环境中运行Python命令

Run Python commands, without showing any graphical user interface:译: 运行Python命令,但不显示任何图形用户界面:

Slicer.exe --python-code "doSomething; doSomethingElse; etc." --testing --no-splash --no-main-window

Slicer exits when the commands are completed because --testing options is specified.译: 当命令完成后,Slicer退出 因为指定了--testing选项。

Run a Python script file in the Slicer environment译: 在Slicer环境中运行Python脚本文件

Run a Python script (stored in script file), without showing any graphical user interface:译: 运行Python脚本(存储在脚本文件中),但不显示任何图形用户界面:

Slicer.exe --python-script "/full/path/to/myscript.py" --no-splash --no-main-window

To make Slicer exit when the script execution is completed, call sys.exit(errorCode) (where errorCode is set 0 for success and other value to indicate error).译: 若要在脚本执行完成后退出Slicer,请调用sys .exit(errorCode)(其中将errorCode设置为0表示成功,其他值表示错误)。

谷歌翻译自:Script repository — 3D Slicer documentation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值