# Compute Hausdorff distance hd_name = 'hd_' + sct.extract_fname(self.target_fname)[1] + '_' + self.seg_param.res_type + '.txt' sct.run('sct_compute_hausdorff_distance -i '+gm_seg+' -d '+ref_gmseg+' -thinning 1 -o '+hd_name+' -v '+str(self.seg_param.verbose)) sct.run('mv ./' + hd_name + ' ../') os.chdir('..') return dice_name, hd_name ######################################################################################################################## # ------------------------------------------------------ MAIN ------------------------------------------------------- # ######################################################################################################################## if __name__ == "__main__": model_param = ModelParam() seg_param = SegmentationParam() input_target_fname = None input_sc_seg_fname = None input_t2_data = None input_level_fname = None input_ref_gm_seg = None compute_ratio = False if seg_param.debug: print '\n*** WARNING: DEBUG MODE ON ***\n' fname_input = model_param.path_model + "/errsm_34.nii.gz" fname_input = model_param.path_model + "/errsm_34_seg_in.nii.gz" else: parser = get_parser() arguments = parser.parse(sys.argv[1:]) input_target_fname = arguments["-i"] input_sc_seg_fname = arguments["-s"]
sct.printv('Done!\n' 'You can warp the template to the target using the following command lines:\n' 'sct_concat_transfo -w '+multimodal_reg_param.warp_template2anat+','+warp_anat2target_corrected+' -d '+multimodal_reg_param.target+' -o warp_template2'+sct.extract_fname(multimodal_reg_param.target)[1]+'.nii.gz\n' 'sct_warp_template -d '+multimodal_reg_param.target+' -w warp_template2'+sct.extract_fname(multimodal_reg_param.target)[1]+'.nii.gz', verbose, 'info') os.chdir('..') if remove: sct.printv('\nRemove temporary files...', verbose, 'normal') sct.run("rm -rf "+path_tmp) if __name__ == "__main__": multimodal_reg_param = MultimodalRegistrationParam() wm_reg_param = WmRegistrationParam() gm_seg_param = SegmentationParam() remove = True verbose = 1 if wm_reg_param.debug: print '\n*** WARNING: DEBUG MODE ON ***\n' else: param_default = WmRegistrationParam() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Register the template on an image with a white/gray matter contrast according to the internal structure:\n' ' - register multimodal of the template to the target image\n' ' - automatic segmentation of the white and gray matter in the target image\n' ' - correction of the registration of the template to the target according to the WM/GM segmentation') # TODO: change description parser.usage.addSection('General parameters')
sct.run('cp warp_wm_gm2template2anat* ../'+sct.extract_fname(reg_param.wm_gm2template2anat_warp)[1]+'_wm.nii.gz') os.chdir('..') sct.printv('Done!\n You can apply the following commands to correct the registration of the template to :\n' 'sct_concat_transfo -w ../t2/warp_template2anat.nii.gz,'+sct.extract_fname(reg_param.wm_gm2template2anat_warp)[1]+'_wm.nii.gz -d '+target_fname+' -o warp_template2t2star_with_wm.nii.gz\n' ' sct_warp_template -d '+target_fname+' -w warp_template2t2star_with_wm.nii.gz', verbose, 'info') # remove temporary file if reg_param.remove_temp == 1: sct.printv('\nRemove temporary files...', verbose, 'normal') sct.run("rm -rf "+path_tmp) if __name__ == "__main__": reg_param = RegistrationParam() gm_seg_param = SegmentationParam() input_target_fname = '' input_sc_seg_fname = '' path_to_label = '' if reg_param.debug: print '\n*** WARNING: DEBUG MODE ON ***\n' else: param_default = RegistrationParam() # Initialize the parser parser = Parser(__file__) parser.usage.set_description('Register the template on a gray matter segmentation') # TODO: change description parser.usage.addSection('Segmentation parameters') parser.add_option(name="-i", type_value="file",
'Done!\n You can apply the following commands to correct the registration of the template to :\n' 'sct_concat_transfo -w ../t2/warp_template2anat.nii.gz,' + sct.extract_fname(reg_param.wm_gm2template2anat_warp)[1] + '_wm.nii.gz -d ' + target_fname + ' -o warp_template2t2star_with_wm.nii.gz\n' ' sct_warp_template -d ' + target_fname + ' -w warp_template2t2star_with_wm.nii.gz', verbose, 'info') # remove temporary file if reg_param.remove_temp == 1: sct.printv('\nRemove temporary files...', verbose, 'normal') sct.run("rm -rf " + path_tmp) if __name__ == "__main__": reg_param = RegistrationParam() gm_seg_param = SegmentationParam() input_target_fname = '' input_sc_seg_fname = '' path_to_label = '' if reg_param.debug: print '\n*** WARNING: DEBUG MODE ON ***\n' else: param_default = RegistrationParam() # Initialize the parser parser = Parser(__file__) parser.usage.set_description( 'Register the template on a gray matter segmentation' ) # TODO: change description parser.usage.addSection('Segmentation parameters')