0

I have a little issue concerning the representation of a string in Python.

I have the following Python code:

#!/usr/bin/env python
import sys
import math
import string
from vmtk import pypes
from vmtk import vmtkscripts

seedPointCoordinates = "399 268 364"
targetPointCoordinates = [" 367 264 361 " , "344 287 336 " , " 336 289 330 " , " 315 287 330 " , " 294 278 325 " , " 269 254 321 "  ]

for x in range (0,6,1):
myInitializationArguments = "vmtkimageinitialization -ifile     <PATH>"\XA_001.dcm -interactive 0 -method fastmarching -upperthreshold 11000  -lowerthreshold 2000 -sourcepoints "+seedPointsOne+" -targetpoints "+targetPointsOne[x]+" -olevelsetsfile <PATH>\initialLevelSets"+str(x+1)+".vti"
myPype = pypes.PypeRun(myinitializationArguments)
myArgumentsForMarchingCubes = "vmtkmarchingcubes –ifile <PATH>\initialLevelSets"+str(x+1)+".vti   -ofile <PATH>\initialLevelSets"+str(x+1)+"mc.vtp"
myPype = pypes.PypeRun(myArgumentsForMarchingCubes)

which I include with the following LaTeX command:

\lstinputlisting[language=Python, label={lst:label32}, showstringspaces=false, extendedchars=true,keepspaces=true, tabsize=4, morekeywords={models, lambda, forms}, commentstyle={\rmfamily\catcode`\$=11}, columns=flexible,texcl,showspaces=false, captionpos=b,caption=Example of using the segmentation script with the help of the PypePad command and a Pypes object.]{./PythonCodePart.py}

My problem is that the - signs don't appear after compiling. And there is also an issue with the construct <PATH>...

Can someone please help me out?

  • Welcome to TeX.SX! Please make your code compilable and self-contained (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. – Thruston Jun 20 '16 at 8:21
  • As far as I can see, there is just one hyphen that disappears, that is, the first one in line 14; the problem is that you typed U+2013 (EN-DASH) instead of a hyphen. – egreg Jun 20 '16 at 8:28
  • @egreg, yes that was another problem, but still.. the - (minus sign) doesn't appear, compiled it twices, no command renewed etc... Thanks however for pointing the dash thing out! – user3640476 Jun 20 '16 at 10:00
  • have you tried the minted-package? – naphaneal Jun 20 '16 at 18:32
1

EDIT: there's an indentation error in the for-loop, but I'm too lazy to upload a new image.

A quik'n'derty example of minted as an alternative to the lstlisting-package. Taking the above code

\documentclass[10pt,a4paper]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage{minted}

\begin{document}
\begin{minted}{Python}
#!/usr/bin/env python
import sys
import math
import string
from vmtk import pypes
from vmtk import vmtkscripts

seedPointCoordinates = "399 268 364"
targetPointCoordinates = [" 367 264 361 " , "344 287 336 ",
 " 336 289 330 " , " 315 287 330 " , " 294 278 325 " , " 269 254 321 "]

for x in range (0,6,1):
    myInitializationArguments = "vmtkimageinitialization -ifile <PATH>"
    \XA_001.dcm -interactive 0 -method fastmarching
    -upperthreshold 11000  -lowerthreshold 2000 -sourcepoints " 
    +seedPointsOne+ 
    " -targetpoints "
    +targetPointsOne[x]+
    " -olevelsetsfile <PATH>\initialLevelSets"+str(x+1)+".vti"

    myPype = pypes.PypeRun(myinitializationArguments)

    myArgumentsForMarchingCubes = "vmtkmarchingcubes –ifile <PATH>\initialLevelSets" 
    +str(x+1)+ ".vti   -ofile <PATH>\initialLevelSets"
    +str(x+1)+ "mc.vtp"
    myPype = pypes.PypeRun(myArgumentsForMarchingCubes)
\end{minted}
\end{document}

with some clean up results in

enter image description here

  • thank you! even if quick'n'derty, it is still a solution! – user3640476 Jun 21 '16 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.