Просмотр исходного кода

Small changes in the handling of directories

zahra 1 год назад
Родитель
Сommit
2b73fbed1a
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      python/extract_suv_from_mask.py

+ 4 - 3
python/extract_suv_from_mask.py

@@ -48,8 +48,9 @@ def organ_percentile(img, mask, level, p):
     
 def main():  
     
-    path = r"C:/Users/strah/OneDrive/Namizje/Raziskave/Melanoma/Retrospective/"           #path to folder in which patient images are
-    inputCSV = os.path.join(path, 'cases_retroMManon.csv')                          #input csv file that has the path to each patient image
+    # Get the current script's directory
+    current_dir = os.path.dirname(os.path.abspath(__file__))
+    inputCSV = os.path.join(current_dir, "..", 'data', 'cases_retroMManon.csv')                          #input csv file that has the path to each patient image
     
     #Returns concatinated sequnces of evenly spaced numbers over a specified interval - for SUV percentile
     pv=numpy.concatenate((numpy.linspace(10,50,5),
@@ -108,7 +109,7 @@ def main():
     Names=numpy.concatenate((Names,col_names))
     #make a dataframe to write the data than in excel - that can be read by another script
     df=pd.DataFrame(alldata,columns=Names)
-    df.to_excel('C:/Users/strah/OneDrive/Namizje/Raziskave/Melanoma/Retrospective/percentilesAnon.xlsx', index=None) #path to where you want to save excel
+    df.to_excel('..\\data\\percentilesAnon.xlsx', index=None) #path to where you want to save excel
     print("Done.")
 
 if __name__ == '__main__':