Skip to content

Commit 8e214da

Browse files
authored
Merge pull request #13 from enriquehdez98/patch-1
Refactor ZIP extraction logic based on volume file existence
2 parents b228ce1 + a971934 commit 8e214da

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Tutorials/STC-SEG-103_AIBasedSegmentationIn3DSlicer/AIBasedSegmentationIn3DSlicer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,18 @@ def test_Slicer4Minute1(self):
105105
if not os.path.exists(zip_path):
106106
urllib.request.urlretrieve(zip_url, zip_path)
107107

108-
# Extrair ZIP se não estiver extraído
109-
if not os.path.exists(extract_path):
110-
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
111-
zip_ref.extractall(slicer.app.temporaryPath)
112-
113108
# Carregar os volumes
114109
prostate_folder = os.path.join(extract_path, "dataset3_ProstateMRI")
115110
adc_path = os.path.join(prostate_folder, "msd-prostate-01-adc.nrrd")
116111
t2_path = os.path.join(prostate_folder, "msd-prostate-01-t2.nrrd")
117112

113+
# Extrair ZIP se não estiver extraído
114+
if not (os.path.exists(adc_path) and os.path.exists(t2_path)):
115+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
116+
zip_ref.extractall(slicer.app.temporaryPath)
117+
118+
119+
118120
slicer.util.loadVolume(adc_path)
119121
slicer.util.loadVolume(t2_path)
120122

0 commit comments

Comments
 (0)