Commit c6fbe855 authored by Mickaël Cardoso Fonseca's avatar Mickaël Cardoso Fonseca
Browse files

Merge branch 'master' into 'main'

init

See merge request !1
parents 2032d132 b71cf3ac
This diff is collapsed.
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 23 15:09:43 2019
@author: Mariette Bergere
"""
#See exemple of command_file.
#Respect yaml indentation.
# method: str. command_file or command_file_Della_Croce
# a, E: int. angle and error magnitude
# Error_dir: str. AP_ML, AP_DP or ML_DP
import numpy as np
import yaml
import glob
import itertools
def definition_method(data_path):
'''see 2 existing command files'''
File=glob.glob(data_path+"\\command_file"+"*.txt")
if File==[]:
raise Exception ("command_file not found")
else:
method=File[0].replace(data_path+"\\",'')
method=method.replace(".txt",'')
return method
def definition_marker(data_path,method):
'''Takes info of the 1st part of command_file (Markers)'''
Ori=[]
Dir=[]
Seg_name=[]
Mark=[]
file_path=data_path + '\\' + method+'.txt'
if not glob.glob(file_path):
raise Exception ("command_file not found")
else:
with open(file_path, 'r') as file:
command_file = yaml.load_all(file)
for command in command_file:
for k,v in command.items():
if k=='Markers':
for m in range(len(v)):
M=v.items()[m][1].items()
for i in M:
if i[0]=='name':
Mark.append(i[1])
elif i[0]=='dir':
Dir.append(i[1])
elif i[0]=='segment_name':
Seg_name.append(i[1])
elif i[0]=='ori':
Ori.append(i[1])
return (Ori, Dir, Seg_name, Mark)
def definition_combi(data_path):
'''Takes info of the 2nd part of command_file (Error) and creates all the
combinaisons of error possible '''
MARK=definition_marker(data_path, 'command_file' )[3]
Er=[]
Angles=[]
file_path=data_path + '\\' + 'command_file.txt'
if not glob.glob(file_path):
raise Exception ("command_file not found")
else:
with open(file_path, 'r') as file:
command_file = yaml.load_all(file)
for command in command_file:
for k,v in command.items():
if k=='Error':
A=v.items()[0][1].items()
E=v.items()[1][1].items()
for ang in A:
Angles.append(ang[1])
for er in E:
Er.append(er[1])
Error_Succession=[]
Combi=[]
Er_poss=[]
Combi_er=[]
for e in Er:
if e==0:
Er_poss.append([0,e])
else:
for a in Angles:
Er_poss.append([a,e])
for c in itertools.product(Er_poss,repeat=len(MARK)):
Combi_er.append(c)
Error_Succession.append(c)
for c in Combi_er:
Mark_mis=[]
for m in range(len(MARK)):
Mark_mis.append([MARK[m], c[m]])
Combi.append(Mark_mis)
return (Combi, Er_poss, Error_Succession)
def definition_error(a, E, Error_dir):
'''Creates the error vector in the LCS to add to the marker's original values at each frames.'''
# a_cos=abs(np.cos(np.deg2rad(a)))
# a_sin=abs(np.sin(np.deg2rad(a)))
a_cos = np.cos(np.deg2rad(a))
a_sin = np.sin(np.deg2rad(a))
if Error_dir == 'AP_DP':
Error = np.array([[E*a_cos, 0, E*a_sin]])
elif Error_dir == 'AP_ML':
# Error = np.array([[E*a_cos, E*a_sin, 0]])
Error = np.array([[E*a_sin, E*a_cos, 0]])
elif Error_dir == 'ML_DP':
Error = np.array([[0, E*a_cos, E*a_sin]])
return(Error[0])
def definition_combi_Della_Croce(data_path):
'''Takes info of the 2nd part of command_file (Error) and creates all the
combinaisons of error possible '''
MARK=definition_marker(data_path, 'command_file_Della_Croce')[3]
Magn=[]
file_path=data_path + '\\' + 'command_file_Della_Croce.txt'
if not glob.glob(file_path):
raise Exception ("command_file not found")
else:
with open(file_path, 'r') as file:
command_file = yaml.load_all(file)
for command in command_file:
for k,v in command.items():
if k=='Markers':
for m in range(len(v)):
M=v.items()[m][1].items()
for i,j in M:
if i=='misplacement_magnitude':
magn_mark=[]
for magn in range(len(j)):
m=j.items()[magn][1]
if m!='None':
magn_mark.append(j.items()[magn][1])
Magn.append(magn_mark)
file.close()
Er_poss=[]
for er in Magn:
Er_Mark=[[0,0],[0,er[0]],[180,-er[0]],[90,er[1]],[270,-er[1]]]
Er_poss.append(Er_Mark)
Combi=[]
Combi_er=[]
for c in itertools.product(Er_poss[0],Er_poss[1],Er_poss[2],Er_poss[3],Er_poss[4],Er_poss[5],Er_poss[6],Er_poss[7]):#[Er_poss[i] for i in range(len(Er_poss))]):#,Er_poss[1],Er_poss[2],Er_poss[3],Er_poss[4],Er_poss[5],Er_poss[6],Er_poss[7]):#len(MARK)
Combi_er.append(c)
for c in Combi_er:
Mark_mis=[]
for m in range(len(MARK)):
Mark_mis.append([MARK[m], c[m]])
Combi.append(Mark_mis)
return (Combi,Er_poss)
\ No newline at end of file
#%%
import numpy as np
import pandas as pd
from pyCGM2 import btk
import Simplify_acq
import File_Processing
#%%
Data_path = 'C:\\Users\\FONSECMI\\OneDrive - unige.ch\\Projects\\MIS\\App\\1_Data\\'
DataToExport_path = 'C:\\Users\\FONSECMI\\OneDrive - unige.ch\\Projects\\MIS\\App\\2_DataToExport\\'
ExportCsv_path = 'C:\\Users\\FONSECMI\\OneDrive - unige.ch\\Projects\\MIS\\App\\3_InputData\\'
Markers_To_Keep = ['LTOE','LHEE','LMET','LMED','LANK','LTIB',\
'RTOE','RHEE','RMET','RMED','RANK','RTIB','RTTU','RKNE','RTHI',\
'LTTU','LKNE','LTHI','LASI','RASI','LPSI','RPSI']
Metadata_To_Export = ["Bodymass","Height","LeftLegLength","RightLegLength","LeftKneeWidth","RightKneeWidth","LeftAnkleWidth","RightAnkleWidth","LeftSoleDelta","RightSoleDelta","LeftShoulderOffset","LeftElbowWidth","LeftWristWidth","LeftHandThickness","RightShoulderOffset","RightElbowWidth","RightWristWidth","RightHandThickness"]
#%%
# static_file = '01_03000_04617_20180423-SBNNN-VDEF-02.C3D'
# dynamic_file = '01_03000_04617_20180423-GBNNN-VDEF-05.C3D'
static_file = '03517_05339_20201211-SBNNN-VREF-01.C3D'
dynamic_file = '03517_05339_20201211-GBNNN-VREF-06.C3D'
#%% Export kinematics
Angles_to_Export = ['LPelvisAngles_pyCGM2_1', 'RPelvisAngles_pyCGM2_1', 'LHipAngles_pyCGM2_1', 'RHipAngles_pyCGM2_1', 'LKneeAngles_pyCGM2_1', 'RKneeAngles_pyCGM2_1', 'LAnkleAngles_pyCGM2_1', 'RAnkleAngles_pyCGM2_1', 'LFootProgressAngles_pyCGM2_1', 'RFootProgressAngles_pyCGM2_1']
ptk = np.concatenate((Markers_To_Keep, Angles_to_Export))
#%%
Simplify_acq.new_dyn(dynamic_file, ptk, Data_path, DataToExport_path)
acq_dyn = File_Processing.reader(DataToExport_path + dynamic_file)
acq_sta = File_Processing.reader(Data_path + static_file)
# %%
MarkersDyn_df = pd.DataFrame()
MarkersSta_df = pd.DataFrame()
for marker in Markers_To_Keep:
m = acq_dyn.GetPoint(marker).GetValues()
MarkersDyn_df[marker+'_X'] = m[:,0]
MarkersDyn_df[marker+'_Y'] = m[:,1]
MarkersDyn_df[marker+'_Z'] = m[:,2]
m = acq_sta.GetPoint(marker).GetValues()
MarkersSta_df[marker+'_X'] = m[:,0]
MarkersSta_df[marker+'_Y'] = m[:,1]
MarkersSta_df[marker+'_Z'] = m[:,2]
Angles_df = pd.DataFrame()
for angles in Angles_to_Export:
m = acq_dyn.GetPoint(angles).GetValues()
Angles_df[angles+'_X'] = m[:,0]
Angles_df[angles+'_Y'] = m[:,1]
Angles_df[angles+'_Z'] = m[:,2]
# %% export markers to csv
MarkersDyn_df.to_csv(ExportCsv_path+dynamic_file[:-4] + '.csv')
MarkersSta_df.to_csv(ExportCsv_path+static_file[:-4] + '.csv')
Angles_df.to_csv(ExportCsv_path+dynamic_file[:-4]+'_kinematics.csv')
# %%
metadata = acq_sta.GetMetadata()
Metadata = {}
Metadata["Bodymass"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[0]
Metadata["Height"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[1]
Metadata["LeftLegLength"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[4]
Metadata["RightLegLength"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[7]
Metadata["LeftKneeWidth"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[3]
Metadata["RightKneeWidth"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[6]
Metadata["LeftAnkleWidth"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[2]
Metadata["RightAnkleWidth"]=metadata.FindChild("ANALYSIS").value().FindChild("VALUES").value().GetInfo().ToDouble()[5]
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 25 09:23:14 2019
@author: Mariette Bergere
MIS2 project
"""
from pyCGM2 import btk
def reader(file):
reader = btk.btkAcquisitionFileReader()
reader.SetFilename(file)
reader.Update()
acq=reader.GetOutput()
return acq
def writer (acq, save_path, new_filename):
writer = btk.btkAcquisitionFileWriter()
writer.SetInput(acq)
writer.SetFilename(save_path + new_filename)
writer.Update()
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 10 15:52:29 2020
@author: MCDF
"""
import scipy.io
import numpy as np
def calculate_GDI(g):
''' calculate Gait deviation index (Schwartz)
g - kinemtatics of the patient (vector 459*9)
'''
G = scipy.io.loadmat('G.mat')
GG = np.transpose(G['G'])
features = scipy.io.loadmat('features.mat') #matrix of clean values
ff = features['features']
C = GG.dot(ff)
for i in range(len(C)):
if np.all(C[i,:] == np.zeros(len(C[2]))):
CC = C[:i, :]
break
meanC = CC.mean(0)
deltaC = CC
for i in range(len(CC)):
deltaC[i,:] = CC[i,:]-meanC
d = np.sqrt(np.sum(deltaC*deltaC,1))
lnd = np.log(d)
m_lnd = np.mean(lnd)
sd_lnd = np.std(lnd)
Csubject = g.dot(ff)
Cdiff = Csubject - meanC
lnd = np.log(np.sqrt(np.sum(np.sum(Cdiff*Cdiff))))
zlnd = (lnd-m_lnd)/(sd_lnd)
GDI = 100-(10*zlnd)
return GDI
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 12 12:59:41 2020
@author: MCDF
"""
import scipy.io
import numpy as np
def calculate_GPS(Data_patient):
''' calculate GPS
g - kinemtatics of the patient (vector 459*9)
warning: only left leg considered
'''
# G = scipy.io.loadmat('G.mat')
# GG = np.transpose(G['G'])
# features = scipy.io.loadmat('features.mat') #matrix of clean values
# ff = features['features']
Gmean = scipy.io.loadmat('Gmean')
G_m = Gmean['G']
G_mean = np.transpose(G_m.reshape(9,51))
# # prepare patient data [matrix of 15 columns PT,2HF,2KF,2AF,PO,2HA,PR,2HR,2FP] interp to 51 points
# data_f = data[1:,1:13]
# data_ff = data_f.astype(np.float)
# tn = np.linspace(0,50,51) # interpolate into 51 points
# LPelvisAngles_interp = np.zeros((51,3))
# LHipAngles_interp = np.zeros((51,3))
# LKneeAngles_interp = np.zeros((51,1))
# LAnkleAngles_interp = np.zeros((51,1))
# LFootProgAngles_interp = np.zeros((51,1))
# LGC1t = np.linspace(0, 50, len(data[1:,1:4]))
# for i in range(3):
# LPelvisAngles_interp[:,i] = np.interp(tn, LGC1t, data_ff[:,i])
# LHipAngles_interp[:,i] = np.interp(tn, LGC1t, data_ff[:,i+3])
# LKneeAngles_interp[:,0] = np.interp(tn, LGC1t, data_ff[:,6])
# LAnkleAngles_interp[:,0] = np.interp(tn, LGC1t, data_ff[:,9])
# LFootProgAngles_interp[:,0] = np.interp(tn, LGC1t, data_ff[:,11])
#
# Data_patient = np.transpose(np.array([LPelvisAngles_interp[:,0], LHipAngles_interp[:,0], LKneeAngles_interp[:,0], \
# LAnkleAngles_interp[:,0], LPelvisAngles_interp[:,1], LHipAngles_interp[:,1],\
# LPelvisAngles_interp[:,2], LHipAngles_interp[:,2], LFootProgAngles_interp[:,0]]))
# prepare control data [matrix of 15 columns PT,HF,KF,AF,PO,HA,PR,HR,FP]
Data_control = np.transpose(np.array([G_mean[:,0], G_mean[:,3], G_mean[:,6], G_mean[:,7], G_mean[:,1], \
G_mean[:,4], G_mean[:,2], G_mean[:,5], G_mean[:,8]]))
# fig, axs = plt.subplots(3,3)
# axs[0,0].plot(LPelvisAngles_interp[:,0], 'r')
# axs[0,0].plot(Data_Control[:,0], 'b')
# axs[0,1].plot(LPelvisAngles_interp[:,1], 'r')
# axs[0,1].plot(Data_Control[:,1], 'b')
# axs[0,2].plot(LPelvisAngles_interp[:,2], 'r')
# axs[0,2].plot(Data_Control[:,2], 'b')
# axs[1,0].plot( LHipAngles_interp[:,0],'r')
# axs[1,0].plot(Data_Control[:,3], 'b')
# axs[1,1].plot( LHipAngles_interp[:,1],'r')
# axs[1,1].plot(Data_Control[:,4], 'b')
# axs[1,2].plot( LHipAngles_interp[:,2],'r')
# axs[1,2].plot(Data_Control[:,5], 'b')
# axs[2,0].plot( LKneeAngles_interp[:,0],'r')
# axs[2,0].plot(Data_Control[:,6], 'b')
# axs[2,1].plot( LAnkleAngles_interp[:,0],'r')
# axs[2,1].plot(Data_Control[:,7], 'b')
# axs[2,2].plot( LFootProgAngles_interp[:,0],'r')
# axs[2,2].plot(Data_Control[:,8], 'b')
#
# Calculation GPS MAP for left leg (consider only left cycle)
MAP = np.zeros([1,len(G_mean[1])+2])
for n in range(0,len(G_mean[1])):
MAP[:,n] = np.sqrt(np.mean( (Data_control[:,n] - Data_patient[:,n])**2) )
# MAP 15, 16, 17 are Left, Right & Overall GPS
MAP[:,9] = np.sqrt( (MAP[:,0]**2+MAP[:,2]**2+MAP[:,1]**2+MAP[:,3]**2+MAP[:,4]**2+MAP[:,5]**2+MAP[:,6]**2+MAP[:,7]**2+MAP[:,8]**2)/9 )
MAP[:,10] = np.sqrt(np.mean(MAP[:,0:8]**2))
# MAP[15,t] = np.sqrt( (MAP[0,t]**2+MAP[1,t]**2+MAP[3,t]**2+MAP[5,t]**2+MAP[7,t]**2+MAP[8,t]**2+MAP[10,t]**2+MAP[11,t]**2+MAP[13,t]**2)/9 )
# MAP[16,t] = np.sqrt( (MAP[0,t]**2+MAP[2,t]**2+MAP[4,t]**2+MAP[6,t]**2+MAP[7,t]**2+MAP[9,t]**2+MAP[10,t]**2+MAP[12,t]**2+MAP[14,t]**2)/9 )
# MAP[17,t] = np.sqrt(np.mean(MAP[0:15,t]**2))
return MAP
\ No newline at end of file
import pandas as pd
from pyCGM2 import btk
import numpy as np
def acq_to_df(acq, list_angles, ev_fs, ff, xt, tn):
df = pd.DataFrame()
for ang in list_angles:
print(ang)
angle = acq.GetPoint(ang+'Angles')
angle = angle.GetValues()
df[ang + '_x'] = np.interp(tn, xt, angle[ev_fs[0]-ff:ev_fs[1]-ff,0])
df[ang + '_y'] = np.interp(tn, xt, angle[ev_fs[0]-ff:ev_fs[1]-ff,1])
df[ang + '_z'] = np.interp(tn, xt, angle[ev_fs[0]-ff:ev_fs[1]-ff,2])
return df
\ No newline at end of file
<deployment-project plugin="plugin.ezdeploy" plugin-version="1.0">
<configuration file="C:\Users\FONSECMI\OneDrive - unige.ch\Projects\MIS\App\MarkMis.prj" location="C:\Users\FONSECMI\OneDrive - unige.ch\Projects\MIS\App" name="MarkMis" target="target.ezdeploy.standalone" target-name="Application Compiler">
<param.appname>MarkMis</param.appname>
<param.icon />
<param.icons />
<param.version>1.0</param.version>
<param.authnamewatermark>Mickael Fonseca</param.authnamewatermark>
<param.email>mickael.cardosofonseca@hcuge.ch</param.email>
<param.company>Laboratory of Kinesiology</param.company>
<param.summary>blabla</param.summary>
<param.description>blabla</param.description>
<param.screenshot />
<param.guid />
<param.installpath.string>\Laboratory of Kinesiology\MarkMis\</param.installpath.string>
<param.installpath.combo>option.installpath.programfiles</param.installpath.combo>
<param.logo />
<param.install.notes>blabla</param.install.notes>
<param.target.install.notes />
<param.intermediate>${PROJECT_ROOT}\MarkMis\for_testing</param.intermediate>
<param.files.only>${PROJECT_ROOT}\MarkMis\for_redistribution_files_only</param.files.only>
<param.output>${PROJECT_ROOT}\MarkMis\for_redistribution</param.output>
<param.logdir>${PROJECT_ROOT}\MarkMis</param.logdir>
<param.enable.clean.build>false</param.enable.clean.build>
<param.user.defined.mcr.options />
<param.target.type>subtarget.standalone</param.target.type>
<param.support.packages />
<param.web.mcr>true</param.web.mcr>
<param.package.mcr>false</param.package.mcr>
<param.no.mcr>false</param.no.mcr>
<param.web.mcr.name>MyAppInstaller_web</param.web.mcr.name>
<param.package.mcr.name>MyAppInstaller_mcr</param.package.mcr.name>
<param.no.mcr.name>MyAppInstaller_app</param.no.mcr.name>
<param.windows.command.prompt>false</param.windows.command.prompt>
<param.create.log>false</param.create.log>
<param.log.file />
<param.native.matlab>false</param.native.matlab>
<param.checkbox>false</param.checkbox>
<param.example />
<param.help.text>Syntax
test_Matexe -?
test_Matexe input
Input Arguments
-? print help on how to use the application
input input arguments
Description
blabla</param.help.text>
<unset>
<param.icon />
<param.icons />
<param.version />
<param.screenshot />
<param.guid />
<param.installpath.string />
<param.installpath.combo />
<param.logo />
<param.target.install.notes />
<param.intermediate />
<param.files.only />
<param.output />
<param.logdir />
<param.enable.clean.build />
<param.user.defined.mcr.options />
<param.target.type />
<param.support.packages />
<param.web.mcr />
<param.package.mcr />
<param.no.mcr />
<param.web.mcr.name />
<param.package.mcr.name />
<param.no.mcr.name />
<param.create.log />
<param.log.file />
<param.native.matlab />
<param.checkbox />
<param.example />
</unset>
<fileset.main>
<file>${PROJECT_ROOT}\test_Matexe.m</file>
</fileset.main>
<fileset.resources>
<file>${PROJECT_ROOT}\test_Matexe.m</file>
</fileset.resources>
<fileset.package />
<fileset.depfun />
<build-deliverables>
<file location="${PROJECT_ROOT}\MarkMis\for_testing" name="MarkMis.exe" optional="false">C:\Users\FONSECMI\OneDrive - unige.ch\Projects\MIS\App\MarkMis\for_testing\MarkMis.exe</file>
<file location="${PROJECT_ROOT}\MarkMis\for_testing" name="splash.png" optional="false">C:\Users\FONSECMI\OneDrive - unige.ch\Projects\MIS\App\MarkMis\for_testing\splash.png</file>
<file location="${PROJECT_ROOT}\MarkMis\for_testing" name="readme.txt" optional="true">C:\Users\FONSECMI\OneDrive - unige.ch\Projects\MIS\App\MarkMis\for_testing\readme.txt</file>
</build-deliverables>
<workflow />
<matlab>
<root>C:\Program Files\MATLAB\R2021a</root>
<toolboxes>
<toolbox name="neuralnetwork" />
</toolboxes>
<toolbox>
<neuralnetwork>
<enabled>true</enabled>
</neuralnetwork>
</toolbox>
</matlab>
<platform>
<unix>false</unix>
<mac>false</mac>
<windows>true</windows>
<win2k>false</win2k>
<winxp>false</winxp>
<vista>false</vista>
<linux>false</linux>
<solaris>false</solaris>
<osver>10.0</osver>
<os32>false</os32>
<os64>true</os64>
<arch>win64</arch>
<matlab>true</matlab>
</platform>
</configuration>
</deployment-project>
\ No newline at end of file
import numpy as np
import Rotation_Matrix
import Definition
import File_Processing
from pyCGM2 import btk
def move(c3d_path, c3d_filename, Marker_list, Mag_list, Angle_list, Segment_list, Origin_list, sagital, coronal, transversal):
# seg: segment name (e.g. PELVIS, LFEMUR) - <string>
# ori: origin marker (e.g. LHJC, LKJC) - <string>
# marker: marker name (e.g. LASI, LANK) - <string>
# ang: misplacement angle (from 0 to 360) - <int>
# mag: magnitude misplacement - <int>
# plane: plane code of misplacement (options: ML_AP for transversal, ML_DP for sagital, AP_DP for coronal) - <string>
# SEGMENT_origin=Definition.definition_marker(current_path, method)[0][m]
# Error_dir=Definition.definition_marker(current_path, method)[1][m]
# SEGMENT_name=Definition.definition_marker(current_path, method)[2][m]
acq = File_Processing.reader(c3d_path+c3d_filename)
for i in range(len(Marker_list)):
marker = Marker_list[i]
mag = Mag_list[i]
angle = Angle_list[i]
seg = Segment_list[i]
ori = Origin_list[i]
# LASI correction
if marker == 'LASI' and angle == 'Medial':
angle = 'Lateral'
elif marker == 'LASI' and angle == 'Lateral':
angle = 'Medial'
if angle == 'Original':
mag = 0
ang = 0
if marker in sagital:
plane = 'AP_DP'
if angle == 'Anterior':
ang = 0
elif angle == 'Proximal':
ang = 90
elif angle == 'Posterior':
ang = 180
elif angle == 'Distal':
ang = 270
elif marker in coronal:
plane = 'ML_DP'
if angle == 'Medial':
ang = 0
elif angle == 'Proximal':
ang = 90
elif angle == 'Lateral':
ang = 180
elif angle == 'Distal':
ang = 270
elif marker in transversal:
plane = 'AP_ML'
if angle == 'Medial':
ang = 0
elif angle == 'Anterior':
ang = 90
elif angle == 'Lateral':
ang = 180
elif angle == 'Posterior':
ang = 270
if angle != 'Original':
Segment_proximal = seg + '_Z'
Segment_lateral = seg + '_Y'