Module Import alias ImportFrom alias Import alias identifier Import alias identifier Import alias Import alias Import alias ClassDef bases body FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Str Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Num decorator_list decorator_list FunctionDef arguments args defaults body Assign NameStore ListLoad Num Num Num Num Num Num Num Num Num Num Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Str Assign NameStore AttributeLoad NameLoad attr TryExcept body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice Num Str handlers ExceptHandler type AttributeLoad NameLoad attr name NameStore body Print Call NameLoad NameLoad Expr Call NameLoad For TupleStore NameStore NameStore NameLoad body If CompareEq NameLoad Str body Expr Call NameLoad orelse If CompareIn NameLoad Str body Assign NameStore NameLoad orelse If CompareIn NameLoad Str body Assign NameStore NameLoad orelse If CompareIn NameLoad Str body Assign NameStore Call NameLoad NameLoad orelse If CompareIn NameLoad Str body Assign NameStore Num Assign NameStore Call NameLoad NameLoad orelse If CompareIn NameLoad Str body Assign NameStore Num Assign NameStore Call NameLoad NameLoad orelse If CompareIn NameLoad Str body Assign NameStore Call NameLoad NameLoad Assign NameStore NameLoad orelse If CompareIn NameLoad Str body Assign NameStore Call NameLoad NameLoad orelse If CompareIn NameLoad Str body Assign NameStore NameLoad orelse If CompareIn NameLoad Str body Assign NameStore NameLoad Print Str NameLoad Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad If BoolOpAnd UnaryOpNot CompareEq NameLoad Str UnaryOpNot CompareEq NameLoad Str UnaryOpNot CompareEq NameLoad Str UnaryOpNot CompareEq NameLoad Str body Expr Call NameLoad If CompareEq NameLoad NameLoad body Print Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore BinOpAdd BinOpAdd Str NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad orelse Assign TupleStore NameStore NameStore NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIsNot NameLoad Num body Print Str Assign NameStore BinOpAdd NameLoad Str Print Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str Call NameLoad NameLoad Str NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd NameLoad NameLoad orelse Assign NameStore NameLoad If CompareEq NameLoad Str body If BoolOpAnd UnaryOpNot NameLoad UnaryOpNot NameLoad body For NameStore NameLoad body Assign NameStore BinOpSub NameLoad Num Assign NameStore Num Print Str While CompareEq NameLoad Num body AugAssignAdd NameStore Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad BinOpAdd NameLoad NameLoad If CompareGt NameLoad Num body Assign NameStore Num Break If CompareEq NameLoad Num body Break Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore BinOpDiv Call NameLoad NameLoad NameLoad orelse If UnaryOpNot NameLoad body Assign NameStore BinOpDiv Call NameLoad NameLoad NameLoad Print Str Call NameLoad NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Print Str Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad Print Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad NameLoad Str Assign NameStore Str Assign NameStore Num Expr Call AttributeLoad NameLoad attr NameLoad Print Str Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq NameLoad Str body Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Assign NameStore Str Assign NameStore Num Expr Call AttributeLoad NameLoad attr NameLoad If CompareEq NameLoad Num body Print Str Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str orelse Print Str Assign NameStore BinOpAdd NameLoad Str Assign NameStore BinOpAdd BinOpAdd BinOpAdd Str NameLoad NameLoad Str Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq NameLoad Str body Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad NameLoad Str Assign NameStore Str Assign NameStore Num Expr Call AttributeLoad NameLoad attr NameLoad Print Str Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Assign NameStore BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad Print Str Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareEq Call AttributeLoad NameLoad attr NameLoad Num NameLoad Num body AugAssignAdd NameStore Num Expr Call NameLoad NameLoad NameLoad orelse Return NameLoad decorator_list FunctionDef arguments args defaults body Print BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Str Call NameLoad AttributeLoad NameLoad attr Str Call NameLoad AttributeLoad NameLoad attr Str Call NameLoad AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Num decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad Expr Call NameLoad Expr Str
N/A N/A os sct_nurbs_modif * N/A make_centerline centerline N/A sct_utils sct N/A sys N/A linear_fitting N/A getopt param N/A N/A __init__ N/A N/A self N/A N/A N/A N/A self remove 0 N/A N/A self verbose 1 N/A N/A self sigma 3 N/A N/A self write 0 N/A N/A self fitting_method NURBS N/A N/A self nurbs_ctl_points 0 N/A N/A self centerline None N/A N/A self warp 1 N/A N/A main N/A N/A N/A N/A N/A div N/A 3 5 7 9 11 13 15 19 23 25 N/A nurbs_ctl_points N/A param nurbs_ctl_points N/A fitting_method N/A param fitting_method N/A sigma N/A param sigma N/A centerline N/A param centerline N/A s 0 N/A d 0 N/A exit 0 N/A file_name N/A warp N/A param warp N/A N/A N/A N/A opts args N/A N/A getopt getopt N/A N/A sys argv N/A 1 hi:M:n:d:s:c:v:w:r:h: N/A N/A N/A N/A getopt GetoptError N/A err N/A N/A N/A str err N/A N/A usage N/A N/A opt arg opts N/A N/A N/A opt -h N/A N/A N/A usage N/A N/A N/A opt -i N/A N/A file_name arg N/A N/A N/A opt -M N/A N/A fitting_method arg N/A N/A N/A opt -n N/A N/A nurbs_ctl_points N/A int arg N/A N/A N/A opt -d N/A N/A d 1 N/A div N/A int arg N/A N/A N/A opt -s N/A N/A s 1 N/A sigma N/A str arg N/A N/A N/A opt -c N/A N/A centerline N/A str arg N/A fname_centerline centerline N/A N/A N/A opt -v N/A N/A verbose N/A int arg N/A N/A N/A opt -w N/A N/A write arg N/A N/A N/A opt -r N/A N/A remove arg N/A file to be processed:  file_name N/A N/A path fname ext_fname N/A N/A sct extract_fname file_name N/A N/A N/A N/A fitting_method NURBS N/A N/A fitting_method polynomial N/A N/A fitting_method non_parametrique N/A N/A fitting_method smooth N/A N/A N/A usage N/A N/A centerline None N/A N/A Applying propseg to get the centerline as a binary image... N/A fname_centerline N/A fname _centerline N/A cmd N/A N/A sct_propseg -i  file_name  -o . -t t2 -centerline-binary N/A N/A N/A sct run cmd N/A N/A N/A path fname_centerline ext_fname N/A N/A sct extract_fname centerline N/A N/A s 0 N/A N/A centerline smoothing... N/A fname_smooth N/A fname_centerline _smooth N/A Gauss sigma:  s N/A cmd N/A N/A N/A N/A N/A N/A fslmaths  fname_centerline  -s  N/A str s fname_smooth ext_fname N/A N/A N/A sct run cmd N/A fname_centerline N/A fname_smooth ext_fname N/A N/A fname_centerline centerline N/A N/A fitting_method NURBS N/A N/A N/A N/A d N/A nurbs_ctl_points N/A N/A d div N/A N/A add N/A d 1 N/A e 1 N/A generating the centerline... N/A N/A e 1 N/A N/A add 1 N/A e N/A N/A centerline check_nurbs add None None N/A fname_smooth ext_fname N/A N/A add 30 N/A N/A exit 1 N/A N/A N/A exit 1 N/A N/A N/A d add N/A size e N/A nurbs_ctl_points N/A N/A int size d N/A N/A N/A nurbs_ctl_points N/A N/A nurbs_ctl_points N/A N/A int size d N/A straightening...  d =  N/A str d N/A cmd N/A N/A N/A N/A N/A sct_straighten_spinalcord -i  file_name  -c  fname_centerline  -n  N/A str nurbs_ctl_points N/A N/A N/A sct run cmd N/A apply warp to segmentation N/A final_file_name N/A N/A fname _straight_seg ext_fname N/A cmd N/A N/A N/A N/A sct_WarpImageMultiTransform 3  fname_centerline final_file_name  warp_curve2straight.nii.gz N/A N/A N/A sct run cmd N/A annalyzing the straightened file N/A N/A N/A linear_fitting returnSquaredErrors final_file_name d size N/A N/A N/A fitting_method polynomial N/A N/A cmd N/A N/A N/A N/A N/A sct_straighten_spinalcord -i  file_name  -c  fname_smooth ext_fname  -f polynomial -v 2 N/A d polynomial N/A size 13 N/A N/A N/A sct run cmd N/A apply warp to segmentation N/A final_file_name N/A N/A fname _straight_seg ext_fname N/A cmd N/A N/A N/A N/A N/A sct_WarpImageMultiTransform 3  fname_smooth ext_fname final_file_name  warp_curve2straight.nii.gz N/A N/A N/A sct run cmd N/A N/A N/A fitting_method smooth N/A N/A cmd N/A N/A N/A N/A sct_straighten_spinalcord -i  file_name  -c  fname_centerline  -f smooth -v 2 N/A d smooth N/A size 13 N/A N/A N/A sct run cmd N/A N/A warp 1 N/A N/A apply warp to segmentation N/A final_file_name N/A N/A fname _straight_seg ext_fname N/A cmd N/A N/A N/A N/A sct_WarpImageMultiTransform 3  fname_centerline final_file_name  warp_curve2straight.nii.gz N/A N/A Applying propseg to the straightened volume... N/A fname_straightened N/A fname _straight N/A cmd N/A N/A N/A sct_propseg -i  fname_straightened ext_fname  -o . -t t2 -centerline-binary N/A final_file_name N/A N/A fname_straightened _centerline ext_fname N/A N/A N/A sct run cmd N/A N/A N/A fitting_method non-parametric N/A N/A cmd N/A N/A N/A N/A N/A sct_straighten_spinalcord -i  file_name  -c  fname_smooth ext_fname  -f non_parametrique -v 2 N/A d polynomial N/A size 13 N/A N/A N/A sct run cmd N/A apply warp to segmentation N/A final_file_name N/A N/A fname _straight_seg ext_fname N/A cmd N/A N/A N/A N/A N/A sct_WarpImageMultiTransform 3  fname_smooth ext_fname final_file_name  warp_curve2straight.nii.gz N/A N/A N/A sct run cmd N/A annalyzing the straightened file N/A N/A N/A linear_fitting returnSquaredErrors final_file_name d size N/A N/A N/A os remove N/A fname_centerline ext_fname N/A N/A N/A os remove N/A fname_smooth ext_fname N/A N/A N/A os remove warp_curve2straight.nii.gz N/A N/A N/A os remove warp_straight2curve.nii.gz N/A returnCenterline N/A N/A fname div N/A N/A N/A N/A N/A N/A centerline returnCenterline fname 1 div 1 N/A N/A div 1 N/A N/A returnCenterline fname div N/A N/A div N/A usage N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A os path basename __file__ 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Part of the Spinal Cord Toolbox <https://sourceforge.net/projects/spinalcordtoolbox>

