Module Import alias ImportFrom alias ImportFrom alias Import alias identifier ImportFrom alias alias ImportFrom alias alias alias alias alias alias ImportFrom alias ImportFrom alias FunctionDef arguments args defaults body Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr keyword Str keyword ListLoad ListLoad Str Str keyword Str keyword NameLoad keyword ListLoad Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword ListLoad Str Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword ListLoad Str Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword ListLoad Str Str Expr Call AttributeLoad NameLoad attr keyword Str keyword Str keyword Str keyword NameLoad keyword Str keyword ListLoad Str Str Str Expr Call AttributeLoad NameLoad attr keyword Str keyword NameLoad keyword Str keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body ImportFrom alias Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Index Num Assign NameStore Call NameLoad NameLoad NameLoad keyword NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults NameLoad body Assign NameStore Str Assign NameStore Str If UnaryOpNot NameLoad body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice Num Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore SubscriptLoad NameLoad Index Str If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str orelse Assign NameStore Str If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str orelse Assign NameStore Str If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Str Expr Call NameLoad Str NameLoad Assign NameStore Call NameLoad keyword NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Expr Call NameLoad NameLoad Expr Call NameLoad Str NameLoad If NameLoad body Expr Call NameLoad Str SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num orelse If NameLoad body Assign NameStore Call NameLoad Str Expr Call AttributeLoad NameLoad attr Str Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad Call NameLoad BinOpDiv NameLoad Num Expr Call NameLoad Str NameLoad NameLoad orelse Expr Call NameLoad Str Num Str Expr Call NameLoad Str NameLoad Expr Call NameLoad Str Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Assign NameStore Call NameLoad Str Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad If NameLoad body Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad If NameLoad body Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str Str NameLoad NameLoad NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str Str Str If CompareEq NameLoad Str body Assign TupleStore NameStore NameStore NameStore Call NameLoad NameLoad Assign NameStore BinOpAdd BinOpAdd NameLoad Str NameLoad Expr Call NameLoad Str Expr Call NameLoad Str NameLoad Expr Call NameLoad BinOpAdd NameLoad Str BinOpAdd NameLoad NameLoad If CompareEq NameLoad Num body Expr Call NameLoad Str NameLoad Expr Call NameLoad BinOpAdd Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad NameLoad Str NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Num body Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore ListLoad Num Num Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Str If CompareEq NameLoad Str body Assign NameStore Str orelse If CompareEq NameLoad Str body Assign NameStore Str ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad Num Assign NameStore Str Assign NameStore Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad Str NameLoad Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore Call NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Str Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore AttributeLoad Call NameLoad NameLoad attr Assign NameStore AttributeLoad Call NameLoad NameLoad attr If NameLoad body Expr Call NameLoad Str NameLoad ImportFrom alias Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr NameLoad ListLoad Num Num Num Assign NameStore Call NameLoad SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr Assign NameStore ListComp Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr CompareEq NameLoad SubscriptLoad NameLoad Index NameLoad Index Num comprehension NameStore Call NameLoad Call NameLoad NameLoad Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad BinOpMult Call AttributeLoad NameLoad attr NameLoad Num attr Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad If CompareEq NameLoad Num body Import alias identifier Expr Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore AttributeLoad NameLoad attr ImportFrom alias Assign NameStore Call NameLoad NameLoad NameLoad keyword NameLoad keyword Str Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad Call NameLoad BinOpDiv NameLoad Num Assign NameStore Call NameLoad Call NameLoad BinOpDiv NameLoad Num If CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd NameLoad NameLoad Slice Slice keyword Num attr keyword NameLoad keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr keyword NameLoad Expr Call NameLoad Str NameLoad Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore SubscriptLoad NameLoad Index Num Assign NameStore ListLoad Assign NameStore ListLoad Assign NameStore Str Assign NameStore NameLoad While NameLoad body Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str Call NameLoad NameLoad Str Call NameLoad NameLoad Str NameLoad NameLoad TryExcept body Assign NameStore Call NameLoad SubscriptLoad Call AttributeLoad NameLoad attr CompareEq NameLoad NameLoad Index Num handlers ExceptHandler type NameLoad body Expr Call NameLoad Str NameLoad Str Break Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr If CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad NameLoad keyword Str keyword Num Assign NameStore Call NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore Num Assign NameStore Num For NameStore NameLoad body If CompareGt BinOpAdd BinOpAdd NameLoad NameLoad NameLoad NameLoad body Assign NameStore BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpSub BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad TupleLoad TupleLoad Num Num TupleLoad Num Num TupleLoad Num NameLoad Str keyword Num orelse If CompareLt BinOpSub BinOpSub NameLoad NameLoad NameLoad Num body Assign NameStore Call NameLoad BinOpSub BinOpSub NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpAdd BinOpSub BinOpSub NameLoad NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpSub NameLoad NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad TupleLoad TupleLoad Num Num TupleLoad Num Num TupleLoad NameLoad Num Str keyword Num orelse Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr If BoolOpAnd CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call NameLoad NameLoad NameLoad Num orelse Assign NameStore Num Assign NameStore BinOpAdd NameLoad Num If NameLoad body Expr Call NameLoad Str NameLoad Assign NameStore NameLoad If Call AttributeLoad NameLoad attr NameLoad body Assign NameStore SubscriptLoad ListComp NameLoad comprehension NameStore Call NameLoad Call NameLoad NameLoad CompareEq SubscriptLoad NameLoad Index NameLoad Call NameLoad NameLoad Index Num Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str Call NameLoad NameLoad Str Call NameLoad SubscriptLoad NameLoad Index NameLoad Str NameLoad If CompareLt SubscriptLoad NameLoad Index NameLoad NameLoad body Expr Call NameLoad Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Num orelse Expr Call NameLoad Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Num If CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad keyword TupleLoad Num Num Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Slice Slice keyword Num attr keyword Str keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Num Assign NameStore Num Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Slice Slice keyword Num attr keyword Str keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Num Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Slice Slice keyword Num attr keyword Str keyword AttributeLoad AttributeLoad NameLoad attr attr keyword Str Expr Call AttributeLoad NameLoad attr BinOpAdd Str Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad Index NameLoad Str Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr keyword Call AttributeLoad NameLoad attr Num keyword Num keyword Str keyword Str Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword Num keyword Str keyword Str Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str Call NameLoad NameLoad Str Call AttributeLoad NameLoad attr Assign NameStore BinOpAdd NameLoad SubscriptLoad NameLoad Index NameLoad If CompareEq NameLoad Num body Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr BinOpAdd NameLoad NameLoad NameLoad keyword Str keyword Num Expr TupleLoad Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd NameLoad NameLoad Num NameLoad BinOpAdd BinOpAdd Call NameLoad NameLoad Str Call NameLoad BinOpAdd NameLoad Num keyword Str keyword Str keyword Str keyword Num Call AttributeLoad NameLoad attr If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr Num NameLoad Expr Call AttributeLoad NameLoad attr Num NameLoad orelse If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad If CompareGt Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad BinOpMult Call AttributeLoad NameLoad attr NameLoad Num attr Assign NameStore ListComp NameLoad comprehension TupleStore NameStore NameStore Call NameLoad NameLoad CompareIn NameLoad SubscriptLoad NameLoad Slice Num Assign NameStore ListComp SubscriptLoad NameLoad Index NameLoad comprehension NameStore NameLoad Assign NameStore ListComp BinOpDiv Call NameLoad SubscriptLoad NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad comprehension NameStore Call NameLoad Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad orelse Assign NameStore Num Assign NameStore ListComp Call NameLoad Call NameLoad BinOpMult SubscriptLoad NameLoad Index NameLoad NameLoad comprehension NameStore Call NameLoad Call NameLoad NameLoad If CompareEq NameLoad Str body TryExcept body Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr BinOpSub NameLoad Num handlers ExceptHandler type NameLoad body Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad Assign NameStore BinOpAdd NameLoad NameLoad Assign NameStore BinOpSub NameLoad Num orelse If CompareEq NameLoad Str body TryExcept body Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr NameLoad handlers ExceptHandler body Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore BinOpAdd NameLoad Num If BoolOpOr CompareGtE NameLoad NameLoad CompareEq NameLoad Num body Expr Call NameLoad Str NameLoad Assign NameStore Str Assign NameStore BinOpAdd SubscriptLoad NameLoad Index Num Num Assign NameStore BinOpSub SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr NameLoad If CompareLtE NameLoad Num body Assign NameStore NameLoad Assign NameStore Call NameLoad NameLoad If UnaryOpNot CompareEq NameLoad Num body Expr Call NameLoad BinOpAdd Str Call NameLoad BinOpSub NameLoad Num NameLoad Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr BinOpSub NameLoad Num Assign NameStore BinOpAdd Call NameLoad NameLoad NameLoad Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad If CompareGt NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr Num NameLoad orelse Expr Call AttributeLoad NameLoad attr Num NameLoad Expr Call AttributeLoad NameLoad attr Num BinOpSub NameLoad Num Assign NameStore Call NameLoad NameLoad For NameStore Call NameLoad NameLoad body TryExcept body Assign NameStore Call NameLoad ListComp NameLoad comprehension NameStore Call NameLoad Call NameLoad NameLoad CompareGt SubscriptLoad NameLoad Index NameLoad NameLoad handlers ExceptHandler type NameLoad body Assign NameStore Num orelse Assign NameStore BinOpAdd SubscriptLoad NameLoad Index NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Slice Index NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num NameLoad NameLoad If CompareEq NameLoad Num body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Call NameLoad Call NameLoad BinOpDiv NameLoad Num NameLoad keyword NameLoad keyword Call NameLoad NameLoad keyword Call NameLoad NameLoad keyword Str keyword Str keyword Num AugAssignAdd AttributeStore NameLoad attr Str Expr Call AttributeLoad NameLoad attr If CompareEq NameLoad Num body Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign TupleStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore NameStore AttributeLoad NameLoad attr ImportFrom alias Assign TupleStore NameStore NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr ExtSlice Slice Slice Index NameLoad Assign TupleStore NameStore NameStore TupleLoad Call NameLoad Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Assign SubscriptStore AttributeLoad NameLoad attr ExtSlice Slice Slice Slice Num Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad NameLoad NameLoad ImportFrom alias Assign AttributeStore NameLoad attr Call NameLoad AttributeLoad NameLoad attr Num Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad ImportFrom alias Assign TupleStore NameStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore NameStore TupleLoad Call NameLoad Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Call NameLoad Call NameLoad NameLoad Assign NameStore Call NameLoad SubscriptLoad AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad NameLoad Return ListLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults body Expr Str If CompareEq NameLoad Num body Import alias identifier Assign NameStore Num Assign NameStore Call NameLoad Num Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num If UnaryOpNot CompareEq AttributeLoad NameLoad attr TupleLoad Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num body Expr Call NameLoad Str NameLoad Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad Assign NameStore Num For NameStore NameLoad body Assign NameStore SubscriptLoad NameLoad ExtSlice Slice BinOpSub NameLoad NameLoad BinOpAdd BinOpAdd NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num Slice BinOpSub BinOpAdd NameLoad NameLoad NameLoad BinOpAdd BinOpAdd BinOpAdd NameLoad NameLoad NameLoad Num If UnaryOpNot CompareEq AttributeLoad NameLoad attr TupleLoad Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num Call NameLoad Call NameLoad BinOpAdd BinOpMult NameLoad Num Num body Expr Call NameLoad Str NameLoad Return NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Slice Num Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad NameLoad Index TupleLoad Num Num Assign NameStore BinOpAdd NameLoad Num Assign NameStore Call NameLoad Call NameLoad NameLoad keyword BinOpDiv Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If CompareEq NameLoad Num body Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Str Expr Call AttributeLoad NameLoad attr ListLoad Str Str Expr Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad Call NameLoad NameLoad AttributeLoad NameLoad attr keyword NameLoad Index Num If CompareEq Call NameLoad NameLoad Num body Expr Call NameLoad Str NameLoad Assign NameStore NameLoad orelse Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str Call NameLoad NameLoad Str Call NameLoad SubscriptLoad NameLoad Index NameLoad Str NameLoad If CompareLt SubscriptLoad NameLoad Index NameLoad NameLoad body Expr Call NameLoad Str NameLoad Assign NameStore NameLoad orelse Assign NameStore BinOpAdd Call NameLoad BinOpAdd NameLoad Call NameLoad BinOpDiv SubscriptLoad NameLoad Index NameLoad Num Num Expr Call NameLoad BinOpAdd Str Call NameLoad NameLoad NameLoad If CompareEq NameLoad Num body Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad SubscriptLoad NameLoad Index NameLoad Str Expr TupleLoad Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str Call NameLoad NameLoad Str Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Expr Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str Expr Call NameLoad BinOpAdd BinOpAdd Str NameLoad Str Assign NameStore AttributeLoad Call NameLoad Str attr Expr Call NameLoad Str Assign NameStore AttributeLoad Call NameLoad Str attr Assign NameStore AttributeLoad Call NameLoad NameLoad attr Assign NameStore BinOpSub NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad Str For NameStore Call NameLoad Call NameLoad SubscriptLoad NameLoad Index Num body Assign TupleStore NameStore NameStore NameStore TupleLoad SubscriptLoad SubscriptLoad NameLoad Index Num Index NameLoad SubscriptLoad SubscriptLoad NameLoad Index Num Index NameLoad SubscriptLoad SubscriptLoad NameLoad Index Num Index NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index TupleLoad NameLoad NameLoad NameLoad SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A sys os chdir glob glob N/A numpy np scipy.signal argrelextrema gaussian sct_utils extract_fname printv run generate_output_file slash_at_the_end tmp_create msct_parser Parser msct_image Image get_parser N/A N/A N/A N/A N/A parser N/A Parser __file__ N/A N/A N/A N/A parser usage set_description This function takes an anatomical image and its cord segmentation (binary file), and outputs the cord segmentation labeled with vertebral level. The algorithm requires an initialization (first disc) and then performs a disc search in the superior, then inferior direction, using template disc matching based on mutual information score.
Tips: To run the function with init txt file that includes flags -initz/-initcenter:
sct_label_vertebrae -i t2.nii.gz -s t2_seg_manual.nii.gz  "$(< init_label_vertebrae.txt)"
 N/A N/A N/A parser add_option name -i type_value file description input image. mandatory True example t2.nii.gz N/A N/A N/A parser add_option name -seg type_value file description Segmentation or centerline of the spinal cord. mandatory True deprecated_by -s example t2_seg.nii.gz N/A N/A N/A parser add_option name -s type_value file description Segmentation or centerline of the spinal cord. mandatory True example t2_seg.nii.gz N/A N/A N/A parser add_option name -initz type_value N/A N/A , int description Initialize labeling by providing slice number and disc value. Example: 68,3 (slice 68 corresponds to disc C3/C4). WARNING: Slice number should correspond to superior-inferior direction (e.g. Z in RPI orientation, but Y in LIP orientation). mandatory False example N/A 125,3 N/A N/A N/A parser add_option name -initcenter type_value int description Initialize labeling by providing the disc value centered in the rostro-caudal direction. If the spine is curved, then consider the disc that projects onto the cord at the center of the z-FOV mandatory False N/A N/A N/A parser add_option name -initfile type_value file description Initialize labeling by providing a text file which includes either -initz or -initcenter flag. mandatory False N/A N/A N/A parser add_option name -o type_value file_output description Output file mandatory False default_value example t2_seg_labeled.nii.gz N/A N/A N/A parser add_option name -ofolder type_value folder_creation description Output folder. mandatory False default_value N/A N/A N/A parser add_option name -denoise type_value multiple_choice description Apply denoising filter to the data. Sometimes denoising is too aggressive, so use with care. mandatory False default_value 0 example N/A 0 1 N/A N/A N/A parser add_option name -laplacian type_value multiple_choice description Apply Laplacian filtering. More accuracy but could mistake disc depending on anatomy. mandatory False default_value 0 example N/A 0 1 N/A N/A N/A parser add_option name -r type_value multiple_choice description Remove temporary files. mandatory False default_value 1 example N/A 0 1 N/A N/A N/A parser add_option name -v type_value multiple_choice description Verbose. 0: nothing. 1: basic. 2: extended. mandatory False default_value 1 example N/A 0 1 2 N/A N/A N/A parser add_option name -h type_value None description display this help mandatory False N/A parser N/A calc_MI N/A N/A x y bins N/A N/A sklearn.metrics mutual_info_score N/A c_xy N/A N/A N/A np histogram2d x y bins N/A 0 N/A mi N/A mutual_info_score None None contingency c_xy N/A mi N/A main N/A N/A args N/A None N/A N/A initz N/A initcenter N/A N/A args N/A N/A args N/A N/A sys argv N/A 1 N/A parser N/A get_parser N/A arguments N/A N/A parser parse N/A N/A sys argv N/A 1 N/A fname_in N/A arguments N/A -i N/A fname_seg N/A arguments N/A -s N/A N/A -o arguments N/A N/A file_out N/A arguments N/A -o N/A N/A file_out N/A N/A -ofolder arguments N/A N/A path_output N/A arguments N/A -ofolder N/A N/A path_output N/A N/A -initz arguments N/A N/A initz N/A arguments N/A -initz N/A N/A -initcenter arguments N/A N/A initcenter N/A arguments N/A -initcenter N/A verbose N/A int N/A arguments N/A -v N/A remove_tmp_files N/A int N/A arguments N/A -r N/A denoise N/A int N/A arguments N/A -denoise N/A laplacian N/A int N/A arguments N/A -laplacian N/A N/A printv 
