def create_cross(contrast):
    # Define list to gather all distances
    list_distances_1 = []
    list_distances_2 = []
    for i in range(0,len(SUBJECTS_LIST)):
        subject = SUBJECTS_LIST[i][0]

        # go to output folder
        print '\nGo to output folder '+ PATH_OUTPUT + '/subjects/'+ subject+ '/' + contrast
        os.chdir(PATH_OUTPUT + '/subjects/' + subject + '/' + contrast )

        #Calculate distances between : (last_label and bottom)  and (first label and top)
        print '\nCalculating distances between : (last_label and bottom)  and (first label and top)...'
        img_label = nibabel.load('labels_vertebral_dilated_reg_2point_crop.nii.gz')
        data_labels = img_label.get_data()
        from msct_image import Image
        nx, ny, nz, nt, px, py, pz, pt = Image('labels_vertebral_dilated_reg_2point_crop.nii.gz').dim
        X, Y, Z = (data_labels > 0).nonzero()
        list_coordinates = [([X[i], Y[i], Z[i], data_labels[X[i], Y[i], Z[i]]]) for i in range(0, len(X))]
        for i in range(len(list_coordinates)):
            if list_coordinates[i][3] == 1:
                coordinates_first_label = list_coordinates[i]
            if list_coordinates[i][3] == 20:
                coordinates_last_label = list_coordinates[i]
        # Distance 1st label top
        distance_1 = nz - coordinates_first_label[2] - 1
        distance_2 = nz - 1 - coordinates_last_label[2]

        # Complete list to gather all distances
        list_distances_1.append(distance_1)
        list_distances_2.append(distance_2)

        # Create a cross on each subject at first and last labels
        print '\nCreating a cross at first and last labels...'
        os.system('sct_create_cross.py -i data_RPI_crop_normalized_straight_crop.nii.gz -x ' +str(int(round(nx/2.0)))+' -y '+str(int(round(ny/2.0)))+ ' -s '+str(coordinates_last_label[2])+ ' -e '+ str(coordinates_first_label[2]))

        # Write into a txt file the list of distances
        # os.chdir('../')
        # f_distance = open('list_distances.txt', 'w')
        # f_distance.write(str(distance_1))
        # f_distance.write(' ')
        # f_distance.write(str(distance_2))
        # f_distance.write('\n')

    # Calculate mean cross height for template and create file of reference
    print '\nCalculating mean cross height for template and create file of reference'
    mean_distance_1 = int(round(sum(list_distances_1)/len(list_distances_1)))
    mean_distance_2 = int(round(sum(list_distances_2)/len(list_distances_2)))
    L = height_of_template_space - 2 * mean_distance_2
    H = height_of_template_space - 2 * mean_distance_1
    os.chdir(path_sct+'/dev/template_creation')
    os.system('sct_create_cross.py -i template_landmarks-mm.nii.gz -x ' +str(x_size_of_template_space/2)+' -y '+str(y_size_of_template_space/2)+ ' -s '+str(L)+ ' -e '+ str(H))



# push into template space
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/dev/template_preprocessing/pipeline_template.py/create_cross/swapped operands of `-`