def loadScans(self, dataFolder):
        """Get all the scans under a folder and turn to the first one"""
        self.initPb("Making sure input valid", "Loading scans")

        # 1. ensure valid input
        if dataFolder is None or len(dataFolder) == 0:
            slicer.util.errorDisplay(
                "Please select a Data Folder first!", autoCloseMsec=5000)
            return

        if not osp.exists(dataFolder):
            slicer.util.errorDisplay(
                f"The Data Folder( {dataFolder} ) doesn't exist!",
                autoCloseMsec=2000)
            return

        self.clearScene()

        self.setPb(0.2, "Searching for scans")

        # 2. list files in assigned directory
        self._dataFolder = dataFolder
        paths = [
            p for p in os.listdir(self._dataFolder)
            if p[p.find("."):] in self.file_suffix
        ]
        paths = [
            p for p in paths if p.split(".")[0][-len("_label"):] != "_label"
        ]
        paths.sort()
        self._scanPaths = [osp.join(self._dataFolder, p) for p in paths]

        if len(paths) == 0:
            self.closePb()
            slicer.util.errorDisplay(
                f"No file ending with {' or '.join(self.file_suffix)} is found under {self._dataFolder}.\nDid you chose the wrong folder?"
            )
            return
        self.setPb(0.5,
                   f"Found {len(paths)} scans in folder {self._dataFolder}")

        self._currScanIdx, self._finishedPaths = self.getProgress()
        self.updateProgressWidgets()

        if len(set(self._scanPaths) - set(
                self._finishedPaths)) == 0 and self.ui.skipFinished.checked:
            self.closePb()
            slicer.util.delayDisplay(
                f"All {len(self._scanPaths)} scans have been annotated!\nUncheck Skip Finished Scans to browse through them.",
                4000, )
            return

        self.setPb(0.6, "Loading Scan and label")
        self._currScanIdx -= 1
        found = self.nextScan(silentFail=True)
        if not found:
            self._currScanIdx += 2
            self.prevScan()

        self.ui.finishScanButton.setEnabled(True)
        logging.info(
            f"All scans found under {self._dataFolder} are{','.join([' '+osp.basename(p) for p in self._scanPaths])}"
        )
Get all the scans under a folder and turn to the first one
EISeg/med3d/EISegMed3D/EISegMed3D.py