1

I am new to python or more specifically ipython. I have been running through the steps to run what should be a very simple Dicom Conversion in a statistical package called SPM for an MRI image file as described by NiPype. I can't get it to run and was wondering what I was doing wrong. I am not getting an error message, instead, there is no file change or output. It just hangs. Does anyone have any idea what I might be doing wrong? It's likely that I am missing something very simple here (sorry :(

import os
from pylab import *
from glob import glob
from nipype.interfaces.matlab import MatlabCommand as mlab
mlab.set_default_paths('/home/orkney_01/s1252042/matlab/spm8')
from nipype.interfaces.spm.utils import DicomImport as di

os.chdir('/sdata/images/projects/ASD_MM/1/datafiles/restingstate_files')
filename = "reststate_directories.txt"
restingstate_files_list = [line.strip() for line in open(filename)]

for x in restingstate_files_list:
    os.chdir( x )
    y = glob('*.dcm')
    conversion = di(in_files = y))
    print(res.outputs)
Dan
  • 12,157
  • 12
  • 50
  • 84
  • Try adding some `print()` statements to your code so you can see how far it gets before hanging - this will help you narrow down where the problem is. – Thomas K May 28 '15 at 21:14
  • Is `/sdata/images/projects/ASD_MM/1/datafiles/restingstate_files` really the directory you want? i.e. is sdata the child of root? if sdata is in directory below the one in which your script is running, then remove leading '/' – Jacob Lee Jun 12 '17 at 15:37

1 Answers1

0

You are creating a DicomImport interface, but you are not actually running it. You should have res = di.run().

Also, you are best to tell the interface where to run using di.base_dir = '/some/path' before running.

Finally, you may also want to print the contents of restingstate_files_list to check you are finding the DICOM directories correctly.

Gilly
  • 1,739
  • 22
  • 30