Hi Kaori,

Sorry - I made a mistake. The load function is only intended for use in the python shell, not from a script. To load an image in a script, you can do something like this:

overlayList.append(Image('/.../subj01/subj01-T1.nii.gz'))

On 31 July 2017 at 19:50, Kaori Ito <[log in to unmask]> wrote:
Hi Paul,

Thanks for your response and for creating such a useful tool! 

When I change the index to 0, it is still the same result (see below). 

Regarding the SliceCanvas object, can you please expand on that a little more? Is it an object that should be defined in fsleyes' python shell? When I type it into the python shell directly (after loading an image), I get an error saying it's not defined: 'NameError: name 'SliceCanvas' is not defined'



makeImage.py script: 

>> load('/.../subj01/subj01-T1.nii.gz')
>> print (overlayList)
>> overlay = overlayList[0]

output:

fsleyes --runscript /...scripts/makeImage.py 

[] 
WARNING        runscript.pyc  104: __doAction      - Script (/.../scripts/makeImage.py) could not be executed: list index out of range

Traceback (most recent call last):

  File "fsleyes/actions/runscript.pyc", line 98, in __doAction

  File "fsleyes/actions/runscript.pyc", line 166, in runScript

  File "/.../scripts/makeImage.py", line 7, in <module>

  File "fsleyes/overlay.pyc", line 230, in __getitem__

  File "fsleyes_props/properties_value.pyc", line 1112, in __getitem__

IndexError: list index out of range


Thanks,
Kaori



On Mon, Jul 31, 2017 at 2:00 AM, paul mccarthy <[log in to unmask]> wrote:
Hi Kaori,

In your code, you are referring to overlaylist[1] - as python indices start from 0, does it work if you change this to overlayList[0] ?

There is no direct command to save a screenshot from the python shell, although it is a good idea, so I will look at adding it in.

In the meantime, if you can get a reference to the SliceCanvas object(s), you can call its getBitmap method to get an in-memory bitmap that you can then save out to file. However, if you want to save an image of multiple canvases (e.g. the ortho view), you would need to generate the bitmap for each canvas, and manually arrange them.

Cheers,

Paul

On 29 July 2017 at 03:35, Kaori Ito <[log in to unmask]> wrote:
My apologies! Looks like the first part of my message didn't get posted. Here it is:

Hi all,

I would ideally like to use fsleyes to render the same type of images for a large number of subjects. I am able to recursively call fsleyes -render , but I would prefer to run a python script in the python shell within the program, rather than call the program again and again. I am using the standalone fsleyes version on a mac.

First, is there a command I can call on the python shell to render images? (equivalent of fsleyes -render)

Additionally, when I load an image and attempt to access overlayList within my script, I get the error: "list index out of range" - as if it hasn't been set (see below for full output). But, when I load the image from the script and then open up the python shell from fsleyes and type in overlayList, my image is loaded and overlayList is accessible. Can someone explain why this might be happening?

Thank you in advance- any pointers would be helpful!




--
Kaori Ito, MA, OTR/L, PhD Student
Chan Division of Occupational Science & Occupational Therapy
University of Southern California