<s> import sys <EOL> import commands <EOL> import getopt <EOL> import os <EOL> import time <EOL> import numpy as np <EOL> import nibabel as nib <EOL> import sct_utils as sct <EOL> def main ( ) : <EOL> size_data = <NUM_LIT> <EOL> size_label = <NUM_LIT:1> <EOL> dice_acceptable = <NUM_LIT> <EOL> test_passed = <NUM_LIT:0> <EOL> remove_temp_files = <NUM_LIT:0> <EOL> verbose = <NUM_LIT:1> <EOL> try : <EOL> opts , args = getopt . getopt ( sys . argv [ <NUM_LIT:1> : ] , '<STR_LIT>' ) <EOL> except getopt . GetoptError : <EOL> usage ( ) <EOL> for opt , arg in opts : <EOL> if opt == '<STR_LIT>' : <EOL> usage ( ) <EOL> elif opt in ( '<STR_LIT>' ) : <EOL> verbose = int ( arg ) <EOL> path_tmp = '<STR_LIT>' + time . strftime ( "<STR_LIT>" ) <EOL> sct . run ( '<STR_LIT>' + path_tmp , verbose ) <EOL> os . chdir ( path_tmp ) <EOL> data_src = np . zeros ( ( size_data , size_data , size_data ) , dtype = np . int16 ) <EOL> data_dest = np . zeros ( ( size_data , size_data , size_data ) , dtype = np . int16 ) <EOL> data_src [ <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> , <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> , <NUM_LIT:10> - size_label : <NUM_LIT:10> + size_label + <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> data_src [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> ] = <NUM_LIT:2> <EOL> data_src [ <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> , <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> , <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> ] = <NUM_LIT:3> <EOL> data_src [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> ] = <NUM_LIT:4> <EOL> data_src [ <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> , <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> , <NUM_LIT:50> - size_label : <NUM_LIT:50> + size_label + <NUM_LIT:1> ] = <NUM_LIT:5> <EOL> points_moving = [ [ <NUM_LIT:20> , <NUM_LIT:20> , <NUM_LIT:10> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ] , <EOL> [ <NUM_LIT:30> , <NUM_LIT:30> , <NUM_LIT:30> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT:20> , <NUM_LIT:20> , <NUM_LIT:50> ] ] <EOL> data_dest [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT:10> - size_label : <NUM_LIT:10> + size_label + <NUM_LIT:1> ] = <NUM_LIT:1> <EOL> data_dest [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT:20> - size_label : <NUM_LIT:20> + size_label + <NUM_LIT:1> ] = <NUM_LIT:2> <EOL> data_dest [ <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> , <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> , <NUM_LIT:30> - size_label : <NUM_LIT:30> + size_label + <NUM_LIT:1> ] = <NUM_LIT:3> <EOL> data_dest [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> ] = <NUM_LIT:4> <EOL> data_dest [ <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT> - size_label : <NUM_LIT> + size_label + <NUM_LIT:1> , <NUM_LIT:50> - size_label : <NUM_LIT:50> + size_label + <NUM_LIT:1> ] = <NUM_LIT:5> <EOL> points_fixed = [ [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:10> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ] , <EOL> [ <NUM_LIT:30> , <NUM_LIT:30> , <NUM_LIT:30> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:50> ] ] <EOL> img_src = nib . Nifti1Image ( data_src , np . eye ( <NUM_LIT:4> ) ) <EOL> nib . save ( img_src , '<STR_LIT>' ) <EOL> img_dest = nib . Nifti1Image ( data_dest , np . eye ( <NUM_LIT:4> ) ) <EOL> nib . save ( img_dest , '<STR_LIT>' ) <EOL> import msct_register_landmarks <EOL> ( rotation_matrix , translation_array , moving_points_reg ) = msct_register_landmarks . getRigidTransformFromLandmarks ( points_fixed , points_moving , constraints = '<STR_LIT>' , show = False ) <EOL> text_file = open ( "<STR_LIT>" , "<STR_LIT:w>" ) <EOL> text_file . write ( "<STR_LIT>" ) <EOL> text_file . write ( "<STR_LIT>" ) <EOL> text_file . write ( "<STR_LIT>" ) <EOL> text_file . write ( "<STR_LIT>" % ( <EOL> rotation_matrix [ <NUM_LIT:0> , <NUM_LIT:0> ] , rotation_matrix [ <NUM_LIT:0> , <NUM_LIT:1> ] , rotation_matrix [ <NUM_LIT:0> , <NUM_LIT:2> ] , rotation_matrix [ <NUM_LIT:1> , <NUM_LIT:0> ] , <EOL> rotation_matrix [ <NUM_LIT:1> , <NUM_LIT:1> ] , rotation_matrix [ <NUM_LIT:1> , <NUM_LIT:2> ] , rotation_matrix [ <NUM_LIT:2> , <NUM_LIT:0> ] , rotation_matrix [ <NUM_LIT:2> , <NUM_LIT:1> ] , <EOL> rotation_matrix [ <NUM_LIT:2> , <NUM_LIT:2> ] , translation_array [ <NUM_LIT:0> , <NUM_LIT:0> ] , translation_array [ <NUM_LIT:0> , <NUM_LIT:1> ] , <EOL> translation_array [ <NUM_LIT:0> , <NUM_LIT:2> ] ) ) <EOL> text_file . write ( "<STR_LIT>" ) <EOL> text_file . close ( ) <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sct . run ( '<STR_LIT>' , verbose ) <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sct . run ( '<STR_LIT>' , verbose ) <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> cmd = '<STR_LIT>' <EOL> printv ( '<STR_LIT>' + cmd , verbose ) <EOL> commands . getstatusoutput ( cmd ) <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sct . run ( '<STR_LIT>' , verbose ) <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sct . run ( '<STR_LIT>' , verbose ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:r>" ) as file_dice : <EOL> dice = float ( file_dice . read ( ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> printv ( '<STR_LIT>' + str ( dice ) , verbose ) <EOL> if dice > dice_acceptable : <EOL> test_passed = <NUM_LIT:1> <EOL> os . chdir ( '<STR_LIT:..>' ) <EOL> if remove_temp_files == <NUM_LIT:1> : <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sct . run ( '<STR_LIT>' + path_tmp , verbose ) <EOL> if test_passed : <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> else : <EOL> printv ( '<STR_LIT>' , verbose ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def printv ( string , verbose ) : <EOL> if verbose : <EOL> print ( string ) <EOL> def usage ( ) : <EOL> print '<STR_LIT:\n>' '<STR_LIT>' + os . path . basename ( __file__ ) + '<STR_LIT:\n>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT:\n>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT:\n>' '<STR_LIT>' '<STR_LIT:U+0020>' + os . path . basename ( __file__ ) + '<STR_LIT:\n>' '<STR_LIT:\n>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT>' '<STR_LIT:\n>' <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
