<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def __ReadFromDirectory(self, datapath, dicom_expected=None):
 """This function is actually the ONE, which reads 3D data from file :param datapath: path to file :return: tuple (data3d, metadata) """

        start = self.start
        stop = self.stop
        step = self.step
        kwargs = self.kwargs
        gui = self.gui

        if (dicom_expected is not False) and (dcmr.is_dicom_dir(datapath)):  # reading dicom
            logger.debug('Dir - DICOM')
            logger.debug("dicom_expected " + str(dicom_expected))
            reader = dcmr.DicomReader(datapath,
                                      series_number=self.series_number,
                                      gui=gui,
                                      **kwargs)  # qt_app=None, gui=True)
            data3d = reader.get_3Ddata(start, stop, step)
            metadata = reader.get_metaData()
            metadata['series_number'] = reader.series_number
            metadata['datadir'] = datapath
            self.overlay_fcn = reader.get_overlay
        else:  # reading image sequence
            logger.debug('Dir - Image sequence')

            logger.debug('Getting list of readable files...')
            flist = []
            try:
                import SimpleITK as Sitk
            except ImportError as e:
                logger.error("Unable to import SimpleITK. On Windows try version 1.0.1")
            for f in os.listdir(datapath):
                try:
                    Sitk.ReadImage(os.path.join(datapath, f))
                except Exception as e:
                    logger.warning("Cant load file: " + str(f))
                    logger.warning(e)
                    continue
                flist.append(os.path.join(datapath, f))
            flist.sort()

            logger.debug('Reading image data...')
            image = Sitk.ReadImage(flist)
            logger.debug('Getting numpy array from image data...')
            data3d = Sitk.GetArrayFromImage(image)
            metadata = _metadata(image, datapath)
        return data3d, metadata