def closeFile(self): # Close the files. if (len(self.file_ptrs) > 0): for fp in self.file_ptrs: fp.close() # Write the parameters XML and .inf files. for i in range(len(self.filenames)): if feeds.isCamera(self.feed_names[i]): camera = self.parameters.get(self.feed_names[i], self.parameters) else: camera = self.parameters.get("feeds." + self.feed_names[i], self.parameters) filename = self.filenames[i][ 0:-len(self.parameters.get("film.filetype"))] writeInfFile(filename, self.number_frames[i], self.parameters, camera) # Save the parameters, but only for the cameras. if feeds.isCamera(self.feed_names[i]): self.parameters.add( "acquisition.camera", params.Parameter("", "camera", "camera" + str(i + 1), 1, False, True)) self.parameters.add( "acquisition.number_frames", params.Parameter("", "number_frames", self.number_frames[i], 1, False, True)) self.parameters.saveToFile(filename + ".xml") self.is_open = False
def closeFile(self): # Close the files. if (len(self.file_ptrs)>0): for fp in self.file_ptrs: fp.close() # Write the parameters XML and .inf files. for i in range(len(self.filenames)): if feeds.isCamera(self.feed_names[i]): camera = self.parameters.get(self.feed_names[i], self.parameters) else: camera = self.parameters.get("feeds." + self.feed_names[i], self.parameters) filename = self.filenames[i][0:-len(self.parameters.get("film.filetype"))] writeInfFile(filename, self.number_frames[i], self.parameters, camera) # Save the parameters, but only for the cameras. if feeds.isCamera(self.feed_names[i]): self.parameters.add("acquisition.camera", params.Parameter("", "camera", "camera" + str(i+1), 1, False, True)) self.parameters.add("acquisition.number_frames", params.Parameter("", "number_frames", self.number_frames[i], 1, False, True)) self.parameters.saveToFile(filename + ".xml") self.is_open = False
def __init__(self, filename, parameters, feed_names, extension, want_fp = True): self.feed_names = feed_names self.is_open = True self.parameters = parameters.copy() # FIXME: different cameras could have different lock targets. self.parameters.add("acquisition.lock_target", params.Parameter("", "lock_target", 0.0, 1, False, True)) self.parameters.add("acquisition.spot_counts", params.Parameter("", "spot_counts", "NA", 1, False, True)) self.parameters.add("acquisition.stage_position", params.ParameterCustom("", "stage_position", "0.0,0.0,0.0", 1, False, True)) self.parameters.add("acquisition.time", str(datetime.datetime.now())) self.filename = filename self.filenames = [] self.file_ptrs = [] self.number_frames = [] # Just return if there is nothing to save. if (len(self.feed_names) == 0): return if (len(self.feed_names) > 1): # Figure out if there is more than one camera. n_cameras = 0 for feed_name in self.feed_names: if feeds.isCamera(feed_name): n_cameras += 1 for feed_name in self.feed_names: # Only stick the camera name into the file if there is more than one camera. if feeds.isCamera(feed_name): if (n_cameras > 1): fname = filename + "_" + feed_name + "." + extension else: fname = filename + "." + extension else: fname = filename + "_" + feed_name + "." + extension self.filenames.append(fname) if want_fp: self.file_ptrs.append(open(fname, "wb")) self.number_frames.append(0) else: feed_name = self.feed_names[0] if feeds.isCamera(feed_name): fname = filename + "." + extension else: fname = filename + "_" + feed_name + "." + extension self.filenames.append(fname) if want_fp: self.file_ptrs.append(open(fname, "wb")) self.number_frames.append(0)
def __init__(self, filename, parameters, feed_names, extension, want_fp = True): self.feed_names = feed_names self.is_open = True self.parameters = parameters.copy() self.parameters.set("acquisition", params.StormXMLObject([])) # FIXME: different cameras could have different lock targets. self.parameters.set("acquisition.lock_target", 0.0) self.parameters.set("acquisition.spot_counts", "NA") self.parameters.set("acquisition.stage_position", [0.0, 0.0, 0.0]) self.filename = filename self.filenames = [] self.file_ptrs = [] self.number_frames = [] # Just return if there is nothing to save. if (len(self.feed_names) == 0): return if (len(self.feed_names) > 1): # Figure out if there is more than one camera. n_cameras = 0 for feed_name in self.feed_names: if feeds.isCamera(feed_name): n_cameras += 1 for feed_name in self.feed_names: # Only stick the camera name into the file if there is more than one camera. if feeds.isCamera(feed_name): if (n_cameras > 1): fname = filename + "_" + feed_name + "." + extension else: fname = filename + "." + extension else: fname = filename + "_" + feed_name + "." + extension self.filenames.append(fname) if want_fp: self.file_ptrs.append(open(fname, "wb")) self.number_frames.append(0) else: feed_name = self.feed_names[0] if feeds.isCamera(feed_name): fname = filename + "." + extension else: fname = filename + "_" + feed_name + "." + extension self.filenames.append(fname) if want_fp: self.file_ptrs.append(open(fname, "wb")) self.number_frames.append(0)
def totalFilmSize(self): total_size = 0.0 for i in range(len(self.filenames)): if feeds.isCamera(self.feed_names[i]): temp = self.parameters.get(self.feed_names[i]) else: temp = self.parameters.get("feeds." + self.feed_names[i]) total_size += self.number_frames[i] * temp.get("bytes_per_frame") * 0.000000953674 return total_size
def handleCameraShutter(self, boolean): if feeds.isCamera(self.feed_name): self.cameraShutter.emit(self.feed_name)
def getCameraSize(parameters, feed_name): if feeds.isCamera(feed_name): feed_obj = parameters.get(feed_name, parameters) else: feed_obj = parameters.get("feeds." + feed_name, parameters) return [feed_obj.get("x_pixels"), feed_obj.get("y_pixels")]