Create temporary folder... verbose N/A path_tmp N/A tmp_create verbose verbose N/A N/A printv 
Copying input data to tmp folder... verbose N/A N/A run N/A N/A N/A N/A sct_convert -i  fname_in  -o  path_tmp data.nii N/A N/A run N/A N/A N/A N/A sct_convert -i  fname_seg  -o  path_tmp segmentation.nii.gz N/A N/A chdir path_tmp N/A N/A printv 
Create label to identify disc... verbose N/A initz N/A N/A N/A create_label_z segmentation.nii.gz N/A initz N/A 0 N/A initz N/A 1 N/A N/A initcenter N/A N/A nii N/A Image segmentation.nii.gz N/A N/A N/A nii change_orientation RPI N/A N/A nx ny nz nt px py pz pt N/A nii dim N/A z_center N/A int N/A round N/A nz 2 N/A N/A create_label_z segmentation.nii.gz z_center initcenter N/A N/A N/A printv 
ERROR: You need to initialize the disc detection algorithm using one of these two options: -initz, -initcenter
 1 error N/A N/A printv 
Straighten spinal cord... verbose N/A N/A run sct_straighten_spinalcord -i data.nii -s segmentation.nii.gz -r 0 -qc 0 N/A N/A printv 
Resample to 0.5mm isotropic... verbose N/A N/A run sct_resample -i data_straight.nii -mm 0.5x0.5x0.5 -x linear -o data_straightr.nii verbose N/A N/A printv 
Apply straightening to segmentation... verbose N/A N/A run sct_apply_transfo -i segmentation.nii.gz -d data_straightr.nii -w warp_curve2straight.nii.gz -o segmentation_straight.nii.gz -x linear verbose N/A N/A run sct_maths -i segmentation_straight.nii.gz -thr 0.5 -o segmentation_straight.nii.gz verbose N/A N/A printv 
Dilate z-label and apply straightening... verbose N/A N/A run sct_apply_transfo -i labelz.nii.gz -d data_straightr.nii -w warp_curve2straight.nii.gz -o labelz_straight.nii.gz -x nn verbose N/A N/A printv 
Get z and disc values from straight label... verbose N/A init_disc N/A get_z_and_disc_values_from_label labelz_straight.nii.gz N/A N/A printv N/A ..  N/A str init_disc verbose N/A denoise N/A N/A N/A printv 
Denoise data... verbose N/A N/A run sct_maths -i data_straight.nii -denoise h=0.05 -o data_straight.nii verbose N/A laplacian N/A N/A N/A printv 
Apply Laplacian filter... verbose N/A N/A run sct_maths -i data_straightr.nii -laplacian 1 -o data_straightr.nii verbose N/A N/A vertebral_detection data_straightr.nii segmentation_straight.nii.gz init_disc verbose laplacian N/A N/A printv 
Un-straighten labeling... verbose N/A N/A run sct_apply_transfo -i segmentation_straight_labeled.nii.gz -d segmentation.nii.gz -w warp_straight2curve.nii.gz -o segmentation_labeled.nii.gz -x nn verbose N/A N/A printv 
Clean labeled segmentation (correct interpolation errors)... verbose N/A N/A clean_labeled_segmentation segmentation_labeled.nii.gz segmentation.nii.gz segmentation_labeled.nii.gz N/A N/A file_out N/A N/A N/A path_seg file_seg ext_seg N/A extract_fname fname_seg N/A file_out N/A N/A file_seg _labeled ext_seg N/A N/A chdir .. N/A N/A printv 
Generate output files... verbose N/A N/A generate_output_file N/A path_tmp segmentation_labeled.nii.gz N/A path_output file_out N/A N/A remove_tmp_files 1 N/A N/A N/A printv 
Remove temporary files... verbose N/A N/A run N/A rm -rf  path_tmp N/A N/A printv 
Done! To view results, type: verbose N/A N/A printv N/A N/A N/A N/A N/A fslview  fname_in path_output file_out  -l Random-Rainbow -t 0.5 &
 verbose info N/A vertebral_detection N/A N/A fname fname_seg init_disc verbose laplacian N/A 0 N/A N/A shift_AP 32 N/A size_AP 11 N/A size_RL 1 N/A size_IS 19 N/A smooth_factor N/A 9 3 1 N/A thr_corr 0.2 N/A fig_anat_straight 1 N/A fig_pattern 2 N/A contrast_template t2 N/A N/A contrast_template t1 N/A N/A contrast_template T1 N/A N/A N/A contrast_template t2 N/A N/A contrast_template T2 os path N/A path_script N/A N/A path dirname __file__ N/A path_sct N/A slash_at_the_end N/A N/A path dirname path_script 1 N/A folder_template data/template/ N/A fname_template_list N/A glob N/A N/A N/A N/A path_sct folder_template * contrast_template .nii.gz N/A fname_template N/A fname_template_list N/A 0 N/A fname_disc_list N/A glob N/A N/A path_sct folder_template *_disc.nii.gz N/A fname_disc N/A fname_disc_list N/A 0 N/A data_template N/A N/A Image fname_template data N/A data_disc_template N/A N/A Image fname_disc data N/A laplacian N/A N/A N/A printv 