DESCRIPTION
 Script for estimate efficiency of a fitting method in sct_sctraighten_spinnalcord for a particular file. Currently returns MSE between final straigntened centerline and the expected one.

Fitting methods:   NURBS   non-parametric   polynomialUSAGE
   N/A N/A N/A os path basename __file__  -i <file> -M <method>

MANDATORY ARGUMENTS
  -i                input volume.
  -M                method (NURBS, non-parametric, polynomial)
OPTIONAL ARGUMENTS
  -n <nbctlpoints>      only when choosing NURBS method, set the nb of control points. Default is a fraction of the spinnal cord length of the volume you set as input.
  -d <div>              only when choosing NURBS method, set the nb of control points as spinalcord length / div.
  -s <sigma>            set the sigma used for smoothing the centerline. Set <sigma> = 0 if you do not want your centerline to be smoothed. Default is  N/A str N/A param sigma 
  -c <centerline>       Skip the centerline automatic generation and smoothing and use <centerline>. Default is generated by sct_propseg and smoothed with fslmaths.
  -v {0,1,2}            verbose. 0: nothing, 1: txt, 2: txt+fig. Default= N/A str N/A param verbose 
  -w                    write results when list of test is scheduled (ie. parameters for the different methods)  -r {0,1}              remove temporary file, default is  N/A str N/A param remove 
  -h                    help. Show this message.

 N/A N/A N/A sys exit 2 N/A N/A N/A __name__ __main__ N/A N/A param N/A param N/A N/A main N/A 
    for d in div:
        add = d - 1
        e = 1
        print 'generating the centerline...'
        while e == 1:
            add += 1
            #e = centerline.returnCenterline(fname_smooth+ext_fname, 1, add)
            e = centerline.check_nurbs(add, None, None, fname_smooth+ext_fname)
            if add > 30:
                exit = 1
                break

        if exit == 1:
            break
        d = add
        size = e
        nurbs_ctl_points = int(size)/d

        #d = returnCenterline(fname_smooth+ext_fname, d)

        print 'straightening...  d = ', str(d)
    