Module Import alias alias alias ImportFrom alias Import alias Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd NameLoad Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd NameLoad Str ImportFrom alias alias alias alias Import alias identifier ImportFrom alias ImportFrom alias Assign NameStore ListLoad ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str ListLoad Str Str Str Assign NameStore NameLoad Assign NameStore Str Assign NameStore Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd BinOpAdd Str NameLoad Str Assign NameStore Call NameLoad BinOpAdd BinOpAdd NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd NameLoad Str NameLoad For NameStore Call NameLoad Num Call NameLoad NameLoad body Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num If Call AttributeLoad AttributeLoad NameLoad attr attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad Str NameLoad Str NameLoad body Print BinOpAdd Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad Str NameLoad Str NameLoad Print BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str Str Assign NameStore Str Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad Str NameLoad Str NameLoad Assign NameStore Call NameLoad BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd NameLoad Str NameLoad Str NameLoad Str NameLoad Str Assign NameStore NameLoad Assign NameStore NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num If CompareEq Call NameLoad NameLoad Num body Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr Str Index Num Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad BinOpAdd BinOpAdd NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str NameLoad Str Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Str If CompareIn Str NameLoad body Expr Call AttributeLoad NameLoad attr Str Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore BinOpAdd NameLoad Num Assign NameStore SubscriptLoad NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str NameLoad Str If BoolOpAnd CompareEq NameLoad NameLoad CompareEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str orelse Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str NameLoad Str If CompareIn Str NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore BinOpAdd NameLoad Num Assign NameStore SubscriptLoad NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str NameLoad Str If CompareIn Str NameLoad body Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd BinOpAdd Str NameLoad Str NameLoad Str NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore BinOpAdd NameLoad Num Assign NameStore SubscriptLoad NameLoad Slice NameLoad Expr Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd Str NameLoad Str Expr Call AttributeLoad NameLoad attr Str Expr Call AttributeLoad NameLoad attr
N/A N/A commands sys os glob glob N/A nibabel N/A N/A status path_sct N/A N/A commands getstatusoutput echo $SCT_DIR N/A N/A N/A N/A sys path append N/A path_sct /scripts N/A N/A N/A N/A sys path append N/A path_sct /dev/tamag numpy mean append isnan array N/A sct_utils sct scipy ndimage msct_image Image N/A SUBJECTS_LIST_total N/A N/A errsm_02 /Volumes/data_shared/montreal_criugm/errsm_02/22-SPINE_T1 /Volumes/data_shared/montreal_criugm/errsm_02/28-SPINE_T2 N/A errsm_04 /Volumes/data_shared/montreal_criugm/errsm_04/16-SPINE_memprage/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_04/18-SPINE_space N/A errsm_05 /Volumes/data_shared/montreal_criugm/errsm_05/23-SPINE_MEMPRAGE/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_05/24-SPINE_SPACE N/A errsm_09 /Volumes/data_shared/montreal_criugm/errsm_09/34-SPINE_MEMPRAGE2/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_09/33-SPINE_SPACE N/A errsm_10 /Volumes/data_shared/montreal_criugm/errsm_10/13-SPINE_MEMPRAGE/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_10/20-SPINE_SPACE N/A errsm_11 /Volumes/data_shared/montreal_criugm/errsm_11/24-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_11/09-SPINE_T2 N/A errsm_12 /Volumes/data_shared/montreal_criugm/errsm_12/19-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_12/18-SPINE_T2 N/A errsm_13 /Volumes/data_shared/montreal_criugm/errsm_13/33-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_13/34-SPINE_T2 N/A errsm_14 /Volumes/data_shared/montreal_criugm/errsm_14/5002-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_14/5003-SPINE_T2 N/A errsm_16 /Volumes/data_shared/montreal_criugm/errsm_16/23-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_16/39-SPINE_T2 N/A errsm_17 /Volumes/data_shared/montreal_criugm/errsm_17/41-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_17/42-SPINE_T2 N/A errsm_18 /Volumes/data_shared/montreal_criugm/errsm_18/36-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_18/33-SPINE_T2 N/A errsm_21 /Volumes/data_shared/montreal_criugm/errsm_21/27-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_21/30-SPINE_T2 N/A errsm_22 /Volumes/data_shared/montreal_criugm/errsm_22/29-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_22/25-SPINE_T2 N/A errsm_23 /Volumes/data_shared/montreal_criugm/errsm_23/29-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_23/28-SPINE_T2 N/A errsm_24 /Volumes/data_shared/montreal_criugm/errsm_24/20-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_24/24-SPINE_T2 N/A errsm_25 /Volumes/data_shared/montreal_criugm/errsm_25/25-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_25/26-SPINE_T2 N/A errsm_30 /Volumes/data_shared/montreal_criugm/errsm_30/51-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_30/50-SPINE_T2 N/A errsm_31 /Volumes/data_shared/montreal_criugm/errsm_31/31-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_31/32-SPINE_T2 N/A errsm_32 /Volumes/data_shared/montreal_criugm/errsm_32/16-SPINE_T1/echo_2.09  /Volumes/data_shared/montreal_criugm/errsm_32/19-SPINE_T2 N/A errsm_33 /Volumes/data_shared/montreal_criugm/errsm_33/30-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_33/31-SPINE_T2 N/A 1 /Volumes/data_shared/marseille/ED/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-101 /Volumes/data_shared/marseille/ED/01_0008_sc-tse-spc-1mm-3palliers-fov256-nopat-comp-sp-65 N/A ALT /Volumes/data_shared/marseille/ALT/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-15 /Volumes/data_shared/marseille/ALT/01_0100_space-composing N/A JD /Volumes/data_shared/marseille/JD/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-23 /Volumes/data_shared/marseille/JD/01_0100_compo-space N/A JW /Volumes/data_shared/marseille/JW/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/JW/01_0100_compo-space N/A MLL /Volumes/data_shared/marseille/MLL_1016/01_0008_sc-mprage-1mm-2palliers-fov384-comp-sp-7 /Volumes/data_shared/marseille/MLL_1016/01_0100_t2-compo N/A MT /Volumes/data_shared/marseille/MT/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/MT/01_0100_t2composing N/A TR /Volumes/data_shared/marseille/TR_T076/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/TR_T076/01_0016_sc-tse-spc-1mm-3palliers-fov256-nopat-comp-sp-19 N/A T047 /Volumes/data_shared/marseille/T047/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/T047/01_0100_t2-3d-composing N/A VC /Volumes/data_shared/marseille/VC/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-23 /Volumes/data_shared/marseille/VC/01_0008_sc-tse-spc-1mm-3palliers-fov256-nopat-comp-sp-113 N/A VG /Volumes/data_shared/marseille/VG/T1/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-15 /Volumes/data_shared/marseille/VG/T2/01_0024_sc-tse-spc-1mm-3palliers-fov256-nopat-comp-sp-11 N/A VP /Volumes/data_shared/marseille/VP/01_0011_sc-mprage-1mm-2palliers-fov384-comp-sp-25 /Volumes/data_shared/marseille/VP/01_0100_space-compo N/A pain_pilot_1 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot1/24-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot1/25-SPINE N/A pain_pilot_2 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot2/13-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot2/30-SPINE_T2 N/A pain_pilot_4 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot4/33-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot4/32-SPINE_T2 N/A TM /Volumes/data_shared/marseille/TM_T057c/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/TM_T057c/01_0105_t2-composing N/A errsm_20 /Volumes/data_shared/montreal_criugm/errsm_20/12-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_20/34-SPINE_T2 N/A pain_pilot_3 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot3/16-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot3/31-SPINE_T2 N/A errsm_34 /Volumes/data_shared/montreal_criugm/errsm_34/41-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_34/40-SPINE_T2 N/A errsm_35 /Volumes/data_shared/montreal_criugm/errsm_35/37-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_35/38-SPINE_T2 N/A pain_pilot_7 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot7/32-SPINE_T1/echo_2.09 /Volumes/data_shared/montreal_criugm/d_sp_pain_pilot7/33-SPINE_T2 N/A errsm_03 /Volumes/data_shared/montreal_criugm/errsm_03/32-SPINE_all/echo_2.09 /Volumes/data_shared/montreal_criugm/errsm_03/38-SPINE_all_space N/A FR /Volumes/data_shared/marseille/FR_T080/01_0039_sc-mprage-1mm-3palliers-fov384-comp-sp-13 /Volumes/data_shared/marseille/FR_T080/01_0104_spine2 N/A GB /Volumes/data_shared/marseille/GB_T083/01_0029_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/GB_T083/01_0033_sc-tse-spc-1mm-3palliers-fov256-nopat-comp-sp-7 N/A T045 /Volumes/data_shared/marseille/T045/01_0007_sc-mprage-1mm-2palliers-fov384-comp-sp-5 /Volumes/data_shared/marseille/T045/01_0101_t2-3d-composing N/A SUBJECTS_LIST SUBJECTS_LIST_total N/A path_i /Users/tamag/data/data_template/info/template_subjects N/A contrast T1 N/A path_result N/A N/A N/A os chdir path_i N/A f_name N/A N/A all_crop_ contrast .txt N/A f N/A open N/A N/A path_i / f_name w N/A N/A N/A f write ##Commands to generate label and txt files

