@@ -868,12 +868,23 @@ def _do_subject_normalize(subject_data, fwhm=0., anat_fwhm=0., caching=True,
868868 # sanitize subject_data (do things like .nii.gz -> .nii conversion, etc.)
869869 subject_data .sanitize (niigz2nii = (software == "spm" ))
870870
871+ # XXX get spm version
872+ spm_version = _get_version_spm (SPM_DIR )
873+
871874 # prepare for smart caching
872875 if caching :
873876 cache_dir = os .path .join (subject_data .scratch , 'cache_dir' )
874877 if not os .path .exists (cache_dir ): os .makedirs (cache_dir )
875- normalize = NipypeMemory (base_dir = cache_dir ).cache (spm .Normalize )
876- else : normalize = spm .Normalize ().run
878+ if spm_version == 'spm8' :
879+ normalize = NipypeMemory (base_dir = cache_dir ).cache (spm .Normalize )
880+ elif spm_version == 'spm12' :
881+ normalize = NipypeMemory (base_dir = cache_dir ).cache (spm .Normalize12 )
882+ else :
883+ # XXX normalize or normalize12
884+ if spm_version == 'spm8' :
885+ normalize = spm .Normalize ().run
886+ elif spm_version == 'spm12' :
887+ normalize = spm .Normalize12 ().run
877888
878889 segmented = 'segment' in subject_data .nipype_results
879890
@@ -889,6 +900,8 @@ def _do_subject_normalize(subject_data, fwhm=0., anat_fwhm=0., caching=True,
889900 else :
890901 parameter_file = subject_data .nipype_results [
891902 'segment' ].outputs .transformation_mat
903+ deformation_file = subject_data .nipype_results [
904+ 'segment' ].outputs .forward_deformation_field
892905
893906 subject_data .parameter_file = parameter_file
894907
@@ -908,14 +921,23 @@ def _do_subject_normalize(subject_data, fwhm=0., anat_fwhm=0., caching=True,
908921 write_voxel_sizes = get_vox_dims (apply_to_files )
909922 else : write_voxel_sizes = anat_write_voxel_sizes
910923 apply_to_files = subject_data .anat
911-
912- # run node
924+ # XXX replace by normalize12
925+ print ('[DEFORMATION FILE]' , deformation_file )
926+ print ('[APPLY TO FILE]' , apply_to_files )
913927 normalize_result = normalize (
914- parameter_file = parameter_file ,
928+ deformation_file = deformation_file ,
915929 apply_to_files = apply_to_files ,
916930 write_voxel_sizes = list (write_voxel_sizes ),
917- # write_bounding_box=[[-78, -112, -50], [78, 76, 85]],
918- write_interp = 1 , jobtype = 'write' , ignore_exception = True )
931+ write_interp = 1 , jobtype = 'write' , ignore_exception = False )
932+ print ('[RESULTS]' , normalize_result .outputs )
933+
934+ # run node
935+ # normalize_result = normalize(
936+ # parameter_file=parameter_file,
937+ # apply_to_files=apply_to_files,
938+ # write_voxel_sizes=list(write_voxel_sizes),
939+ # # write_bounding_box=[[-78, -112, -50], [78, 76, 85]],
940+ # write_interp=1, jobtype='write', ignore_exception=False)
919941
920942 # failed node ?
921943 if normalize_result .outputs is None :
0 commit comments