SPM Dicom Convert in python (Ipython/ Nipype)

339 views Asked by At

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)
1

There are 1 answers

0
Gilly On

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.