path_results =''

if not os.path.isdir(path_results +'/' + 'T1'):
	os.makedirs(path_results +'/' + 'T1')
 N/A N/A N/A f write 
if not os.path.isdir(path_results +'/' + 'T2'):
	os.makedirs(path_results +'/' + 'T2')
 N/A N/A N/A f close N/A list_d N/A N/A os listdir N/A N/A path_i / contrast N/A i N/A range 0 N/A len SUBJECTS_LIST N/A N/A subject N/A N/A SUBJECTS_LIST N/A i N/A 0 N/A N/A N/A N/A os path isdir N/A N/A N/A N/A path_i / contrast / subject N/A N/A N/A subject N/A list_d_2 N/A N/A os listdir N/A N/A N/A N/A path_i / contrast / subject N/A N/A N/A N/A N/A N/A N/A N/A 
Recover infos from text file path_i / contrast / subject / crop.txt N/A file_name crop.txt N/A N/A N/A os chdir N/A N/A N/A N/A path_i / contrast / subject N/A file N/A open N/A N/A N/A N/A N/A N/A path_i / contrast / subject / file_name r N/A ymin_anatomic None N/A ymax_anatomic None N/A line file N/A N/A line_list N/A N/A line split , N/A zmin_anatomic N/A N/A N/A line split , N/A 0 N/A zmax_anatomic N/A N/A N/A line split , N/A 1 N/A zmin_seg N/A N/A N/A line split , N/A 2 N/A zmax_seg N/A N/A N/A line split , N/A 3 N/A N/A N/A len line_list 6 N/A N/A ymin_anatomic N/A N/A N/A line split , N/A 4 N/A ymax_anatomic N/A N/A N/A line split , N/A 5 N/A N/A N/A file close N/A N/A N/A os chdir ../.. N/A f N/A open N/A N/A path_i / f_name a N/A N/A N/A f write N/A N/A 

