Dwifslpreproc: [ERROR] UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\ufffd’ in position 375: ordinal not in range(128)

hi there i’ve encountered the above error when running the command below on a particular subject— i did not have this issue with other subjects. I’ve checked that the input files are fine.

dwifslpreproc DWI_degibbed.mif DWI_eddycorr.mif -rpe_pair -se_epi fmap.mif -eddy_mask mask.nii -pe_dir ap -readout_time 0.12705 -align_seepi -eddy_options " --data_is_shelled " -scratch dwifslpreproc -nocleanup

here’s the full log

dwifslpreproc: 
dwifslpreproc: Note that this script makes use of commands / algorithms that have relevant articles for citation; INCLUDING FROM EXTERNAL SOFTWARE PACKAGES. Please consult the help page (-help option) for more information.
dwifslpreproc: 
dwifslpreproc: Generated scratch directory: /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc
Command:  mrconvert /scratch/junhong.yu/LFC/DWI/168/DWI_degibbed.mif /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc/dwi.mif -json_export /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc/dwi.json
Command:  mrconvert /scratch/junhong.yu/LFC/DWI/168/fmap.mif /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc/se_epi.mif
Command:  mrconvert /scratch/junhong.yu/LFC/DWI/168/mask.nii /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc/eddy_mask.mif -datatype bit
dwifslpreproc: Changing to scratch directory (/scratch/junhong.yu/LFC/DWI/168/dwifslpreproc)
Command:  dirstat dwi.mif -output asym
dwifslpreproc: [WARNING] sampling of b=500 shell is moderately asymmetric; distortion correction may benefit from use of: -eddy_options " ... --slm=linear ... "
Command:  mrconvert dwi.mif dwi_first_bzero.mif -coord 3 0 -axes 0,1,2
dwifslpreproc: Balanced phase-encoding scheme detected in SE-EPI series; volume 0 will be removed and replaced with first b=0 from DWIs
Command:  mrconvert se_epi.mif - -coord 3 1 | mrcat dwi_first_bzero.mif - se_epi_firstdwibzero.mif -axis 3
Command:  mrinfo dwi.mif -export_grad_mrtrix grad.b
dwifslpreproc: 1 spatial axis of DWIs has non-even size; this will be automatically padded for compatibility with topup, and the extra slice erased afterwards
Command:  mrconvert se_epi_firstdwibzero.mif -coord 2 80 - | mrcat se_epi_firstdwibzero.mif - se_epi_firstdwibzero_pad2.mif -axis 2
Command:  mrconvert dwi.mif -coord 2 80 -clear dw_scheme - | mrcat dwi.mif - dwi_pad2.mif -axis 2
Command:  mrconvert se_epi_firstdwibzero_pad2.mif topup_in.nii -import_pe_table se_epi_manual_pe_scheme.txt -strides -1,+2,+3,+4 -export_pe_table topup_datain.txt
Command:  topup --imain=topup_in.nii --datain=topup_datain.txt --out=field --fout=field_map.nii.gz --config=/usr/local/fsl-6.0.5/etc/flirtsch/b02b0.cnf --verbose
Command:  mrconvert dwi_pad2.mif -import_pe_table dwi_manual_pe_scheme.txt - | mrinfo - -export_pe_eddy applytopup_config.txt applytopup_indices.txt
Command:  mrconvert dwi_pad2.mif dwi_pad2_pe_0.nii -coord 3 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126 -strides -1,+2,+3,+4 -json_export dwi_pad2_pe_0.json
Command:  applytopup --imain=dwi_pad2_pe_0.nii --datain=applytopup_config.txt --inindex=1 --topup=field --out=dwi_pad2_pe_0_applytopup.nii --method=jac
Command:  mrconvert dwi_pad2_pe_0_applytopup.nii.gz dwi_pad2_pe_0_applytopup.mif -json_import dwi_pad2_pe_0.json
dwifslpreproc: [WARNING] User-provided processing mask for eddy does not match DWI voxel grid; resampling
Command:  mrtransform eddy_mask.mif - -template dwi_pad2.mif -interp linear | mrthreshold - -abs 0.5 - | mrconvert - eddy_mask.nii -datatype float32 -stride -1,+2,+3
Command:  mrconvert dwi_pad2.mif -import_pe_table dwi_manual_pe_scheme.txt eddy_in.nii -grad grad.b -strides -1,+2,+3,+4 -export_grad_fsl bvecs bvals -export_pe_eddy eddy_config.txt eddy_indices.txt
Command:  eddy_cuda --imain=eddy_in.nii --mask=eddy_mask.nii --acqp=eddy_config.txt --index=eddy_indices.txt --bvecs=bvecs --bvals=bvals --topup=field --data_is_shelled --out=dwi_post_eddy --verbose

dwifslpreproc: [ERROR] Unhandled Python exception:
dwifslpreproc: [ERROR]   UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 375: ordinal not in range(128)
dwifslpreproc: [ERROR] Traceback:
dwifslpreproc: [ERROR]   /home/junhong.yu/.conda/envs/mrtrix3env/bin/dwifslpreproc:936 (in execute())
dwifslpreproc: [ERROR]     eddy_output_file.write(str(exception_cuda).encode('utf-8', errors='replace'))
dwifslpreproc: Scratch directory retained; location: /scratch/junhong.yu/LFC/DWI/168/dwifslpreproc

Hi,
I had a similar error code when my name - including the letter ‘ö’ - was present in the comments section of the header. You could check if there are any “exotic” letters or symbols for this participant present in the header.
Best,
Örjan

i dont see any strange characters in the comments however the voxel size listed as ‘1 x 1 x 2 x ?’ in the header. Perhaps the question mark is causing the problem. How did you edit your header?

You can use mrconvert with the -set_property flag to change the header. It’s a bit strange that the number of images in the series (the 4th dimension) can’t be listed though…

well i actually had to use the -vox flag to edit the voxel dimensions. But yea, that really fixed the issue, dwifslpreproc completed on this subject without any issues