Dcm2nii, ipython, nipype


I have successfully converted dicom files to niftii files using dcm2nii in ipython.
However, I want to also change the name of the output, for example to “t1.nii”.
Not it has a complicated name. So according to Chris Rorden that answered my query at the NITRC forum, he recommended me to use dcm2niix instead of dcm2nii. dcm2nii allows one to specify out_filename, with flag -f, e.g. ‘-f t1’. I would like to know how to do this. Maybe you can answer this. But the most acute problem is, however, that I cannot import dcm2niix.
from nipype.interfaces.dcm2nii import dcm2niix. It says, cannot import name dcm2niix.
Obviously, dcm2nii has worked. I have installed dcm2niix from neurodebian and all seems updated. What am I doing wrong.

Hi @Granit_Kastrati, can you make sure your import statement looks like
from nipype.interfaces.dcm2nii import Dcm2niix

If it cannot find it, I’d suggest updating your nipype - I believe it was added back in version 0.12

thanx, I had written it like you suggested. I wrote it incorrectly in my question here. I will try to update nipype. I thought I did so in the terminal in unix using sudo apt-get update. Is that correct?

@Granit_Kastrati I believe you’d have to install it through python - either with conda or pip. You can get the latest version with the command:

pip install --upgrade https://github.com/nipy/nipype/archive/master.zip

Thank you! I did this. It installed. I tried to from nipype.interfaces.dcm2nii import Dcm2niix from ipython but got the error message cannot import name Dcm2niix.

From the installation/update of Nipype from the terminal, the only error message seems to be:

ImportError: No module named six.moves.

can you run the following commands?

  • pip install six
  • pip uninstall nipype
  • pip install https://github.com/nipy/nipype/archive/master.zip
  • python -c "import nipype; print(nipype.__version__)"

Ok it worked! Awsome. So fast you are to respond!

I can ask you, I am using Dcm2niix like this:

converter = Dcm2niix()

How can I use out_filename. Its ‘-f’, and then I want the name ‘t1’.
using it like this does not work: converter.inputs.out_filename(’-f t1’).

Nipype essentially wraps the -f part when you define out_filename, so you just have to set it to converter.inputs.out_filename = 't1'