class FitParam(DataSet): _prop = GetAttrProp("fittype") fittype = ChoiceItem("Fit type", [("chebyshev", "Chebyshev"), ("spline", "Spline")], default="chebyshev").set_prop("display", store=_prop) k = IntItem(_("Spline degree"), help=_("Spline deg"), min=1, max=5, default=3).set_prop( "display", active=FuncProp( _prop, lambda x: x == 'spline')).set_pos(col=1, colspan=2) s = IntItem(_("Spline Smooth"), help=_("Spline smooth"), min=0, default=30000).set_prop("display", active=FuncProp( _prop, lambda x: x == 'spline')).set_pos( col=1, colspan=3) deg = IntItem(_("Chebyshev degree"), help=_("Chebyshev deg"), min=0, default=90).set_prop( "display", active=FuncProp(_prop, lambda x: x == 'chebyshev')).set_pos( col=1, colspan=2)
class Test(DataSet): _prop = GetAttrProp("choice") choice = ChoiceItem('Choice', choices).set_prop("display", store=_prop) x1 = FloatItem('x1') x2 = FloatItem('x2').set_prop("display", active=FuncProp(_prop, lambda x: x == 'B')) x3 = FloatItem('x3').set_prop("display", active=FuncProp(_prop, lambda x: x == 'C'))
class CsvParam(DataSet): _indexprop = GetAttrProp("indextype") indextype = ChoiceItem( "Index Column", (("A", "None"), ("B", "Input value below")), help="If None, no need to input index column").set_prop( "display", store=_indexprop) indexCol = IntItem("", default=0, min=0, help="first column is 0").set_prop( "display", active=FuncProp(_indexprop, lambda x: x == 'B')) _headerprop = GetAttrProp("headertype") headertype = ChoiceItem( "Header Row", (("A", "None"), ("B", "Input value below")), help="If None, no need to input index column").set_prop( "display", store=_headerprop) headerRow = IntItem("", default=0, min=0, help="first column is 0").set_prop( "display", active=FuncProp(_headerprop, lambda x: x == 'B'))
class ModifyParam(DataSet): """ Modification Parameter Setting Linear: New Array = a * Original Array + b <br> Moving Average: Decide point number(to get average, or regard it as sinc filter) """ text = StringItem("New Name", default="Modify_" + name) a = FloatItem("a :", default=1.0) b = FloatItem("b :", default=0.0) _en = GetAttrProp("enable") enable = BoolItem( "Enable Moving Average", help="If disabled, the following parameters will be ignored", default=False).set_prop("display", store=_en) points = IntItem("Window", default=5, min=1).set_prop("display", active=FuncProp(_en, lambda x: x))
class TestParameters(DataSet): """ PPT Converter Choose according to your function """ #fname = FileOpenItem("Open file", "ppt", FILE_ppt.name) #_eg = StartGroup("Convert_Mode") PPTnames = FilesOpenItem("Open_files", ("ppt", "pptx"), help="Input your PPT file") ##list outpath = DirectoryItem("OutDirectory", default=PPTnames._props["data"]["basedir"], help="default is the PPt path") outname = StringItem('Outlabel', help="default is the ppt name ") dtime = DateTimeItem("Date/time", default=datetime.datetime( 2017, 10, 10)) #text = TextItem("Text") g1 = BeginGroup("Convert_Mode") # outMode = MultipleChoiceItem("", # ["Raw", "Resized", # ],help="(default concated)",default=(1,)).horizontal(1)#.set_pos(col=1) raw = BoolItem("Raw", default=False, help="normal mode").set_pos(col=0) _prop = GetAttrProp("resize") #choice = ChoiceItem('Choice', choices).set_prop("display", store=_prop) resize = BoolItem("Resized", default=True, help="normal mode").set_pos(col=1).set_prop("display", store=_prop) newsize = IntItem("NewSize(width_dpi)", default=709, min=0, help="if changed,dpi", max=2160, slider=True).set_pos(col=2).set_prop( "display", active=FuncProp(_prop, lambda x: x)).set_pos(col=2) _g1 = EndGroup("Convert_Mode") outFormat = MultipleChoiceItem( "OuterForm", ["Pngs", "Con_Pngs", "PDF", "HTML", "XML"], help="(default all)", default=(0, 1, 2, 3, 4), ).horizontal(1)
class ReconstructionParameters(ActivableDataSet): #Preprocessing Parameters #events associated to different parameters def _threshold_change(self, item, value): if self.threshold_change_cb is not None: self.threshold_change_cb() def set_threshold_change_cb(self, cb): self.threshold_change_cb = cb def _unwrap_change(self, item, value): if self.unwrap_change_cb is not None: self.unwrap_change_cb() def set_unwrap_change_cb(self, cb): self.unwrap_change_cb = cb def _use_filter_size_aberration_change(self, item, value): if self.use_filter_size_aberration_change_cb is not None: self.use_filter_size_aberration_change_cb() def set_use_filter_size_aberration_change_cb(self, cb): self.use_filter_size_aberration_change_cb = cb def _use_filter_amplitude_change(self, item, value): if self.use_filter_amplitude_change_cb is not None: self.use_filter_amplitude_change_cb() def set_use_filter_amplitude_change_cb(self, cb): self.use_filter_amplitude_change_cb = cb def _filter_size_aberration_change(self, item, value): if self.filter_size_aberration_change_cb is not None: self.filter_size_aberration_change_cb() def set_filter_size_aberration_change_cb(self, cb): self.filter_size_aberration_change_cb = cb def _bool_deriv_change(self, item, value): if self.bool_deriv_change_cb is not None: self.bool_deriv_change_cb() def set_bool_deriv_change_cb(self, cb): self.bool_deriv_change_cb = cb def _XYImport_change(self, item, value): if self.XYImport_change_cb is not None: self.XYImport_change_cb() def set_XYImport_change_cb(self, cb): self.XYImport_change_cb = cb def _bool_ThresholdMethod_change(self, item, value): if self.bool_ThresholdMethod_change_cb is not None: self.bool_ThresholdMethod_change_cb() def set_bool_ThresholdMethod_change_cb(self, cb): self.bool_ThresholdMethod_change_cb = cb def _particlecontrast_change(self, item, value): if self.particlecontrast_change_cb is not None: self.particlecontrast_change_cb() def set_particlecontrast_change_cb(self, cb): self.particlecontrast_change_cb = cb def _it_eros_change(self, item, value): if self.it_eros_change_cb is not None: self.it_eros_change_cb() def set_it_eros_change_cb(self, cb): self.it_eros_change_cb = cb def _it_dil_change(self, item, value): if self.it_dil_change_cb is not None: self.it_dil_change_cb() def set_it_dil_change_cb(self, cb): self.it_dil_change_cb = cb def _XYImportFilePath_change(self, item, value): if self.XYImportFilePath_change_cb is not None: self.XYImportFilePath_change_cb() def set_XYImportFilePath_change_cb(self, cb): self.XYImportFilePath_change_cb = cb #Initialization of buttons in different groups unwrap = ChoiceItem(_("Unwrap"), [(True, 'Yes'), (False, 'False')], default=False).set_prop("display", callback=_unwrap_change) unwrap_change_cb = None #Group Filtering Filtering_group = BeginGroup("Filtering") use_filter_size_aberration = ChoiceItem( _("Use uniform filter for aberration compensation"), [(True, 'Yes'), (False, 'False')], default=False).set_prop("display", callback=_use_filter_size_aberration_change) use_filter_size_aberration_change_cb = None filter_size_aberration = IntItem( _("Filter size (aberr. compens.)"), default=100, slider=False, unit='pixels', min=1, max=300).set_prop("display", callback=_filter_size_aberration_change) filter_size_aberration_change_cb = None use_filter_amplitude = ChoiceItem( _("Use amplitude Filter"), [(False, 'No'), (True, 'Yes')], default=False).set_prop("display", callback=_use_filter_amplitude_change) use_filter_amplitude_change_cb = None def _adjust_aberration_change(self, item, value, parent): if self.adjust_aberration_change_cb is not None: self.adjust_aberration_change_cb() def set_adjust_aberration_change_cb(self, cb): self.adjust_aberration_change_cb = cb aberration_perform = ButtonItem("Adjust Filtering", callback=_adjust_aberration_change) adjust_aberration_change_cb = None def _bcgRemove_change(self, item, value): if self.bcgRemove_change_cb is not None: self.bcgRemove_change_cb() def set_bcgRemove_change_cb(self, cb): self.bcgRemove_change_cb = cb def _bcgCompute_change(self, item, value, parent): if self.bcgCompute_change_cb is not None: self.bcgCompute_change_cb() def set_bcgCompute_change_cb(self, cb): self.bcgCompute_change_cb = cb _Filtering_group = EndGroup("Filtering") Filtering_group = BeginGroup("Background") bcgRemove = ChoiceItem(_("Background remove"), [(True, 'Yes'), (False, 'False')], default=False).set_prop("display", callback=_bcgRemove_change) bcgRemove_change_cb = None bcgCompute = ButtonItem("Compute Background", callback=_bcgCompute_change) bcgCompute_change_cb = None _Filtering_group = EndGroup("Background") #Import xy (enable/disable importation of file or detection parameters) propImport = GetAttrProp( "XYImport") # to enable/disable Import XY File path if True or False XYImport = ChoiceItem(_("Import XY Position"), [(False, 'No'), (True, 'Yes')], default=False).set_prop("display", callback=_XYImport_change, store=propImport) XYImport_change_cb = None XYImportFilePath = FileOpenItem( "File Path", formats='txt', default=r'D:\Mesures\3DTracking_Donner\15.05.03_46.68\Sequence_import_xy' ).set_prop("display", active=FuncProp(propImport, lambda x: x == True), callback=_XYImportFilePath_change) XYImportFilePath_change_cb = None #Group Detection parameters Detection_group = BeginGroup("Detection XY").set_prop( "display", active=FuncProp(propImport, lambda x: x == False)) bool_deriv = ChoiceItem(_("Derive"), [(True, 'Yes'), (False, 'No')], default=False).set_prop( "display", callback=_bool_deriv_change) bool_deriv_change_cb = None particlecontrast = ChoiceItem(_("Particle Contrast"), [(0, 'Positive'), (1, 'Negative')]).set_prop( "display", callback=_particlecontrast_change) particlecontrast_change_cb = None threshold = FloatItem( ("Threshold"), default=10., slider=False, min=0., max=255, step=1, ).set_prop("display", callback=_threshold_change) threshold_change_cb = None bool_ThresholdMethod = ChoiceItem( _("Threshold Method"), [(-2, 'No threshold/max value'), (-1, 'Manual'), (0, 'Huang'), (2, 'Intermodes'), (3, 'ReniEntropy'), (4, 'Triangle'), (5, 'Otsu'), (6, 'Yen'), (7, 'Moments'), (8, 'IsoData'), (9, 'Peak Detection')], default=0).set_prop("display", callback=_bool_ThresholdMethod_change) bool_ThresholdMethod_change_cb = None #Threshold method #-1=manual #0=Huang #1=Intermodes #2=MaxEntropy #3=ReniEntropy #4=Triangle #5=Otsu #6=Yen #7=Moments #8=IsoData #9=Peak Detection #erosion and dilatation iterations it_eros = IntItem(_("Iter. erosion"), default=1, slider=False, unit='pixels', min=0).set_prop("display", callback=_it_eros_change) it_eros_change_cb = None it_dil = IntItem(_("Iter. dilatation"), default=4, slider=False, unit='pixels', min=0).set_prop("display", callback=_it_dil_change) it_dil_change_cb = None def _adjust_detection_change(self, item, value, parent): if self.adjust_detection_change_cb is not None: self.adjust_detection_change_cb() def set_adjust_detection_change_cb(self, cb): self.adjust_detection_change_cb = cb detection_perform = ButtonItem("Adjust Detection", callback=_adjust_detection_change) adjust_detection_change_cb = None _Detection_group = EndGroup("Detection XY")
class ImageParam(DataSet): #_hide_data = False #_hide_size = True #title = StringItem(_("Title"), default=_("Untitled")).set_prop("display", hide=True) #data = FloatArrayItem(_("Settings")).set_prop("display", # hide=GetAttrProp("_hide_data")) _prop = GetAttrProp("otype") otype = StringItem("Type of data", default="Unknown").set_prop("display", store=_prop) #, hide=True) title = StringItem(_("Title"), default=_("Untitled")).set_prop("display", hide=True) _bg = BeginGroup("Range setting") #feed = ChoiceItem("Feed", [(1, "1"), (2, "2"), (3, "3")]).set_prop("display", active=False) #section = ChoiceItem("Section", [("Ch0", "0"), ("Ch1", "1"), ("Ch2", "2"), # ("Ch3", "3")]).set_pos(col=1, colspan=2) #polar = ChoiceItem("Polar", [(16, "first choice"), (32, "second choice"), # (64, "third choice")]).set_pos(col=2, colspan=2) #_prop = GetAttrProp("otype") #otype = ChoiceItem("Type of data", [("On/Off: off source", "On/Off: off source"), ("OTF", "OTF"), ("Unknown", "Unknown")], default="Unknown").set_prop("display", store=_prop, hide=True) #otype = StringItem("Type of data", default="Unknown").set_prop("display", store=_prop)#, hide=True) rangei = IntItem( _("num. samples begin"), help= _("Select a number of samples at the begin of the data to use for the computation" ), min=0, default=0).set_prop("display", active=FuncProp( _prop, lambda x: x == 'OTF' or x == 'Unknown')) ranges = IntItem( _("num. samples end"), help= _("Select a number of sameples at the end of the data to use for the computation" ), min=0, default=0).set_prop( "display", active=FuncProp(_prop, lambda x: x == 'OTF' or x == 'Unknown')).set_pos( col=1, colspan=2) rall = BoolItem(_("All"), default=True).set_pos(col=2, colspan=2).set_prop( "display", active=FuncProp(_prop, lambda x: x == 'OTF' or x == 'Unknown'), hide=True) excluded = IntItem( _("Excluded samples"), help= _("Select a number of samples to exclude from the computation at the begining and end of the data symmetrically" ), min=0, default=0).set_prop("display", active=FuncProp( _prop, lambda x: x == 'OTF' or x == 'Unknown')) eall = BoolItem(_("All"), default=True).set_pos(col=1, colspan=2).set_prop("display", hide=True) _eg = EndGroup("Range setting") _bg2 = BeginGroup("Fit Range") frangei = IntItem( _("intitial freq sample"), help=_("Select the first freq sample to use for the fit computation"), min=0, default=0) franges = IntItem( _("last freq sample"), help= _("Select the last freq sample to use for the fit computation (if 0 take max)" ), min=0, default=0).set_pos(col=1, colspan=1) _eg2 = EndGroup("Fit Range") #selected = BoolItem(_("Selected"), default=True) selected = ChoiceItem("Selected", [(True, "Yes"), (False, "No")], default=True).set_prop("display", hide=True)
class TestParameters(DataSet): """ PPT_Converter:Based on Glance Choose according to your demond """ def updatedir(self, item, value): print("\nitem: ", item, "\nvalue:", value) if self.PPTnames and value[0]: self.outpath = os.path.split(value[0])[0] print(os.path.split(value[0])) if len(value) > 0: #如果只是选择了单个文件 self.outprefix = os.path.basename(value[0]).split('.')[0] else: #选了多个文件 self.outpath = os.getcwdu() self.outprefix = None self.WebTitle = self.outprefix print("\nitem: ", self.outpath, "\nvalue:", self.WebTitle) #self.ImagesDirName=str(self.newsize) # self.htmlTitle=self.outprefix #fname = FileOpenItem("Open file", "ppt", FILE_ppt.name) #_eg = StartGroup("Convert_Mode") g0 = BeginGroup("Select Your PPTs to Manipulate") PPTnames = FilesOpenItem("OpenPPTs", ("ppt", "pptx"), help="Select your PPT files", all_files_first=True).set_prop( 'display', callback=updatedir) ##list outpath = DirectoryItem( "OutPath", help= "Select the output path.\nDefault is the path where you choose your PPT" ).set_prop('display', active=True) WebTitle = StringItem( 'HTML/XML Title\n(Glance)', help= "The Title of the generated html/xml file.\nDefault is the PPT's filename" ).set_prop('display', active=True) outprefix = StringItem( 'OutFilePrefix', help="The prefix of generated file .\nDefault is the ppt name " ).set_prop('display', active=True) _g0 = EndGroup("Select Your PPTs to Manipulate") g1 = BeginGroup("Select Your Convert_Mode") # outMode = MultipleChoiceItem("", # ["Raw", "Resized", # ],help="(default concated)",default=(1,)).horizontal(1)#.set_pos(col=1) raw = BoolItem( "Raw", default=False, help= "Those Generated Files will Use Pngs Exported from PPT Slides Without any Crop or Resize" ).set_pos(col=0) _prop = GetAttrProp("resize") #choice = ChoiceItem('Choice', choices).set_prop("display", store=_prop) resize = BoolItem( "Resized", default=True, help= "Means You Want to Resize those Raw Pngs Before Use Them In Your Final Formats\ " ).set_pos(col=1).set_prop("display", store=_prop) newsize = IntItem("NewSize\n(width_dpi)", default=709, min=0, help="The Value Must be lower than the raw png's Width!", max=2160, slider=True).set_prop("display", active=FuncProp( _prop, lambda x: x)) ImagesDirName = StringItem( 'ImagesDirName', help= "The DirName of Resized Pngs used in Html/Xml/LongPng file.\nDefault is the Png wideth size If You Leave It Empty" ).set_prop('display', active=FuncProp(_prop, lambda x: x)) _g1 = EndGroup("Select Your Convert_Mode") g2 = BeginGroup("Which Format Do U Want To Generate") must = BoolItem( "Pngs", default=True, help="You Cannot Remove Pngs If You Want to Get Other Types." ).set_prop("display", active=0).set_pos(col=0) outFormat = MultipleChoiceItem( "Optional", ["Long_Png", "PDF", "HTML", "XML"], help= "(Default all,But I won't give U the Long_Png with Raw Pngs.\nAnd the 1st choice('Pngs') is default to generate.)", default=(1, 2, 3)).horizontal(1).set_pos(col=1) _g2 = EndGroup("Which Format Do U Want To Generate")