if inArgs.verbose: print print "Image LPS World to CTF matrix" print affine_ctf print util.save_itk_affine_matrix( affine_ctf, affine_out_wlps_to_wctf, inArgs.verbose ) # # Save OUT Fiducials in LPS World space. # util.verify_outputs( stage1_output_files[0:3] ) cmd = [ "antsApplyTransformsToPoints", "-d", "3", "-i", fiducials_out_iras, "-o", fiducials_out_wlps, "-t", inArgs.iras_to_wras, inArgs.wras_to_wlps ] util.iw_subprocess(cmd, inArgs.verbose, inArgs.verbose) # # Save OUT Fiducials in CTF World space. # util.verify_that_file_exists(fiducials_out_wlps) cmd = [ "antsApplyTransformsToPoints", "-d", "3", "-i", fiducials_out_iras, "-o", fiducials_out_wctf, "-t", inArgs.iras_to_wras, inArgs.wras_to_wlps, inArgs.wlps_to_wctf ] util.iw_subprocess(cmd, inArgs.verbose, inArgs.verbose) util.verify_outputs( stage1_output_files )
rpa_wras = np.dot(img_affine_matrix_ras, np.concatenate( (rpa_iras, [1]) )) lpa_wlps = np.dot(affine_wras_to_wlps, lpa_wras ) nas_wlps = np.dot(affine_wras_to_wlps, nas_wras ) rpa_wlps = np.dot(affine_wras_to_wlps, rpa_wras ) [ rotate_ctf, translate_ctf, origin_ctf ] = ctf_calc_rotate_translate_origin( nas_wlps, lpa_wlps, rpa_wlps, ctf_scale) affine_ctf = ctf_calc_affine( rotate_ctf, translate_ctf, 0*origin_ctf) if inArgs.verbose: print print "Image LPS World to CTF matrix" print affine_ctf print iwUtilities.save_itk_affine_matrix( affine_ctf, inArgs.wlps_to_wctf ) # # Save MEG Fiducials in LPS World space. # iwUtilities.verify_that_file_exists(inArgs.meg_iras) iwUtilities.verify_that_file_exists(inArgs.iras_to_wras) iwUtilities.verify_that_file_exists(inArgs.wras_to_wlps) cmd = [ "antsApplyTransformsToPoints", "-d", "3", "-i", inArgs.meg_iras, "-o", inArgs.meg_wlps, "-t", inArgs.iras_to_wras, inArgs.wras_to_wlps ] iwUtilities.iw_subprocess(cmd, inArgs.verbose, True )
print "inArgs.out_points = " + str(inArgs.out_points) print "inArgs.ants_affine = " + str(inArgs.ants_affine) print "inArgs.ants_warp = " + str(inArgs.ants_warp) print "inArgs.wlps_to_wctf = " + str(inArgs.wlps_to_wctf) print "inArgs.verbose = " + str(inArgs.verbose) # # Check inputs # input_files = [inArgs.in_ctf, inArgs.ants_affine, inArgs.ants_warp, inArgs.wlps_to_wctf]; for ii in input_files: iwUtilities.verify_that_file_exists(ii) # # Transform CTF points to Native Space # cmd = [ "antsApplyTransformsToPoints", "-d", "3", "-i", inArgs.in_ctf, "-o", inArgs.out_native, "-t", "[", inArgs.wlps_to_wctf,",", "1", "]" ] iwUtilities.iw_subprocess(cmd, inArgs.verbose) clean_nan(inArgs.out_native) # # Transform CTF point to Template Space # cmd = [ "antsApplyTransformsToPoints", "-d", "3", "-i", inArgs.in_ctf, "-o", inArgs.out_template, "-t", "[", inArgs.wlps_to_wctf,",", "1", "]", inArgs.ants_affine, inArgs.ants_warp ]