#Preprocessing for subject  subject N/A N/A N/A f write N/A N/A N/A N/A N/A N/A N/A N/A os.makedirs(path_results + '/ contrast / subject ')
os.chdir(path_results + '/ contrast / subject ')
 N/A N/A N/A f write N/A N/A sct.run('dcm2nii -o . -r N  N/A N/A SUBJECTS_LIST N/A i N/A 1 /*.dcm')
sct.run('mv *.nii.gz data.nii.gz')
sct.run('sct_orientation -i data.nii.gz -s RPI')
 N/A N/A labels_vertebral.nii.gz list_d_2 N/A N/A N/A N/A f write sct.run('sct_crop_image -i data_RPI.nii.gz -dim 2 -start 2 -end 1 -b 0 -o labels_vertebral.nii.gz')
 N/A N/A status output N/A N/A sct run N/A N/A N/A N/A N/A N/A sct_label_utils -i  path_i / contrast / subject /labels_vertebral.nii.gz -t display-voxel N/A nb N/A N/A output find notation N/A int_nb N/A nb 10 N/A labels N/A output N/A int_nb N/A N/A N/A f write N/A N/A sct.run('sct_label_utils -i labels_vertebral.nii.gz -o labels_vertebral.nii.gz -t create -x  labels ')
 N/A N/A N/A ymin_anatomic None N/A ymax_anatomic None N/A N/A N/A N/A f write N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A sct.run('sct_crop_image -i data_RPI.nii.gz -o data_RPI_crop.nii.gz -dim 2 -start   zmin_anatomic  -end  zmax_anatomic  ')
f_crop = open('crop.txt', 'w')
f_crop.write(' zmin_anatomic , zmax_anatomic , zmin_seg , zmax_seg ')
f_crop.close()
 N/A N/A N/A N/A f write 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 N/A N/A sct.run('sct_crop_image -i data_RPI.nii.gz -o data_RPI_crop.nii.gz -dim 1,2 -start  ymin_anatomic , zmin_anatomic  -end  ymax_anatomic , zmax_anatomic ')
f_crop = open('crop.txt', 'w')
f_crop.write(' zmin_anatomic , zmax_anatomic , zmin_seg , zmax_seg , ymin_anatomic , ymax_anatomic ')
f_crop.close()
 N/A N/A centerline_propseg_RPI.nii.gz list_d_2 N/A N/A N/A status_1 output_1 N/A N/A sct run N/A N/A N/A N/A N/A N/A sct_label_utils -i  path_i / contrast / subject /centerline_propseg_RPI.nii.gz -t display-voxel N/A nb_1 N/A N/A output_1 find notation N/A int_nb_1 N/A nb_1 10 N/A labels_1 N/A output_1 N/A int_nb_1 N/A N/A N/A f write N/A N/A sct.run('sct_crop_image -i data_RPI_crop.nii.gz -dim 2 -start 2 -end 1 -b 0 -o centerline_propseg_RPI.nii.gz')
sct.run('sct_label_utils -i centerline_propseg_RPI.nii.gz -o centerline_propseg_RPI.nii.gz -t create -x  labels_1 ')
 N/A N/A labels_updown.nii.gz list_d_2 N/A N/A N/A status_2 output_2 N/A N/A sct run N/A N/A N/A N/A N/A N/A sct_label_utils -i  path_i / contrast / subject /labels_updown.nii.gz -t display-voxel N/A nb_2 N/A N/A output_2 find notation N/A int_nb_2 N/A nb_2 10 N/A labels_2 N/A output_2 N/A int_nb_2 N/A N/A N/A f write N/A N/A sct.run('sct_crop_image -i data_RPI_crop.nii.gz -dim 2 -start 2 -end 1 -b 0 -o labels_updown.nii.gz')
sct.run('sct_label_utils -i labels_updown.nii.gz -o labels_updown.nii.gz -t create -x  labels_2 ')
 N/A N/A N/A f write os.remove('data.nii.gz')
os.remove('data_RPI.nii.gz')
os.remove('data_RPI_crop.nii.gz')
os.chdir('../..')
 N/A N/A N/A f close