Description
Hello:
Recently, I tried datagrabber to grab some files from my dataset, but I found a problem which datagrabber does not work so well, here is the case:
here is the debug code:
import nipype.interfaces.io as nio
input_dir = '/Volumes/dataARAMIS/users/junhao.wen/dataset/PREVDEMALS/GENFI'
datagrabbernode = nio.DataGrabber(
infields=['subject_list', 'session_list', 'subject_repeat', 'session_repeat'],
outfields=['anat_t1'])
datagrabbernode.inputs.base_directory = input_dir
datagrabbernode.inputs.template = '*'
datagrabbernode.inputs.field_template = dict(anat_t1='%s/%s/anat/%s_%s_T1w.nii.gz') # This is just to adapt to the output anat_t1
# just for test with my home nii files
# datagrabbernode.inputs.field_template = dict(anat_t1='sub-%s/ses-%s/anat/sub-%s_ses-%s_T1w.nii')
datagrabbernode.inputs.template_args = dict(anat_t1=[['subject_list', 'session_list', 'subject_repeat',
'session_repeat']])
datagrabbernode.inputs.sort_filelist = False
datagrabbernode.inputs.subject_list = ['sub-PREVDEMALS0010001BE', 'sub-PREVDEMALS0010002VH']
datagrabbernode.inputs.session_list = ['ses-M0', 'ses-M0']
datagrabbernode.inputs.subject_repeat = ['sub-PREVDEMALS0010001BE', 'sub-PREVDEMALS0010002VH']
datagrabbernode.inputs.session_repeat = ['ses-M0', 'ses-M0']
datagrabbernode.inputs.raise_on_empty = False
datagrabbernode.run()
For example, I have a dataset which has two subjects, and one of them has the the nifti image .nii, and another one does not have the image, so what i want is to not let my workflow die in the datagrabber even one of the image is missing, so I put the flag 'raise_on_empty', so what I expected to give me back the output like:
{'anat_t1': [None, '/Volumes/dataARAMIS/users/junhao.wen/dataset/PREVDEMALS/GENFI/sub-PREVDEMALS0010002VH/ses-M0/anat/sub-PREVDEMALS0010002VH_ses-M0_T1w.nii.gz']}
But in your source code, if one of the image is missing, you will give back None, which i think does not make sense.
Here is the bug code(in nipype io.py line1183-1184):
if any([val is None for val in outputs[key]]):
outputs[key] = []
and also, we can add another func of Node to print all the existing images, the missing images will be reported by the warn, like this:
import nipype.interfaces.utility as nutil
def print_filenames(files_list):
print files_list
return None
print_node=pe.Node(name='PrintNode',
interface=nutil.Function(
input_names=['files_list'],
output_names=['empty_output'],
function=print_filenames))
I think we should just comment this, to make it more flexible to use, because in the workflow, we don't wanna it died in datagrabber, maybe it will die in the next Node if we dont deal with the None inside the output field.
Look forward to your reply:)
Good night
Hao
Platform details:
please paste the output of: python -c "import nipype; print(nipype.get_info())"
{'nibabel_version': '2.1.0', 'networkx_version': '1.11', 'numpy_version': '1.11.1', 'sys_platform': 'darwin', 'sys_version': '2.7.12 |Anaconda custom (x86_64)| (default, Jul 2 2016, 17:43:17) \n[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)]', 'commit_source': 'installation', 'commit_hash': u'a4d1e07', 'pkg_path': '/Users/junhao.wen/anaconda2/lib/python2.7/site-packages/nipype', 'sys_executable': '/Users/junhao.wen/anaconda2/bin/python', 'traits_version': '4.6.0', 'scipy_version': '0.18.1'}