I found the solution of this problem : the function spm_reslice adds some NaN values when normalizing an image. When you reuse the function spm_affreg afterwards with these resliced images, the function spm_sample_vol doesn't like the NaN values, for a reason that I cannot explain because this function is private. Nevertheless, an "easy" solution is to write a line after each spm_sample_vol calls that changes the NaN of the output of the function into 0. Example :
line 135 of spm_affreg : [F,dF1,dF2,dF3]=spm_sample_vol(VF(1),y1,y2,y3,1);
After modif :
Hope it will help some of you.