[slicer-devel] Loading MRML Nodes and pass to an add on python modules that uses slicer from cmd line

Steve Pieper pieper at bwh.harvard.edu
Thu Jun 17 14:59:52 EDT 2010


Hi Deepika -

It's a little bit long to put on the command line, but if you write a 
wrapper script it should be okay - you can do something like this:

> ./Slicer3 --execpython "import Slicer; Slicer.slicer.Application.GetModuleGUIByName('Volumes').GetLogic().AddArchetypeVolume('/tmp/volumeFile.nrrd', 'volumeName')"


Pretty much the full API is accessible from python:

http://www.na-mic.org/Slicer/Documentation/Slicer3-doc/html/classes.html

Best,
Steve


On Jun/17/10 2:14 PM, mahaling at email.unc.edu wrote:
> How do I add nrrd files into MRML nodes from cmd line? Right now, if I
> use --execpython, Slicer gui starts, loads files that I have provided as
> arguments into MRML nodes but doesn't start execution by itself.
>
> Are there some documents/man pages where I can find the attributes of
> MRML Node/Scene - that can be used in python code?
>
> -Deepika
>
> Quoting Steve Pieper <pieper at bwh.harvard.edu>:
>
>> Hi Deepika -
>>
>> There is are --execpython (runs command after gui starts) and
>> --evalpython (runs command instead of starting gui) command line
>> arguments but I've never tried to use them to run a module. It may not
>> be ideal but it's worth trying.
>>
>> In theory there would be a way to essentially 'import slicer' and get
>> all the needed commands in the interpreter so you could run the
>> module. But this hasn't ever been set up, I don't think.
>>
>> Demian has similar goals, so he may have some suggestions.
>>
>> -Steve
>>
>>
>>
>> On Jun/17/10 11:21 AM, mahaling at email.unc.edu wrote:
>>> Hi Steve,
>>>
>>> I am Deepika, a student of Martin Styner's at UNC. I have a python
>>> module that can be added to Slicer(i.e. not in-built in Slicer) and uses
>>> MRML nodes(DWI volumes and labelmaps) loaded into Slicer as input. I'd
>>> like to know if there is a way I can do the loading and execution of the
>>> module from command line (without having to open Slicer explicitly) and
>>> if so how.I don't want to modify the existing code but can write a
>>> wrapper if needed.
>>>
>>> I have posted this on the Slicer users and developers mailing lists too,
>>> so sorry if I am flooding your inbox.
>>>
>>> Thanks,
>>> Deepika
>>>
>>>
>>>
>>>
>>
>>
>
>


More information about the slicer-devel mailing list