Hi Ben,
 a few hints to get you going

- there's a mix of tabs and spaces in your python file, I suggest you either 
stick with tabs or spaces, otherwise errors could creep in

- there's no need of adding SurfaceInputFileName and SurfaceOutputFileName: 
whenever you add the name of a script after the documentation
like the 'vmtksurfacereader' in the next line
            ['Surface','i','vtkPolyData',1,'','the input 
surface','vmtksurfacereader'],
pypes automatically adds an -ifile option and uses vmtksurfacereader as a 
default reader. Same thing for the writer.
For the same reason, you can safely delete the last portion of your code: 
self.WriteSurface = vmtkscripts.vmtkSurfaceWriter ...
since the output file will automatically be written as soon as you use -ofile 
at the command line.

- whenever you instantiate a script, like

self.BranchClipper = vmtkscripts.vmtkBranchClipper

you have to add '()' at the end, otherwise you're not actually creating an 
instance of the object (look it up on your Python reference, book or 
tutorials), this way

self.BranchClipper = vmtkscripts.vmtkBranchClipper()

- I'm not sure what you wanted to achieve with

        for i in self.ExtractedBranches.GroupIdsArrayName:
            if branchString == self.ExtractedBranches.GroupIdsArrayName:
                branchString = None
        return branchString

 but this is probably not the right way 
(self.ExtractedBranches.GroupIdsArrayName is not a collection, it's a string, 
so iterating over a string will only get you one letter of the string at a time)

- I see you are using 'self' inside a method call for a method that has self as 
the only parameter (def BranchInput(self):)

while self.BranchNumber == None:
            self.BranchNumber = self.BranchInput(self)
            if self.BranchNumber == None:
                     ...

This is not syntactically correct, it should have been
self.BranchInput()

to make the long story short, when you write object methods in Python, the 
first argument to the method (self, but you can actually call it whatever you 
want) represents the object instance on which you're calling that method and 
does not have to be specified in the call, e.g.

class Foo(object):
        def add(self, a, b):
                return a + b

foo = Foo()
foo.add(1,2)
-> 3

You'll find it in your Python refs.

Hope this helps


Luca



On Jan 20, 2012, at 11:34 PM, Berkowitz, Benjamin M wrote:

> Hi, I've been trying to make a python script that takes in models of vessels 
> with cerebral aneurysms and will eventually give the user an isolated 
> aneurysm.  Basically, the script is pretty simple and does almost the same 
> thing as typing these commands into pypepad, but asks the user for the number 
> of the centerline tract to construct around instead of vmtkcenterlinelabeler:
> 
> vmtksurfacereader -ifile surface1.vtp --pipe vmtkcenterlines --pipe 
> vmtkbranchextractor --pipe vmtkcenterlinelabeler --pipe vmtkbranchclipper 
> -groupids 2 -ofile surface.vtp --pipe vmtkrenderer --pipe vmtksurfaceviewer 
> --pipe vmtksurfaceviewer -ifile  
> /var/tmp/bberkowi/BIOMOST/Coil_Compaction_Growth_Project/Ben_B_auto_aneurysm_cutting/Recur_pt2_pre1L.vtp
>  -opacity 0.5
> 
> It doesn't work, though.  I've just started to learn how to program with 
> Python and PypeS, so I was hoping someone could take a quick look at it and 
> tell me if I'm on the right track and if you see any glaring errors. I've 
> attached the file.
> 
> Thanks,
> Ben Berkowitz
> <isolateaneurysm.py>------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2_______________________________________________
> vmtk-users mailing list
> vmtk-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/vmtk-users

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
vmtk-users mailing list
vmtk-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vmtk-users

Reply via email to