def __init__(self, directory, zip=False): """ Parameters ---------- directory : str The path to the images. zip : bool Whether or not `directory` points to a zip file. """ super().__init__() if not zip: # load all DICOM files for basefile in os.listdir(directory): file = osp.join(directory, basefile) try: image = WLImage(file) except: pass # not a DICOM file else: self.append(image) else: files = load_zipfile(directory, read=True) for file in files: try: image = WLImage(file) except: pass # not a DICOM file else: self.append(image)
def load_zip(self, zip_file): """Load VMAT images from a ZIP file that contains both images. .. versionadded:: 0.8 """ zfiles = load_zipfile(zip_file) images = [BytesIO(zfiles.read(name)) for name in zfiles.namelist()] self.load_images(images, names=zfiles.namelist())