Skip to content

Commit a971934

Browse files
Refactor ZIP extraction logic based on volume file existence
Moved ZIP extraction logic to check for specific volume files before extraction.
1 parent b228ce1 commit a971934

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)