From c8702f318e4ecf40a6d40a6a4606ea2c923c8da0 Mon Sep 17 00:00:00 2001 From: Ananth Reddy Date: Mon, 1 Nov 2021 09:44:51 -0400 Subject: [PATCH 1/2] Chnages to copy DICOM files to the destination. --- modules/workflows/ModalityGrouping.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/workflows/ModalityGrouping.py b/modules/workflows/ModalityGrouping.py index 0aa6015..0593b8d 100644 --- a/modules/workflows/ModalityGrouping.py +++ b/modules/workflows/ModalityGrouping.py @@ -6,7 +6,7 @@ def modality_split(cold_extraction_path, modality_split_path): # iterating through all the files in cold extraction - for root, files in os.walk(cold_extraction_path): + for root, dirs, files in os.walk(cold_extraction_path): for file in files: if file.endswith('.dcm'): dcm_filename = root+'/'+file @@ -15,14 +15,15 @@ def modality_split(cold_extraction_path, modality_split_path): dcm_file = pyd.dcmread(dcm_filename) dcm_modality = dcm_file.Modality - print (dcm_modality, dcm_only_folder) + # print (dcm_modality, dcm_only_folder) isExist = os.path.exists(modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)) if not isExist: os.makedirs(modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)) - shutil.copy2(src=cold_extraction_path+str(dcm_path), dst=modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)+'/'+str(dcm_path.split('/')[-1])) + print (cold_extraction_path+str(dcm_path), modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)+'/'+str(dcm_path.split('/')[-1])) + shutil.copy2(src=cold_extraction_path+str(dcm_path), dst=modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)+'/'+str(dcm_path.split('/')[-1])) if __name__ == "__main__": - cold_extraction_path = sys.argv[1] - modality_split_path = sys.argv[2] + cold_extraction_path = '/home/aredd30/larynx_extract/cold_extraction/' # sys.argv[1] + modality_split_path = '/home/aredd30/larynx_extract/modality_split/' # sys.argv[2] print ('Starting Modality Grouping') modality_split(cold_extraction_path, modality_split_path) From eaf288cc5ad7109f8e5043a00ed737d52ba013f2 Mon Sep 17 00:00:00 2001 From: Ananth Reddy Date: Mon, 1 Nov 2021 13:34:53 -0400 Subject: [PATCH 2/2] Remove the hard-coded values. --- modules/workflows/ModalityGrouping.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/workflows/ModalityGrouping.py b/modules/workflows/ModalityGrouping.py index 0593b8d..4d1cf1e 100644 --- a/modules/workflows/ModalityGrouping.py +++ b/modules/workflows/ModalityGrouping.py @@ -23,7 +23,7 @@ def modality_split(cold_extraction_path, modality_split_path): shutil.copy2(src=cold_extraction_path+str(dcm_path), dst=modality_split_path+str(dcm_modality)+'/'+str(dcm_only_folder)+'/'+str(dcm_path.split('/')[-1])) if __name__ == "__main__": - cold_extraction_path = '/home/aredd30/larynx_extract/cold_extraction/' # sys.argv[1] - modality_split_path = '/home/aredd30/larynx_extract/modality_split/' # sys.argv[2] + cold_extraction_path = sys.argv[1] + modality_split_path = sys.argv[2] print ('Starting Modality Grouping') modality_split(cold_extraction_path, modality_split_path)