Applying Laplacian filter to template data... verbose sct_maths laplacian N/A data_template N/A laplacian N/A N/A data_template astype float N/A 1 1 1 N/A list_disc_value_template N/A sorted N/A data_disc_template N/A N/A N/A data_disc_template nonzero N/A list_disc_z_template N/A N/A int N/A N/A N/A np where N/A data_disc_template N/A list_disc_value_template N/A i N/A 2 N/A i N/A range N/A len list_disc_value_template N/A N/A printv N/A 
Disc values from template:  N/A str list_disc_value_template verbose N/A list_distance_template N/A N/A N/A N/A N/A np diff list_disc_z_template -1 tolist N/A N/A printv N/A Distances between discs (in voxel):  N/A str list_distance_template verbose N/A N/A verbose 2 N/A N/A matplotlib.pyplot plt N/A N/A N/A plt ion N/A img N/A Image fname N/A data N/A img data scipy.ndimage.filters gaussian_filter N/A data N/A gaussian_filter data smooth_factor output None mode reflect N/A N/A nx ny nz nt px py pz pt N/A img dim N/A z N/A range nz N/A xc N/A int N/A round N/A nx 2 N/A yc N/A int N/A round N/A ny 2 N/A N/A verbose 2 N/A N/A N/A N/A plt matshow N/A N/A N/A N/A np mean N/A data N/A N/A N/A xc size_RL N/A xc size_RL N/A N/A axis 0 transpose fignum fig_anat_straight cmap N/A N/A plt cm gray origin lower N/A N/A N/A plt title Anatomical image N/A N/A N/A plt autoscale enable False N/A N/A printv 
Detect intervertebral discs... verbose N/A current_z N/A init_disc N/A 0 N/A current_disc N/A init_disc N/A 1 N/A list_disc_z N/A N/A list_disc_value N/A N/A direction superior N/A search_next_disc True N/A search_next_disc N/A N/A N/A printv N/A N/A N/A N/A N/A Current disc:  N/A str current_disc  (z= N/A str current_z ). Direction:  direction verbose N/A N/A N/A current_z_template N/A int N/A N/A N/A np where N/A data_disc_template current_disc N/A 2 N/A N/A N/A TypeError N/A N/A N/A printv WARNING: Reached the bottom of the template. Stop searching. verbose warning N/A N/A pattern N/A data_template N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A current_z_template size_IS N/A N/A current_z_template size_IS 1 N/A pattern1d N/A N/A pattern ravel N/A N/A verbose 2 N/A N/A N/A N/A plt figure fig_anat_straight N/A N/A N/A plt scatter N/A yc shift_AP current_z c red s 50 N/A range_z N/A range -10 10 N/A I_corr N/A N/A np zeros N/A len range_z N/A allzeros 0 N/A ind_I 0 N/A iz range_z N/A N/A N/A N/A N/A current_z iz size_IS nz N/A N/A padding_size N/A N/A current_z iz size_IS N/A data_chunk3d N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A N/A current_z iz size_IS N/A N/A N/A N/A current_z iz size_IS 1 padding_size N/A data_chunk3d N/A N/A np pad data_chunk3d N/A N/A 0 0 N/A 0 0 N/A 0 padding_size constant constant_values 0 N/A N/A N/A N/A N/A current_z iz size_IS 0 N/A N/A padding_size N/A abs N/A N/A current_z iz size_IS N/A data_chunk3d N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A N/A N/A current_z iz size_IS padding_size N/A N/A N/A current_z iz size_IS 1 N/A data_chunk3d N/A N/A np pad data_chunk3d N/A N/A 0 0 N/A 0 0 N/A padding_size 0 constant constant_values 0 N/A N/A data_chunk3d N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A N/A current_z iz size_IS N/A N/A N/A current_z iz size_IS 1 N/A data_chunk1d N/A N/A data_chunk3d ravel N/A N/A N/A N/A data_chunk1d size N/A pattern1d size N/A N/A np any data_chunk1d N/A N/A N/A I_corr N/A ind_I N/A calc_MI data_chunk1d pattern1d 32 N/A N/A allzeros 1 N/A ind_I N/A ind_I 1 N/A allzeros N/A N/A N/A printv .. WARNING: Data contained zero. We probably hit the edge of the image. verbose N/A I_corr_adj I_corr N/A N/A N/A np any I_corr_adj N/A N/A ind_peak N/A N/A i N/A i N/A range N/A len I_corr_adj N/A N/A I_corr_adj N/A i N/A max I_corr_adj N/A 0 N/A N/A printv N/A N/A N/A N/A .. Peak found: z= N/A str ind_peak  (correlation =  N/A str N/A I_corr_adj N/A ind_peak ) verbose N/A N/A N/A I_corr_adj N/A ind_peak thr_corr N/A N/A N/A printv .. WARNING: Correlation is too low. Using adjusted template distance. verbose N/A ind_peak N/A N/A range_z index 0 N/A N/A N/A printv .. WARNING: Correlation vector only contains zeros. Using adjusted template distance. verbose N/A ind_peak N/A N/A range_z index 0 N/A N/A verbose 2 N/A N/A N/A N/A plt figure fig_pattern figsize N/A 20 7 N/A N/A N/A plt subplot 141 N/A N/A N/A plt imshow N/A N/A np flipud N/A N/A N/A N/A np mean N/A pattern N/A N/A N/A N/A axis 0 transpose origin upper cmap N/A N/A plt cm gray interpolation none N/A N/A N/A plt title Template pattern N/A N/A N/A plt subplot 142 N/A iz 0 N/A data_chunk3d N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A N/A current_z iz size_IS N/A N/A N/A current_z iz size_IS 1 N/A N/A N/A plt imshow N/A N/A np flipud N/A N/A N/A N/A np mean N/A data_chunk3d N/A N/A N/A N/A axis 0 transpose origin upper cmap N/A N/A plt cm gray interpolation none N/A N/A N/A plt title Subject at iz=0 N/A N/A N/A plt subplot 143 N/A iz N/A range_z N/A ind_peak N/A data_chunk3d N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP N/A N/A N/A yc shift_AP size_AP 1 N/A N/A N/A current_z iz size_IS N/A N/A N/A current_z iz size_IS 1 N/A N/A N/A plt imshow N/A N/A np flipud N/A N/A N/A N/A np mean N/A data_chunk3d N/A N/A N/A N/A axis 0 transpose origin upper cmap N/A N/A plt cm gray interpolation none N/A N/A N/A plt title N/A Subject at iz= N/A str iz N/A N/A N/A plt subplot 144 N/A N/A N/A plt plot I_corr_adj N/A N/A N/A plt title MI between template and subject pattern N/A N/A N/A N/A plt plot ind_peak N/A I_corr_adj N/A ind_peak ro N/A N/A plt draw N/A N/A N/A plt axvline x N/A N/A range_z index 0 linewidth 1 color black linestyle dashed N/A N/A N/A plt axhline y thr_corr linewidth 1 color r linestyle dashed N/A N/A N/A N/A plt figure fig_pattern N/A N/A plt savefig N/A N/A ../fig_pattern_MI N/A str current_disc .png N/A N/A plt close N/A current_z N/A current_z N/A range_z N/A ind_peak N/A N/A verbose 2 N/A N/A N/A N/A N/A plt figure fig_anat_straight N/A N/A plt scatter N/A yc shift_AP current_z c yellow s 50 N/A N/A N/A N/A plt text N/A N/A yc shift_AP 4 current_z N/A N/A N/A str current_disc / N/A str N/A current_disc 1 verticalalignment center horizontalalignment left color yellow fontsize 15 N/A N/A plt draw N/A N/A direction superior N/A N/A N/A N/A list_disc_z insert 0 current_z N/A N/A N/A list_disc_value insert 0 current_disc N/A N/A N/A direction inferior N/A N/A N/A N/A list_disc_z append current_z N/A N/A N/A list_disc_value append current_disc N/A N/A N/A len list_disc_z 1 N/A N/A list_distance_current N/A N/A N/A N/A N/A np diff list_disc_z -1 tolist N/A index_disc_identified N/A i N/A N/A i j N/A enumerate list_disc_value_template N/A j N/A list_disc_value N/A -1 N/A list_distance_template_identified N/A N/A list_distance_template N/A i N/A i index_disc_identified N/A list_subject_to_template_distance N/A N/A N/A float N/A list_distance_current N/A i N/A list_distance_template_identified N/A i N/A i N/A range N/A len list_distance_current N/A correcting_factor N/A N/A np mean list_subject_to_template_distance N/A N/A printv N/A .. correcting factor:  N/A str correcting_factor verbose N/A N/A correcting_factor 1 N/A list_distance N/A N/A int N/A round N/A N/A list_distance_template N/A i correcting_factor N/A i N/A range N/A len list_distance_template N/A N/A direction superior N/A N/A N/A N/A approx_distance_to_next_disc N/A list_distance N/A N/A N/A list_disc_value_template index N/A current_disc 1 N/A N/A N/A ValueError N/A N/A N/A printv N/A WARNING: Disc value not included in template. Using previously-calculated distance:  N/A str approx_distance_to_next_disc N/A current_z N/A current_z approx_distance_to_next_disc N/A current_disc N/A current_disc 1 N/A N/A N/A direction inferior N/A N/A N/A N/A approx_distance_to_next_disc N/A list_distance N/A N/A N/A list_disc_value_template index current_disc N/A N/A N/A N/A N/A printv N/A WARNING: Disc value not included in template. Using previously-calculated distance:  N/A str approx_distance_to_next_disc N/A current_z N/A current_z approx_distance_to_next_disc N/A current_disc N/A current_disc 1 N/A N/A N/A current_z nz N/A current_disc 1 N/A N/A N/A printv .. Switching to inferior direction. verbose N/A direction inferior N/A current_disc N/A N/A init_disc N/A 1 1 N/A current_z N/A N/A init_disc N/A 0 N/A list_distance N/A N/A N/A list_disc_value_template index current_disc N/A N/A current_z 0 N/A N/A search_next_disc False N/A upper_disc N/A min list_disc_value N/A N/A N/A upper_disc 1 N/A N/A N/A printv N/A Adding top disc based on adjusted template distance: # N/A str N/A upper_disc 1 verbose N/A approx_distance_to_next_disc N/A list_distance N/A N/A N/A list_disc_value_template index N/A upper_disc 1 N/A next_z N/A N/A max list_disc_z approx_distance_to_next_disc N/A N/A printv N/A .. approximate distance:  N/A str approx_distance_to_next_disc verbose N/A N/A next_z nz N/A N/A N/A N/A list_disc_z insert 0 nz N/A N/A N/A N/A list_disc_z insert 0 next_z N/A N/A N/A list_disc_value insert 0 N/A upper_disc 1 N/A seg N/A Image fname_seg N/A iz N/A range nz N/A N/A N/A N/A ind_above_iz N/A max N/A i N/A i N/A range N/A len list_disc_z N/A N/A list_disc_z N/A i iz N/A N/A N/A ValueError N/A N/A vertebral_level 0 N/A N/A vertebral_level N/A N/A list_disc_value N/A ind_above_iz 1 N/A ind_nonzero N/A N/A np nonzero N/A N/A seg data N/A N/A N/A N/A iz N/A N/A N/A seg data N/A N/A N/A ind_nonzero N/A 0 N/A ind_nonzero N/A 1 iz vertebral_level N/A N/A verbose 2 N/A N/A N/A N/A plt figure fig_anat_straight N/A N/A N/A plt scatter N/A int N/A round N/A ny 2 iz c vertebral_level vmin N/A min list_disc_value vmax N/A max list_disc_value cmap prism marker _ s 200 N/A N/A seg file_name _labeled N/A N/A N/A seg save N/A N/A verbose 2 N/A N/A N/A N/A N/A plt figure fig_anat_straight N/A N/A plt savefig ../fig_anat_straight_with_labels.png N/A N/A N/A plt close N/A create_label_z N/A N/A fname_seg z value N/A N/A N/A 
    Create a label at coordinates x_center, y_center, z
    :param fname_seg: segmentation
    :param z: int
    :return: fname_label
     N/A fname_label labelz.nii.gz N/A nii N/A Image fname_seg N/A orientation_origin N/A N/A nii change_orientation RPI N/A N/A nx ny nz nt px py pz pt N/A nii dim scipy.ndimage.measurements center_of_mass N/A N/A x y N/A center_of_mass N/A N/A nii data N/A N/A N/A N/A z N/A N/A x y N/A N/A int N/A round x N/A int N/A round y N/A N/A N/A nii data N/A N/A N/A N/A 0 N/A N/A N/A nii data N/A N/A x y z value sct_maths dilate N/A N/A nii data N/A dilate N/A nii data 3 N/A N/A N/A nii setFileName fname_label N/A N/A N/A nii change_orientation orientation_origin N/A N/A N/A nii save N/A fname_label N/A get_z_and_disc_values_from_label N/A N/A fname_label N/A N/A N/A 
    Find z-value and label-value based on labeled image
    :param fname_label: image that contains label
    :return: [z_label, value_label] int list
     N/A nii N/A Image fname_label scipy.ndimage.measurements center_of_mass N/A N/A x_label y_label z_label N/A center_of_mass N/A nii data N/A N/A x_label y_label z_label N/A N/A int N/A round x_label N/A int N/A round y_label N/A int N/A round z_label N/A value_label N/A int N/A N/A nii data N/A N/A x_label y_label z_label N/A N/A z_label value_label N/A local_adjustment N/A N/A xc yc current_z current_disc data size_RL shift_AP size_IS searching_window_for_maximum verbose N/A N/A N/A 
    Do local adjustment to be at the center of the current disc, using cross-correlation of mirrored disc
    :param current_z: init current_z
    :return: adjusted_z: adjusted current_z
     N/A N/A verbose 2 N/A N/A matplotlib.pyplot plt N/A size_AP_mirror 1 N/A searching_window N/A range -9 13 N/A fig_local_adjustment 4 N/A thr_corr 0.15 N/A gaussian_std_factor 3 N/A pattern N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP_mirror N/A N/A N/A yc shift_AP size_AP_mirror 1 N/A N/A current_z size_IS N/A N/A current_z size_IS 1 N/A N/A N/A N/A pattern shape N/A N/A int N/A round N/A N/A size_RL 2 1 N/A int N/A round N/A N/A size_AP_mirror 2 1 N/A int N/A round N/A N/A size_IS 2 1 N/A N/A N/A printv .... WARNING: Pattern is missing data (because close to the edge). Using initial current_z provided. verbose N/A current_z N/A pattern1d N/A N/A pattern ravel N/A I_corr N/A N/A np zeros N/A len searching_window N/A ind_I 0 N/A iz searching_window N/A N/A pattern_shift N/A data N/A N/A N/A xc size_RL N/A N/A xc size_RL 1 N/A N/A N/A yc shift_AP size_AP_mirror N/A N/A N/A yc shift_AP size_AP_mirror 1 N/A N/A N/A current_z iz size_IS N/A N/A N/A current_z iz size_IS 1 N/A N/A N/A N/A pattern_shift shape N/A N/A int N/A round N/A N/A size_RL 2 1 N/A int N/A round N/A N/A size_AP_mirror 2 1 N/A int N/A round N/A N/A size_IS 2 1 N/A N/A N/A printv .... WARNING: Pattern is missing data (because close to the edge). Using initial current_z provided. verbose N/A current_z N/A pattern1d_shift N/A N/A pattern_shift ravel N/A pattern1d_shift_mirr N/A pattern1d_shift N/A -1 N/A N/A I_corr N/A ind_I N/A N/A N/A np corrcoef pattern1d_shift_mirr pattern1d N/A N/A 0 1 N/A ind_I N/A ind_I 1 N/A gaussian_window N/A gaussian N/A len searching_window std N/A N/A len searching_window gaussian_std_factor N/A I_corr_adj N/A N/A np multiply I_corr gaussian_window N/A N/A verbose 2 N/A N/A N/A N/A N/A plt figure fig_local_adjustment N/A N/A plt plot I_corr N/A N/A plt plot I_corr_adj k N/A N/A N/A plt legend N/A I_corr I_corr_adj N/A N/A N/A plt title Correlation of pattern with mirrored pattern. N/A ind_peak N/A N/A argrelextrema I_corr_adj N/A np greater order searching_window_for_maximum N/A 0 N/A N/A N/A len ind_peak 0 N/A N/A N/A printv .... WARNING: No peak found. Using initial current_z provided. verbose N/A adjusted_z current_z N/A N/A ind_peak N/A ind_peak N/A N/A N/A np argmax N/A I_corr_adj N/A ind_peak N/A N/A printv N/A N/A N/A N/A .... Peak found:  N/A str ind_peak  (correlation =  N/A str N/A I_corr_adj N/A ind_peak ) verbose N/A N/A N/A I_corr_adj N/A ind_peak thr_corr N/A N/A N/A printv .... WARNING: Correlation is too low. Using initial current_z provided. verbose N/A adjusted_z current_z N/A N/A adjusted_z N/A N/A int N/A current_z N/A round N/A N/A searching_window N/A ind_peak 2 1 N/A N/A printv N/A .... Update init_z position to:  N/A str adjusted_z verbose N/A N/A verbose 2 N/A N/A N/A N/A N/A plt figure fig_local_adjustment N/A N/A plt plot ind_peak N/A I_corr_adj N/A ind_peak ro N/A N/A N/A N/A plt figure fig_local_adjustment N/A N/A plt savefig N/A N/A ../fig_local_adjustment_disc N/A str current_disc .png N/A N/A plt close N/A adjusted_z N/A clean_labeled_segmentation N/A N/A fname_labeled_seg fname_seg fname_labeled_seg_new N/A N/A N/A 
    Clean labeled segmentation by:
      (i)  removing voxels in segmentation_labeled that are not in segmentation and
      (ii) adding voxels in segmentation that are not in segmentation_labeled
    :param fname_labeled_seg:
    :param fname_seg:
    :param fname_labeled_seg_new: output
    :return: none
     N/A N/A run N/A N/A N/A N/A sct_maths -i  fname_labeled_seg  -mul  fname_seg  -o segmentation_labeled_mul.nii.gz N/A N/A run N/A N/A sct_maths -i  fname_labeled_seg  -dilate 2 -o segmentation_labeled_dilate.nii.gz N/A data_label_dilate N/A N/A Image segmentation_labeled_dilate.nii.gz data N/A N/A run sct_maths -i segmentation_labeled_mul.nii.gz -bin -o segmentation_labeled_mul_bin.nii.gz N/A data_label_bin N/A N/A Image segmentation_labeled_mul_bin.nii.gz data N/A data_seg N/A N/A Image fname_seg data N/A data_diff N/A data_seg data_label_bin N/A ind_nonzero N/A N/A np where data_diff N/A im_label N/A Image segmentation_labeled_mul.nii.gz N/A i_vox N/A range N/A len N/A ind_nonzero N/A 0 N/A N/A N/A ix iy iz N/A N/A N/A ind_nonzero N/A 0 N/A i_vox N/A N/A ind_nonzero N/A 1 N/A i_vox N/A N/A ind_nonzero N/A 2 N/A i_vox N/A N/A N/A im_label data N/A N/A ix iy iz N/A data_label_dilate N/A N/A ix iy iz N/A N/A N/A im_label setFileName fname_labeled_seg_new N/A N/A N/A im_label save N/A N/A N/A __name__ __main__ N/A N/A N/A main