I have a function that returns afni files in the BRIK/HEAD format and I am having difficulties using AFNItoNIFTI
function within a mapnode.
For example let’s say I have these afni files:
files = [file_A_+orig.BRIK, file_A_+orig.HEAD, file_B_+orig.BRIK, file_B_+orig.HEAD, file_C_+orig.BRIK, file_C_+orig.HEAD]
templates = {'afni_files': os.path.join(dir_afni, '*')}
select_files = Node(SelectFiles(templates), name='select_files')
convert = MapNode(AFNItoNIFTI(outputtype="NIFTI"), iterfield=['in_file'], name="convert")
wf.connect([(select_files, convert, [('afni_files', 'in_file')])])
wf.run()
Running this code returns the error:
TypeError: _overload_extension() takes exactly 2 arguments (3 given)
A workaround would be defining an out_file
:
convert = MapNode(AFNItoNIFTI(outputtype="NIFTI",out_file='outfile.nii'), iterfield=['in_file'], name="convert")
this works, but then all NIFTI files in my mapflow folder will have the same name and I cannot determine if it’s A, B, C, etc.
mapflow/
_convert0/
outfile.nii
_convert1/
outfile.nii
_convert2/
outfile.nii
etc
Could someone please help me with this, as I have no clue what to do here? Is there a way to tell the mapnode to use the filename from the original BRIK/HEAD files?