From a9719346f2cb7ee47e0aadbeaaa5424573315c08 Mon Sep 17 00:00:00 2001 From: Enrique Hernandez <96093685+enriquehdez98@users.noreply.github.com> Date: Fri, 28 Nov 2025 13:05:54 -0600 Subject: [PATCH] Refactor ZIP extraction logic based on volume file existence Moved ZIP extraction logic to check for specific volume files before extraction. --- .../AIBasedSegmentationIn3DSlicer.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Tutorials/STC-SEG-103_AIBasedSegmentationIn3DSlicer/AIBasedSegmentationIn3DSlicer.py b/Tutorials/STC-SEG-103_AIBasedSegmentationIn3DSlicer/AIBasedSegmentationIn3DSlicer.py index 37d8685c..b7049d83 100644 --- a/Tutorials/STC-SEG-103_AIBasedSegmentationIn3DSlicer/AIBasedSegmentationIn3DSlicer.py +++ b/Tutorials/STC-SEG-103_AIBasedSegmentationIn3DSlicer/AIBasedSegmentationIn3DSlicer.py @@ -105,16 +105,18 @@ def test_Slicer4Minute1(self): if not os.path.exists(zip_path): urllib.request.urlretrieve(zip_url, zip_path) - # Extrair ZIP se não estiver extraído - if not os.path.exists(extract_path): - with zipfile.ZipFile(zip_path, 'r') as zip_ref: - zip_ref.extractall(slicer.app.temporaryPath) - # Carregar os volumes prostate_folder = os.path.join(extract_path, "dataset3_ProstateMRI") adc_path = os.path.join(prostate_folder, "msd-prostate-01-adc.nrrd") t2_path = os.path.join(prostate_folder, "msd-prostate-01-t2.nrrd") + # Extrair ZIP se não estiver extraído + if not (os.path.exists(adc_path) and os.path.exists(t2_path)): + with zipfile.ZipFile(zip_path, 'r') as zip_ref: + zip_ref.extractall(slicer.app.temporaryPath) + + + slicer.util.loadVolume(adc_path) slicer.util.loadVolume(t2_path)