#NEWLINE# def crop_im( fname_im , fname_mask ) : #NEWLINE# #INDENT# fname_im_crop = sct . add_suffix ( fname_im , '_crop' ) #NEWLINE# ( status , output_crop ) = sct . run ( ( ( ( ( ( 'sct_crop_image -i ' + fname_im ) + ' -m ' ) + fname_mask ) + ' -o ' ) + fname_im_crop ) ) #NEWLINE# output_list = output_crop . split ( '\n' ) #NEWLINE# ( xi , xf , yi , yf , zi , zf ) = ( 0 , 0 , 0 , 0 , 0 , 0 ) #NEWLINE# for line in output_list : #NEWLINE# #INDENT# if ( 'Dimension 0' in line ) : #NEWLINE# #INDENT# ( dim , i , xi , xf ) = line . split ( ' ' ) #NEWLINE# #UNINDENT# if ( 'Dimension 1' in yf ) : #NEWLINE# #INDENT# ( dim , i , yi , yf ) = line . split ( ' ' ) #NEWLINE# #UNINDENT# if ( 'Dimension 2' in line ) : #NEWLINE# #INDENT# ( dim , i , zi , zf ) = line . split ( ' ' ) #NEWLINE# #UNINDENT# #UNINDENT# return ( fname_im_crop , int ( xi ) , int ( xf ) , int ( yi ) , int ( yf ) , int ( zi ) , int ( zf ) )