def testExecute(self): """ """ self.run() # Checks that there are no error messages plugin = self.getPlugin() plugin.killAllWorkers() if EDVerbose.isVerboseDebug(): plugin.cleanDispMat(plugin.getWorkingDirectory()) else: plugin.cleanDispMat() # Checking obtained results xsDataResultSPD = plugin.getDataOutput() outputData = EDF( xsDataResultSPD.getCakedFile().getPath().getValue()).GetData(0) referenceData = EDF( os.path.join(self.getTestsDataImagesHome(), self.refOutput)).GetData(0) relError = 100 * (abs(outputData - referenceData).max() - referenceData.min()) / (referenceData.max() - referenceData.min()) absError = abs(outputData - referenceData).max() if relError > 5: EDAssert.lowerThan( relError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f" % (relError, absError)) else: EDAssert.lowerThan( absError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f " % (relError, absError))
def testExecute(self): """ """ self.run() # Checks that there are no error messages plugin = self.getPlugin() plugin.killAllWorkers() # if EDVerbose.isVerboseDebug(): # plugin.cleanDispMat(plugin.getWorkingDirectory()) # else: # plugin.cleanDispMat() # Checking obtained results xsDataResultSPD = plugin.getDataOutput() outputData = EDF(xsDataResultSPD.getCakedFile().getPath().getValue()).GetData(0) referenceData = EDF(os.path.join(self.getTestsDataImagesHome(), self.refOutput)).GetData(0) # print outputData.shape # print referenceData.shape relError = 100 * (abs(outputData - referenceData).max() - referenceData.min()) / (referenceData.max() - referenceData.min()) absError = abs(outputData - referenceData).max() if relError > 5: EDAssert.lowerThan(relError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f" % (relError, absError)) else: EDAssert.lowerThan(absError, 5, "Maximum relative error = %.2f%%, Maximum Absolute Error %.2f " % (relError, absError))
def edf(self, x_start=0, x_end=0, x_step=1, y_start=0, y_end=0, y_step=1, z_start=0, z_end=0, z_step=1): """ Read 3-D tomographic projection data from an EDF (ESRF) file. Parameters file_name : str Input edf file. x_start, x_end, x_step : scalar, optional Values of the start, end and step of the slicing for the whole array. y_start, y_end, y_step : scalar, optional Values of the start, end and step of the slicing for the whole array. z_start, z_end, z_step : scalar, optional Values of the start, end and step of the slicing for the whole array. Returns out : array Returns the data as a matrix. """ # Read data from file. f = EdfFile(self.file_name, access='r') dic = f.GetStaticHeader(0) tmpdata = np.empty((f.NumImages, int(dic['Dim_2']), int(dic['Dim_1']))) for (i, ar) in enumerate(tmpdata): tmpdata[i::] = f.GetData(i) num_z, num_y, num_x = np.shape(tmpdata) if x_end is 0: x_end = num_x if y_end is 0: y_end = num_y if z_end is 0: z_end = num_z # Construct dataset from desired y. dataset = tmpdata[z_start:z_end:z_step, y_start:y_end:y_step, x_start:x_end:x_step] return dataset
def process(self, _edObject=None): EDPluginExec.postProcess(self) EDVerbose.DEBUG("*** EDPluginChiToEDFv1_0.process") # Read the Chi file pyStrPathToChiFile = self.getDataInput().getChiFile().getPath( ).getValue() pyNumpyArray = numpy.loadtxt(pyStrPathToChiFile, skiprows=4) # Prepare the header dictionary self.m_edDictionaryHeader = {} for xsDataKeyValuePair in self.getDataInput().getHeader( ).getKeyValuePair(): key = xsDataKeyValuePair.getKey().getValue() value = xsDataKeyValuePair.getValue().getValue() self.m_edDictionaryHeader[str(key)] = str(value) # Save it as an EDF file if self.getDataInput().getOutputPathEDF() is not None: strOutputPath = self.getDataInput().getOutputPathEDF().getPath( ).getValue() else: strOutputPath = self.getWorkingDirectory() if strOutputPath is None: strOutputPath = os.getcwd() if os.path.exists(strOutputPath): if os.path.isfile(strOutputPath): self._strEDFFile = strOutputPath else: #it is a directory, I guess self._strEDFFile = os.path.join( strOutputPath, os.path.splitext( os.path.basename(self.getDataInput().getChiFile(). getPath().getValue()))[0] + ".edf") else: #strOutputPath does not exist if strOutputPath.endswith("/"): try: os.makedirs(strOutputPath, int("777", 8)) except IOError: raise IOError, "Unable to create directory named %s, please chech the rights or the input parameters." % strOutputPath self._strEDFFile = os.path.join( strOutputPath, os.path.splitext( os.path.basename(self.getDataInput().getChiFile(). getPath().getValue()))[0] + ".edf") else: #it will be a file, the create the upper directory if needed upperDir = os.path.dirname(strOutputPath) if not os.path.isdir(upperDir): try: os.makedirs(upperDir, int("777", 8)) except IOError: raise IOError, "Unable to create directory named %s, please chech the rights or the input parameters." % upperDir self._strEDFFile = strOutputPath print self._strEDFFile edfFile = EdfFile(self._strEDFFile) edfFile.WriteImage(self.m_edDictionaryHeader, pyNumpyArray)
def newFile(self, filename="test", size=(0, 0), metadata={}): """this is a method to create a new empty file @param filename: name of the file to create, the size and the extension will be added. @type filename: string @type size: 2-tuple of integers @param size: the size of the image to create """ if len(size) != 2: EDVerbose.error("Error in the size of the size-tuple") raise Exception("Error in the size of the size-tuple") if size[0] < 0: EDVerbose.error("Error in the X part of the size tuple") raise Exception("Error in the X part of the size tuple") if size[1] < 0: EDVerbose.error("Error in the Y part of the size tuple") raise Exception("Error in the Y part of the size tuple") emptyNParray = numpy.zeros(size, dtype="float32") self.data[filename] = emptyNParray self.headers[filename] = metadata self.size[filename] = size fullFilename = "%sSize%ix%i.edf" % ((filename, ) + size) if os.path.isfile(fullFilename): EDVerbose.warning("Warning, I am going to overwrite the file %s " % fullFilename) self.synchronizeOn() try: self.edf[filename] = EdfFile(fullFilename) self.data[filename] = self.edf[filename].GetData(0) self.headers[filename] = self.edf[filename].GetHeader(0) except Exception: EDVerbose.error("[ERROR] in reading file %s" % filename) self.synchronizeOff() if self.data[filename].shape != size: self.data[filename] = emptyNParray self.headers[filename] = metadata else: self.synchronizeOn() try: self.edf[filename] = EdfFile(fullFilename) self.edf[filename].WriteImage(self.headers[filename], self.data[filename], Append=0) except Exception: EDVerbose.error("[ERROR] in opening and creating file %s" % filename) self.synchronizeOff()
def edf2(self, x_start=0, x_end=0, x_step=1, y_start=0, y_end=0, y_step=1): """ Read 2-D tomographic projection data from an EDF (ESRF) file. Parameters file_name : str Input edf file. x_start, x_end, x_step : scalar, optional Values of the start, end and step of the slicing for the whole array. y_start, y_end, y_step : scalar, optional Values of the start, end and step of the slicing for the whole array. Returns out : array Output 2-D matrix as numpy array. """ try: # Read data from file. f = EdfFile(self.file_name, access='r') dic = f.GetStaticHeader(0) tmpdata = np.empty((int(dic['Dim_2']), int(dic['Dim_1']))) tmpdata[::] = f.GetData(0) num_y, num_x = np.shape(tmpdata) if x_end is 0: x_end = num_x if y_end is 0: y_end = num_y array = tmpdata[y_start:y_end:y_step, x_start:x_end:x_step] except KeyError: self.logger.error( "FILE DOES NOT CONTAIN A VALID TOMOGRAPHY DATA SET") array = None return array
def process(self, _edObject=None): EDPluginExec.process(self) EDVerbose.DEBUG("*** EDPluginEDFReadHeaderv1_0.process") # Read the header contents and put it into an dictionary edStringPathToInputFile = self.getDataInput().getEdfFile().getPath( ).getValue() pyFileDescriptor = open(edStringPathToInputFile, "r") edfFile = EdfFile(pyFileDescriptor) pyFileDescriptor.close() iNumberOfImages = edfFile.GetNumImages() if (iNumberOfImages == 0): edStringErrorMessage = EDMessage.ERROR_UNEXPECTED_01 % ( self.getPluginName() + ".preProcess: No images in file " + edStringPathToInputFile) EDVerbose.error(edStringErrorMessage) self.addErrorMessage(edStringErrorMessage) raise RuntimeError, edStringErrorMessage #if ( iNumberOfImages > 1 ): # pass #EDVerbose.warning( "Warning! More than one image in file " + edStringPathToInputFile ", reading header from first image" ) self.m_edDictionaryHeader = edfFile.GetHeader(0)
def edf2(self, x_start=0, x_end=0, x_step=1, y_start=0, y_end=0, y_step=1): """ Read 2-D tomographic projection data from an EDF (ESRF) file. Parameters file_name : str Input edf file. x_start, x_end, x_step : scalar, optional Values of the start, end and step of the slicing for the whole array. y_start, y_end, y_step : scalar, optional Values of the start, end and step of the slicing for the whole array. Returns out : array Output 2-D matrix as numpy array. """ # Read data from file. f = EdfFile(self.file_name, access='r') dic = f.GetStaticHeader(0) tmpdata = np.empty((int(dic['Dim_2']), int(dic['Dim_1']))) tmpdata[::] = f.GetData(0) num_y, num_x = np.shape(tmpdata) if x_end is 0: x_end = num_x if y_end is 0: y_end = num_y return tmpdata[y_start:y_end:y_step, x_start:x_end:x_step]
def writeData(self): if self.fileName.endswith('.edf'): fileEdf = EdfFile(self.fileName, access='wb') fileEdf.WriteImage({}, self.data) if self.fileName.endswith('.mat'): NameFile = self.fileName.split('/')[-1] NameFile = NameFile.split('.')[0] sio.savemat(self.fileName, {NameFile: self.data}) if self.fileName.endswith('.tiff'): tifImage = TiffIO.TiffIO(self.fileName, 'wb+') tifImage.writeImage(self.data) if self.fileName.endswith('.png'): scipy.misc.imsave(self.fileName, self.data) if self.fileName.endswith('.dcm'): write_dicom(self.data, self.fileName) if self.fileName.endswith('.npy'): np.save(self.fileName, self.data)
def getData(self): if (self.fileName.endswith('.raw') or self.fileName.endswith('.RAW') or self.fileName.endswith('.img')): File = open(str(self.fileName), "rb") size = os.path.getsize(str(self.fileName)) / 4. self.width = int(size**.5) self.height = self.width self.currentSlice = np.fromfile(File, dtype='<f4') self.currentSlice.resize(self.height, self.width) elif (self.fileName.endswith('.edf') or self.fileName.endswith('.EDF')): fileEdf = EdfFile(str(self.fileName), access='rb') self.currentSlice = fileEdf.GetData(0) elif (self.fileName.endswith('.DOWN') or self.fileName.endswith('.UP')): fileEdf = EdfFile(str(self.fileName), access='rb') self.currentSlice = fileEdf.GetData(0) elif (self.fileName.endswith('.tif') or self.fileName.endswith('.TIF') or self.fileName.endswith('.TIFF') or self.fileName.endswith('.tiff')): fileTif = TiffIO(str(self.fileName), mode='rb') self.currentSlice = fileTif.getImage(0) elif (self.fileName.endswith('.png') or self.fileName.endswith('.PNG')): filePng = mpimg.imread(self.fileName) self.currentSlice = filePng elif (self.fileName.endswith('.dcm') or self.fileName.endswith('.DCM')): image = dicom.read_file(str(self.fileName), force=True) self.currentSlice = image.pixel_array elif (self.fileName.endswith('.mat') or self.fileName.endswith('.MAT')): image = sio.loadmat(self.fileName) self.currentSlice = image[image.keys()[0].keys()[0]] else: image = dicom.read_file(str(self.fileName), force=True) self.currentSlice = image return self.currentSlice
# Synthetic data l = 256 x = generate_synthetic_data(l) # Projection operator and projections data, with noise H = build_projection_operator(l, l/5) y = H * x.ravel()[:, np.newaxis] y += 2*np.random.randn(*y.shape) y[y<0] = 0 y = y.reshape((l/5, l)) y = y.astype(np.float32) # Write EdfFile with float32 data phantom = EdfFile("phantom_float.edf") for line in y: lines = np.tile(line, (3, 1)) print "writing", lines.shape phantom._WriteImage({}, lines, DataType="FloatValue", Append=1) #phantom.WriteImage({}, lines) phantom._EdfFile__makeSureFileIsClosed() y *= 2**15 / y.max() y = y.astype(np.uint16) # Write EdfFile with uint16 data phantom = EdfFile("phantom.edf")
def saveDiffractionImage(self, filename, colorMaps, colorMapName, maskedPixelInfo, pixel1X=None, pixel1Y=None, pixel2X=None, pixel2Y=None, lowerBound=0, upperBound=1, logScale=None, invert=None, drawQLines=None, drawdQLines=None, QData=None, calibrationData=None, drawPeaks=None, peakList=None, qLinesColor=None, dQLinesColor=None, peakLinesColor=None): # save EDF data specially if getextension(filename) == ".edf": edf = EdfFile(filename) #You can write any relevant information in the dictionnary. edf.WriteImage( { 'Title': "Edf file converted by the Area Diffraction Machine" }, Numeric.transpose(self.theDiffractionData.data), DataType="SignedInteger", Append=0) del edf # to force file close return # otherwise, try to save it using the PIL image = self.getDiffractionImage(colorMaps, colorMapName, maskedPixelInfo, None, None, None, None, None, None, lowerBound, upperBound, logScale, invert) if drawQLines or drawdQLines: if QData == None: raise Exception( "Cannot save the diffraction data until a q list is given." ) if calibrationData == None: raise Exception( "Cannot save the diffraction data until the calibration Data is given." ) if drawQLines: if qLinesColor == None: raise Exception( 'Cannot add q lines to the saved image until the q line color is set.' ) for Q, dQ in QData.getAllQPairs(): MakeDiffractionImage.addConstantQLineDiffractionImage( image, Q, calibrationData, qLinesColor) if drawdQLines: if dQLinesColor == None: raise Exception( 'Cannot add delta q lines to the saved image until the delta q line color is set.' ) for Q, dQ in QData.getAllQPairs(): MakeDiffractionImage.addConstantQLineDiffractionImage( image, Q - dQ, calibrationData, dQLinesColor) MakeDiffractionImage.addConstantQLineDiffractionImage( image, Q + dQ, calibrationData, dQLinesColor) if drawPeaks and peakList != None: if peakLinesColor == None: raise Exception( "Cannot add peaks to the saved iamge until the peak color is set." ) MakeDiffractionImage.addPeaksDiffractionImage( image, peakList, peakLinesColor) # by default, return entire image if pixel1X != None and pixel1Y != None and pixel2X != None and pixel2Y != None: image = image.crop( (min(int(pixel1X), int(pixel2X)), min(int(pixel1Y), int(pixel2Y)), max(int(pixel1X), int(pixel2X)), max(int(pixel1Y), int(pixel2Y)))) try: image.save(filename) except Exception, e: raise UserInputException( "Cannot save image: %s has an unknown file extension" % filename)
# Synthetic data l = 256 x = generate_synthetic_data(l) # Projection operator and projections data, with noise H = build_projection_operator(l, l / 5) y = H * x.ravel()[:, np.newaxis] y += 2 * np.random.randn(*y.shape) y[y < 0] = 0 y = y.reshape((l / 5, l)) y = y.astype(np.float32) # Write EdfFile with float32 data phantom = EdfFile("phantom_float.edf") for line in y: lines = np.tile(line, (3, 1)) print "writing", lines.shape phantom._WriteImage({}, lines, DataType="FloatValue", Append=1) #phantom.WriteImage({}, lines) phantom._EdfFile__makeSureFileIsClosed() y *= 2**15 / y.max() y = y.astype(np.uint16) # Write EdfFile with uint16 data phantom = EdfFile("phantom.edf")
def set(self, value=0, filename="test.edf", position=(0, 0)): """ This is the set method that will first ensure that the data are available #then set a lock on it and finally #No more write the data #before unlocking. #No more @param: value value of the pixel to set @type value: probably float but can be any figure @param filename: name of the file to be processed @type filename: string @param position: the position of the pixel to modify @type position: 2-tuple of integers """ if not isinstance(value, float): EDVerbose.error("ERROR The value %s is not a float" % value) raise Exception("ERROR The value %s is not a float" % value) if not (isinstance(filename, str) or isinstance(filename, unicode)): EDVerbose.error("ERROR The filename variable %s is not a string " % filename) raise Exception("ERROR The filename variable %s is not a string " % filename) if not isinstance(position, tuple): EDVerbose.error("ERROR The position variable %s is not a tuple " % position) raise Exception("ERROR The position variable %s is not a tuple " % position) if len(position) != 2: EDVerbose.error("ERROR in the size of the position-tuple") raise Exception("ERROR in the size of the position-tuple") if position[0] < 0: EDVerbose.error("ERROR in the X part of the position-tuple") raise Exception("ERROR in the X part of the position-tuple") if position[1] < 0: EDVerbose.error("ERROR in the Y part of the position-tuple") raise Exception("ERROR in the Y part of the position-tuple") if not self.data.has_key(filename): EDVerbose.warning( "ERROR, the destination image %s is not in the list of images tracked : %s" % (filename, self.data.keys())) pystrDirname, pystrFilename = os.path.split(filename) fileInDir = [] for onefile in os.listdir(pystrDirname): if onefile.find("%sSize" % pystrFilename) == 0: if onefile[-4:].lower() == ".edf": XxY = onefile.split("Size")[-1][:-4] try: size = tuple( [int(i) for i in tuple(XxY.split("x"))]) except Exception: size = None if size: fileInDir.append(onefile) if len(fileInDir) > 1: EDVerbose.warning( "ERROR, for %s, I found too many images corresponding to what you are looking for : %s" % (filename, fileInDir)) raise Exception( "ERROR, I found too many images corresponding to what you are looking for : %s" % (filename, fileInDir)) elif len(fileInDir) == 1: EDVerbose.warning( "WARNING, As The file %s exists, I will try to read it. The expected size is %s" % (filename, size)) self.size[filename] = size fullFilename = "%sSize%ix%i.edf" % ((filename, ) + size) self.headers[filename] = {} self.data[filename] = numpy.zeros(size, dtype="float32") self.synchronizeOn() try: self.edf[filename] = EdfFile(fullFilename) self.headers[filename] = self.edf[filename].GetHeader(0) self.data[filename] = self.edf[filename].GetData(0) except Exception: EDVerbose.warning( "ERROR in reading file %s: Reintializing it" % filename) self.edf[filename] = EdfFile(fullFilename) self.data[filename] = numpy.zeros(size, dtype="float32") self.headers[filename] = {} self.synchronizeOff() if self.data[filename].shape != size: self.data[filename] = numpy.zeros(size, dtype="float32") self.headers[filename] = {} else: EDVerbose.error( "ERROR, the destination image %s is not in the list of images tracked : %s" % (filename, self.data.keys())) raise Exception( "ERROR, the destination image %s is not in the list of images tracked : %s" % (filename, self.data.keys())) if position[0] > self.data[filename].shape[0]: EDVerbose.error( "ERROR in the X part of the position-tuple: too large %i > %i" % (position[0], npArray.shape[0])) raise Exception( "ERROR in the X part of the position-tuple: too large %i > %i" % (position[0], npArray.shape[0])) if position[1] > self.data[filename].shape[1]: EDVerbose.error( "ERROR in the Y part of the position-tuple: too large %i > %i" % (position[1], npArray.shape[1])) raise Exception( "ERROR in the Y part of the position-tuple: too large %i > %i" % (position[1], npArray.shape[1])) self.data[filename][position[0], position[1]] = value self.synchronizeOn() try: self.edf[filename].WriteImage(self.headers[filename], self.data[filename], Append=0) except Exception: EDVerbose.error("ERROR in writing image %s at position %s" % (filename, position)) self.synchronizeOff()
def process(self, _edObject=None): EDPluginControl.process(self) EDVerbose.DEBUG("EDPluginBioSaxsMetadatav1_0.process") if not os.path.isfile(self.strInputImage): EDVerbose.WARNING("The given input file does not exist !!!") header = {} else: header = EdfFile(self.strInputImage).GetHeader(0) for key in EDUtilsBioSaxs.TRANSLATION: if key in dir(self) and self.__getattribute__(key) is None: if EDUtilsBioSaxs.TRANSLATION[key] in header: if key in EDUtilsBioSaxs.FLOAT_KEYS: setattr( self, key, float(header[EDUtilsBioSaxs.TRANSLATION[key]])) else: setattr(self, key, header[EDUtilsBioSaxs.TRANSLATION[key]]) if self.strOutputImage is not None: if os.path.abspath(self.strOutputImage) != os.path.abspath( self.strInputImage): shutil.copy(self.strInputImage, self.strOutputImage) keyToUpgrade = [] for key in EDUtilsBioSaxs.TRANSLATION: if key in dir(self) and self.__getattribute__(key) is None: if EDUtilsBioSaxs.TRANSLATION[key] not in header: keyToUpgrade.append(key) else: if key in EDUtilsBioSaxs.FLOAT_KEYS: oneHeader = float( header[EDUtilsBioSaxs.TRANSLATION[key]]) else: oneHeader = header[EDUtilsBioSaxs.TRANSLATION[key]] oneValue = eval("self.%s" % key) EDVerbose.DEBUG( "key: %s value_header=%s(%s) value_extra=%s(%s)" % (key, oneHeader, oneHeader.__class__, eval("self.%s" % key), eval( "self.%s" % key).__class__)) if oneHeader != oneValue: keyToUpgrade.append(key) for key in keyToUpgrade: if not self.__bSaxsMetadataFailed: xsdi = XSDataInputSaxsAddMetadatav1_0() xsdi.setInputImage(self.xsdInputData.getOutputImage()) xsdi.setKey(XSDataString(EDUtilsBioSaxs.TRANSLATION[key])) xsdi.setValue(XSDataString("%s" % eval("self.%s" % key))) edPlugin = self.loadPlugin( self.__strControlledPluginMetadata) edPlugin.setDataInput(xsdi) edPlugin.connectSUCCESS(self.doSuccessMetadata) edPlugin.connectFAILURE(self.doFailureMetadata) edPlugin.executeSynchronous() if self.__bSaxsMetadataFailed: EDVerbose.screen( "EDPluginBioSaxsMetadatav1_0.process: writeMetadata using EdfFile " ) edf = EdfFile(self.strOutputImage) headers = [ edf.GetHeader(i) for i in xrange(edf.GetNumImages()) ] data = [edf.GetData(i) for i in xrange(edf.GetNumImages())] del edf for key in EDUtilsBioSaxs.TRANSLATION: if key in dir(self) and self.__getattribute__(key) is None: header[EDUtilsBioSaxs.TRANSLATION[key]] = eval( "self.%s" % key) edf = EdfFile(self.strOutputImage) if len(data) == 1: edf.WriteImage(header, data[0], Append=0) elif len(data) > 1: edf.WriteImage(header, data[0], Append=0) for datum in data[1:]: edf.WriteImage({}, datum, Append=1) else: EDVerbose.WARNING("There are not data in %s !!!" % self.strInputImage)
roi = PowderIntegrator(cif) pyintXpos, pyintYpos = roi.getSinogramPosition() strLockFile = lockFile(suffix=os.path.splitext(strPathToCif)[0], path='.', basename="lock") startWriteTime = time.time() for pystSinogramFilename in [ "sinogramPhotonFlux.edf", "sinogramIntegratedRaw.edf", "sinogramIntegratedCor.edf" ]: if os.path.isfile(pystSinogramFilename): edf = EdfFile(pystSinogramFilename) npSinogramArray = edf.GetData(0) else: npSinogramArray = roi.getEmptySinogramArray() edf = EdfFile(pystSinogramFilename) if pystSinogramFilename == "sinogramPhotonFlux.edf": npSinogramArray[pyintXpos, pyintYpos] = roi.pyfPhotonFlux elif pystSinogramFilename == "sinogramIntegratedRaw.edf": npSinogramArray[pyintXpos, pyintYpos] = roi.integrate() elif pystSinogramFilename == "sinogramIntegratedCor.edf": npSinogramArray[pyintXpos, pyintYpos] = roi.integrate() / roi.pyfPhotonFlux edf.WriteImage(pydMetaDataEDF, npSinogramArray, Append=0) pylRegionsOfInterest = []
Comm.start() if DoConfigure: Comm.Configure() if not Comm.isAlive(): raise SystemExit Comm.startAcquisition() if not Comm.isAlive(): raise SystemExit while Comm.getCurrentCommand() != Comm.COM_NONE: time.sleep(0.2) for i in range(Comm.getNbFramesReady()): if not Comm.isAlive(): raise SystemExit arr = Comm.getBuffer(i) arr.resize(240,566) f = EDF("%s_%.4d%s" % (filename,i,".edf")) f.WriteImage({},arr[:,5:565]) del f Comm.quit() del Comm if __name__ == "__main__": main()