class BIDSGrabInputSpec(BaseInterfaceInputSpec): # TODO: Check this inteface, why are there 'either file or list'? ~Mateusz fmri_prep_files = List() fmri_prep_aroma_files = Either(List(ImageFile()), File()) conf_raw_files = Either(List(File(exists=True)), File(exists=True)) conf_json_files = Either(List(File(exists=True)), File(exists=True)) subject = Str() task = Str() session = Str() run = Int()
class DBAnalysis(Analysis): meas_analysis_id = Long analysis_view_klass = ('pychron.processing.analyses.analysis_view', 'DBAnalysisView') uuid = Str persisted_age = None experiment_txt = Str xyz_position = Str snapshots = List beam_diameter = Either(Float, Str) pattern = Str mask_position = Either(Float, Str) mask_name = Str attenuator = Either(Float, Str) ramp_duration = Either(Float, Str) ramp_rate = Either(Float, Str) reprate = Either(Float, Str) timestamp = Float rundate = Date collection_time_zero_offset = Float peak_center = Any peak_center_data = Any ic_factors = Dict blank_changes = List fit_changes = List extraction_script_name = Str measurement_script_name = Str extraction_script_blob = Str measurement_script_blob = Str selected_blanks_id = Long source_parameters = List deflections = List def get_db_fit(self, meas_analysis, name, kind, selected_histories): try: if selected_histories is None: selected_histories = meas_analysis.selected_histories sel_fithist = selected_histories.selected_fits fits = sel_fithist.fits return next((fi for fi in fits if fi.isotope.kind == kind and fi.isotope.molecular_weight.name == name), None) except AttributeError, e: print 'exception', e
class DBAnalysis(Analysis): meas_analysis_id = Long analysis_view_klass = ('pychron.processing.analyses.analysis_view', 'DBAnalysisView') uuid = Str persisted_age = None experiment_txt = Str xyz_position = Str snapshots = List beam_diameter = Either(Float, Str) pattern = Str mask_position = Either(Float, Str) mask_name = Str attenuator = Either(Float, Str) ramp_duration = Either(Float, Str) ramp_rate = Either(Float, Str) reprate = Either(Float, Str) timestamp = Float rundate = Date collection_time_zero_offset = Float peak_center = Any peak_center_data = Any ic_factors = Dict blank_changes = List fit_changes = List extraction_script_name = Str measurement_script_name = Str extraction_script_blob = Str measurement_script_blob = Str selected_blanks_id = Long source_parameters = List deflections = List def set_ic_factor(self, det, v, e): for iso in self.get_isotopes(det): iso.ic_factor = ufloat(v, e) def set_temporary_ic_factor(self, k, v, e): iso = self.get_isotope(detector=k) if iso: iso.temporary_ic_factor = (v, e) def set_temporary_blank(self, k, v, e): self.debug('setting temporary blank iso={}, v={}, e={}'.format( k, v, e)) if self.isotopes.has_key(k): iso = self.isotopes[k] iso.temporary_blank = Blank(value=v, error=e) def get_baseline_corrected_signal_dict(self): get = lambda iso: iso.get_baseline_corrected_value() return self._get_isotope_dict(get) def get_baseline_dict(self): get = lambda iso: iso.baseline.uvalue return self._get_isotope_dict(get) def get_ic_factor(self, det): iso = next( (i for i in self.isotopes.itervalues() if i.detector == det), None) if iso: r = iso.ic_factor else: r = ufloat(1, 0) # if det in self.ic_factors: # r = self.ic_factors[det] # else: # r = ufloat(1, 1e-20) return r def get_db_fit(self, meas_analysis, name, kind, selected_histories): try: if selected_histories is None: selected_histories = meas_analysis.selected_histories sel_fithist = selected_histories.selected_fits fits = sel_fithist.fits return next((fi for fi in fits if fi.isotope.kind == kind and \ fi.isotope.molecular_weight.name == name), None) except AttributeError, e: print 'exception', e
class A(HasTraits): foo = RaisingValidator() bar = Either(None, RaisingValidator())
class MultiArrayDataSource(HasTraits): data = Either(None, Array)
class CUDSItemModelView(ModelView): """Wraps the CUDSItem node in a ModelView for easier representation and access.""" traits_view = View( VGroup( VGroup( Item("model.name", resizable=True, enabled_when="False"), label="CUDS Item Data", show_border=True, ), Tabbed( HGroup( VGroup( UItem( "all_fixed_properties", editor=ListStrEditor( adapter=PropertyAdapter(), selected="selected_fixed_property"), ), UItem("selected_fixed_property_model_view", style="custom", enabled_when="fixed_property_model_view_enabled", full_size=True), show_border=False), label="Fixed Properties", show_border=False, ), HGroup( VGroup( UItem( "all_variable_properties", editor=ListStrEditor( adapter=PropertyAdapter(), selected="selected_variable_property"), ), UItem( "selected_variable_property_model_view", style="custom", enabled_when= "variable_property_model_view_enabled", # noqa ), show_border=False), label="Variable Properties", show_border=False, ), ))) #: A list of the fixed and variable properties on the CUDSItem #: we are visualising, and only that object. obj_fixed_properties = Property(List(FixedProperty), depends_on="model") obj_variable_properties = Property(List(VariableProperty), depends_on="model") #: A list of the fixed and variable properties on the CUDSItem #: we are visualising. This includes all those that we inherit all_fixed_properties = Property(List(FixedProperty), depends_on="model") all_variable_properties = Property(List(VariableProperty), depends_on="model") #: The properties that we inherit from the base CUDSItems. inherited_properties = Property(Either(List(FixedProperty), List(VariableProperty)), depends_on="model") #: The properties that are selected by the user when they click selected_fixed_property = Instance(FixedProperty) selected_variable_property = Instance(VariableProperty) #: The ModelViews of the above, to allow controlled presentation. selected_variable_property_model_view = Instance(VariablePropertyModelView) selected_fixed_property_model_view = Instance(FixedPropertyModelView) #: State that says if the editor window should be enabled or not #: Inherited variables cannot be edited on a derived class. fixed_property_model_view_enabled = Bool() variable_property_model_view_enabled = Bool() def _get_obj_fixed_properties(self): """Gets the fixed properties, only local to the object""" return [ p for p in self.model.properties.values() if isinstance(p, FixedProperty) ] def _get_obj_variable_properties(self): """Gets the variable properties, only local to the object""" return [ p for p in self.model.properties.values() if isinstance(p, VariableProperty) ] def _get_all_fixed_properties(self): """Gets all the fixed properties, both local to the object and from its hierarchy""" inherited_properties = [ p for p in self.inherited_properties if isinstance(p, FixedProperty) ] return self.obj_fixed_properties + inherited_properties def _get_all_variable_properties(self): """Gets all the variable properties, both local to the object and from its hierarchy""" inherited_properties = [ p for p in self.inherited_properties if isinstance(p, VariableProperty) ] return self.obj_variable_properties + inherited_properties def _get_inherited_properties(self): """Gets all the inherited properties.""" parent_classes = list(traverse_to_root(self.model))[1:] inherited_properties = [] for parent in parent_classes: inherited_properties += [p for p in parent.properties.values()] return inherited_properties @on_trait_change("selected_variable_property") def _update_selected_variable_property_model_view(self, value): """Syncs the modelview with the changed selected property""" self.selected_variable_property_model_view = VariablePropertyModelView( model=self.selected_variable_property) self.variable_property_model_view_enabled = \ self.selected_variable_property in self.obj_variable_properties @on_trait_change("selected_fixed_property") def _update_selected_fixed_property_model_view(self, value): """Syncs the modelview with the changed selected property""" self.selected_fixed_property_model_view = FixedPropertyModelView( model=self.selected_fixed_property) self.fixed_property_model_view_enabled = \ self.selected_fixed_property in self.obj_fixed_properties