Skip to content

PETPVC wrapper #1332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexsavio opened this issue Jan 27, 2016 · 11 comments
Closed

PETPVC wrapper #1332

alexsavio opened this issue Jan 27, 2016 · 11 comments

Comments

@alexsavio
Copy link
Contributor

Hi,

I have a wrapper for PETPVC, a new tool (very needed) for partial volume correction of PET images.

The wrapper code is here.

Do you think this would be a good addition? What else should I do to get this merged?

Thanks.
Cheers,
Alex

@chrisgorgo
Copy link
Member

It would be a great addition! We would love to have more support for PET related software. Please send a PR.

@alexsavio
Copy link
Contributor Author

First solution given on #1335

@ubersexualShupeng
Copy link

Hi, it is really a nice work to implement this tool in nipype. Obviously, it is much easier for researchers to use than c++ version. I do appreciate it.
I have some issues when using this nipype.interfaces.petpvc.
My code in anaconda4.3.0 python (2.7, 64-bit) as following:
import nipype
import nipype.interfaces.petpvc as PETPVC
pvc = PETPVC.PETPVC()
pvc.inputs.in_file = 'C:\Users\135173\Desktop\pvc_test\PET_nii\x_WB_CTAC_Body.nii.gz'
pvc.inputs.mask_file = 'C:\Users\135173\Desktop\pvc_test\mask_nill\skin_mask.nii.gz'
pvc.inputs.out_file = 'C:\Users\135173\Desktop\pvc_test\pet_pvc_rbv.nii.gz'
pvc.inputs.pvc = 'RBV'
pvc.inputs.fwhm_x = 2
pvc.inputs.fwhm_y = 2
pvc.inputs.fwhm_z = 2
outs = pvc.run()

Errors Message:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1081, in run
runtime = self._run_wrapper(runtime)
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1724, in _run_wrapper
runtime = self._run_interface(runtime)
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1750, in _run_interface
(self.cmd.split()[0], runtime.hostname))
IOError: command 'petpvc' could not be found on host W324831
Interface PETPVC failed to run.

My question is do I need to install the PETPVE (c++ source code) under a specific directory?
If so where should I put it?
I cannot find any document of using this module.
Look forward to your reply. Thank you so much.

@alexsavio
Copy link
Contributor Author

Hi @ubersexualShupeng, you can find the documentation in http://nipype.readthedocs.io/en/latest/documentation.html.
Also, like any other module, the binary command (petpvc) should be in your PATH.

I hope this helps.

Cheers,
Alex

@effigies
Copy link
Member

effigies commented Jun 6, 2017

You'll need to install it somewhere so that running petpvc from the command line successfully starts the program. The source code alone will not do what you want.

It appears there are Windows binaries available. I'm not sure whether this is an installer or a simple executable to be placed in your path. Their README also points to some requirements for Windows users. (The current link is bad; try: https://support.microsoft.com/en-us/help/3179560/update-for-visual-c-2013-and-visual-c-redistributable-package)

Hope this helps.

@ubersexualShupeng
Copy link

Hi @effigies , I install the binaries you provided and that is a bunch of .exe files.
I also add two line code:

import sys
sys.path.append('C:\Program Files (x86)\PETPVC')

The path is where the binaries (.exe) file placed.
But the errors still appeared.
Is that what you mean to put the 'binary command in the PATH''? @alexsavio
Look forward to your reply.
I really appreciate all your help.

@alexsavio
Copy link
Contributor Author

Hi @ubersexualShupeng,

No, sorry, I mean your OS PATH, on Windows you may have to add the folder path where the petpvc binary is to your system path:
https://stackoverflow.com/questions/23400030/windows-7-add-path

@effigies
Copy link
Member

effigies commented Jun 6, 2017

It's better not to manipulate the PATH inside Python, but instead make sure that your programs are in the PATH. That way, your code doesn't depend on the exact setup of your system. You can test whether a program is in your PATH by opening a terminal and typing the program name (in this case, petpvc). If that works, then nipype should be able to work with it.

But if you're going to modify your PATH in Python, you probably need to make that a raw string (r'C:\Program Files (x86)\PETPVC') or escape the backslashes ('C:\\Program Files (x86)\\PETPVC').

@ubersexualShupeng
Copy link

Hi @alexsavio @effigies I do appreciate your help. I added the binaries in the system PATH.
It looks like the nipype can access the binaries but it have new errors.

The error message as following:
Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1081, in run
runtime = self._run_wrapper(runtime)
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1724, in _run_wrapper
runtime = self._run_interface(runtime)
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1755, in _run_interface
redirect_x=self._redirect_x)
File "C:\Program Files\Anaconda2\lib\site-packages\nipype\interfaces\base.py", line 1457, in run_command
env=runtime.environ)
File "C:\Program Files\Anaconda2\lib\subprocess.py", line 390, in init
errread, errwrite)
File "C:\Program Files\Anaconda2\lib\subprocess.py", line 640, in _execute_child
startupinfo)
TypeError: environment can only contain strings
Interface PETPVC failed to run.

How can I fix this problem?

@effigies
Copy link
Member

effigies commented Jun 6, 2017

Can you try running it in a Node?

from nipype.pipeline import engine as pe
from nipype.interfaces.petpvc import PETPVC
pvc = pe.Node(PETPVC(), name='pvc', base_dir=r'C:\tmp')
pvc.inputs.in_file = 'C:\Users\135173\Desktop\pvc_test\PET_nii\x_WB_CTAC_Body.nii.gz'
pvc.inputs.mask_file = 'C:\Users\135173\Desktop\pvc_test\mask_nill\skin_mask.nii.gz'
pvc.inputs.out_file = 'C:\Users\135173\Desktop\pvc_test\pet_pvc_rbv.nii.gz'
pvc.inputs.pvc = 'RBV'
pvc.inputs.fwhm_x = 2
pvc.inputs.fwhm_y = 2
pvc.inputs.fwhm_z = 2
output = pvc.run()

This should create a file: C:\tmp\pvc\_report\report.rst

Paste the contents of that file to a gist. And could you open a new issue? We're 8 posts into a closed issue, now.

@ubersexualShupeng
Copy link

I just created a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants