PyAnatomist instantiation with bang line script

Questions about Anatomist manipulation

Moderators: denghien, riviere

Post Reply
ericbarnhill
Posts: 16
Joined: Mon Oct 17, 2011 1:09 pm

PyAnatomist instantiation with bang line script

Post by ericbarnhill »

Greetings,

I want to create a PyAnatomist script that will save a series of .mesh as a .ply . (Actually I would prefer a .vtk but that is a second question.) All the steps work fine in the IPython interactive environment. However when I put them in a small script with bang line the instantiation of Anatomist gives an error. Here are the steps:

Code: Select all

#!$BRAINVISAPATH/bin/ipython -q4thread

import os
import anatomist.api as ana

a=ana.Anatomist()
#other code for example
RInflated=a.loadObject('$PATH1/brainvisa-database-local/chimpstudy-humans/abd/t1mri/default_acquisition/default_analysis/segmentation/mesh/abd_Rwhite_inflated.mesh')
RInflated.save(filename='/$PATH2/inflated-meshes/abd/Rwhite_inflated.ply')
#etc.
All of this works perfectly in the IPython interactive but when I run it as a script I get

Code: Select all

arg: anatomist
Starting Anatomist.....
config file : /home/ericbarnhill/.anatomist/config/settings.cfg
PyAnatomist Module present
Segmentation fault
As I said it is fine in the interactive.

Any suggestions?
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Re: PyAnatomist instantiation with bang line script

Post by riviere »

Hi Eric,
I guess it is just a matter of instantiating the Qt application before running anatomist:

Code: Select all

import anatomist.api as ana
from PyQt4 import QtGui
import sys

qapp = QtGui.QApplication( sys.argv )
a=ana.Anatomist()
# ...
It could baybe be automatically done in the anatomist application instantiation, but I had trouble finding a reliable way to detect whether the Qt app has already been instantiated or not - but I don't remember exactly, this was perhaps by the time we still supported Qt3 compatibility, I have to check that one day...

Denis
Post Reply