class VResizeDialog(HasTraits): txt = Str("hallo") traits_view = View( VGroup(Item("txt", width=_TXT_WIDTH, resizable=True)), width=_DIALOG_WIDTH, height=_DIALOG_HEIGHT, resizable=True, )
def test_vertical_layout(self): view = View( VGroup( Item("txt1"), Item("txt2"), ) ) with reraise_exceptions(), \ create_ui(MultipleTrait(), ui_kwargs=dict(view=view)): pass
class NewModelADialog(NewModelDialog): """Create a dialog requesting the parameters to create Model A.""" model_name = Str(MODEL_A_NAME) nclasses = Int(5) parameters_group = VGroup( Item(name='nclasses', editor=RangeEditor(mode='spinner', low=3, high=1000), label='Number of annotation classes:', width=100), )
class NoLabelResizeTestDialog(HasTraits): """ Test the combination show_label=False, show_left=False. """ bool_item = Bool(True) traits_view = View(VGroup(Item('bool_item', resizable=True, show_label=False), show_left=False), resizable=True)
def default_traits_view(self): return View( VGroup( UItem( "resizable_readonly_item", resizable=True, style="readonly", ), ), height=_DIALOG_HEIGHT, width=_DIALOG_WIDTH, )
def traits_view(self): ctrl_grp = VGroup( # HGroup(UItem('add_band')), UItem('highlight_bands', height=115,editor=ListEditor(mutable=False, style='custom', editor=InstanceEditor()))) v = View( VSplit( ctrl_grp, UItem('container', editor=ComponentEditor(height=700)))) return v
class VResizeDialog(HasTraits): txt = Str('hallo') traits_view = View( VGroup( Item('txt', width=_TXT_WIDTH, resizable=True), ), width=_DIALOG_WIDTH, height=_DIALOG_HEIGHT, resizable=True )
def traits_view(self): w_view = 350 if is_display_small() else 480 parameters_group = VGroup( Item('_'), HGroup( VGroup( Spring(), Item('handler.omega_hinton_diagram', style='custom', resizable=False, show_label=False, width=w_view), Spring()), Spring(), VGroup(Spring(), Item('handler.view_omega', show_label=False), Spring())), Spring(), Item('_'), Spring(), HGroup( VGroup( UItem('handler.theta_views'), UItem('handler.theta_view', style='custom', resizable=False, width=w_view), Spring()), Spring(), VGroup(Spring(), UItem('handler.view_theta'), Spring()))) body = VGroup(Include('info_group'), parameters_group) traits_view = View(body, buttons=[OKButton], resizable=True) return traits_view
class SaveFileDialog(HasTraits): save_file = File(exists=False) dpi = Int(300) traits_view = View(VGroup( Item('save_file', label='Save to:', editor=FileEditor(allow_dir=False, dialog_style='save', entries=0), style='simple'), Item('dpi', label='Resolution (dpi):')), title='Save plot', width=400, resizable=True, buttons=OKCancelButtons)
def traits_view(self): db_table_editor = TableEditor( columns=[ ObjectColumn(name='data_id', label='Annotations ID', editable=False, width=0.65), ObjectColumn(name='model_name', editable=False, width=0.20), ObjectColumn(name='value', label='Log likelihood', editable=False, width=0.15) ], search=SearchIDFilter(), editable=True, deletable=True, configurable=False, sortable=True, sort_model=False, auto_size=False, orientation='vertical', show_toolbar=True, selection_mode='row', on_dclick=self.forward_to_model_data_view, on_select=self.track_selection) traits_view = View( VGroup( Item( 'results_table', editor=db_table_editor, show_label=False, ), HGroup( Item('open_to_main', show_label=False, width=100), Item('delete_action', show_label=False, enabled_when='current_selection is not None', width=100), Spring(), Item('close_view', show_label=False, width=100)), ), title='pyAnno results database', width=800, height=400, resizable=True, #buttons = [ 'OK' ], kind='live') return traits_view
class EnableWhenDialog(HasTraits): """ Test labels for enable when. """ bool_item = Bool(True) labelled_item = Str('test') unlabelled_item = Str('test') traits_view = View(VGroup( Item('bool_item', ), Item('labelled_item', enabled_when='bool_item'), Item('unlabelled_item', enabled_when='bool_item', show_label=False), ), resizable=True)
def traits_view(self): self.statistics_name = "Cohen's Kappa" traits_view = View(VGroup( HGroup(Item("statistics_name", show_label=False), Item("info_button", show_label=False)), Spring(), HGroup( Spring(), Item("stats_view", style="custom", show_label=False, width=300, resizable=False), Spring()), ), width=400, resizable=True) return traits_view
class EnableWhenDialog(HasTraits): """ Test labels for enable when. """ bool_item = Bool(True) labelled_item = Str("test") unlabelled_item = Str("test") traits_view = View( VGroup( Item("bool_item"), Item("labelled_item", enabled_when="bool_item"), Item("unlabelled_item", enabled_when="bool_item", show_label=False), ), resizable=True, )
class TestShowArray(HasTraits): data = Array view = View(Item('data', editor=TabularEditor(adapter=Array2DAdapter( ncolumns=2, format='%s', show_index=False)), show_label=False), title='Array2D editor', width=0.3, height=0.8, resizable=True, buttons=NoButtons) VGroup( Item('data', editor=TabularEditor(adapter=Array2DAdapter( ncolumns=2, format='%d', show_index=False)), show_label=False)),
def traits_view(self): traits_view = View( VGroup( Item('annotator_idx', label='Annotator index', editor=RangeEditor(mode='spinner', low=0, high=self.theta.shape[0]-1, ), ), HGroup( Item('theta_j_view', style='custom', show_label=False), ), ), width = 500, height = 400, resizable = True ) return traits_view
def traits_view(self): nclasses = self.beta.shape[1] w_table = WIDTH_CELL * nclasses h_table = HEIGHT_CELL * nclasses w_view = min(MAX_WIDTH, w_table + W_MARGIN) h_view = min(MAX_HEIGHT, h_table + HEIGHT_CELL + H_MARGIN) view = View( VGroup( Label('Beta parameters (prior over pi):'), UItem('beta', editor=TabularEditor( adapter=Array2DAdapter(ncolumns=nclasses, format='%.4f', show_index=True, count_from_one=False), ), width = w_table, height = HEIGHT_CELL, padding = 10 ), Label('Alpha parameters (prior over theta):'), UItem('alpha', editor=TabularEditor( adapter=Array2DAdapter(ncolumns=nclasses, format='%.4f', show_index=True, count_from_one=False), ), width = w_table, height = h_table, padding = 10 ), ), width = w_view, height = h_view, scrollable = True, resizable = True, buttons = ['OK', 'Cancel'] ) return view
def _get_auto_group(self): return VGroup( HGroup( icon_button_editor( 'plot_button', 'refresh', tooltip='Replot the isotope evolutions. ' 'This may take awhile if many analyses are selected'), icon_button_editor('save_event', 'database_save', tooltip='Save fits to database'), Item( 'auto_update', label='Auto Plot', tooltip= 'Should the plot refresh after each change ie. "fit" or "show". ' 'It is not advisable to use this option with many analyses' )), HGroup( UItem('global_fit', editor=EnumEditor(name='fit_types')), UItem('global_error_type', editor=EnumEditor(name='error_types'))))
class EventSelectionDialog(HasTraits): source_class_label = String("Select Event Source Classes") severity_level_label = String("Select Event Severity Levels") search = String(regex="^[_a-zA-Z0-9\*\.\$\^\?\s]*$") shown_event_names_list = String(regex="[_a-zA-Z0-9\*\.\$\^\?\n]*") quit_button = Button('Quit') query_button = Button('Run Query...') period_start_date = DelegatesTo("query_object") period_end_date = DelegatesTo("query_object") selected_list_of_event_severity_levels = DelegatesTo("query_object") list_of_event_severity_levels = DelegatesTo("query_object") selected_list_of_source_classes = DelegatesTo("query_object") list_of_source_classes = DelegatesTo("query_object") query_object = Instance(EventSelectionQuery) spring = Spring help_text = ( "Search engine like queries using alphanumeric characters and '_'and '.' \n" + "Space indicate OR-separated queries\n" + "? = match any character\n" + "* = any number of characters\n" + "^ = match beginning\n" "$ = match end") view = View( Group( VGroup( HGroup(Item("period_start_date", label="Period"), Item("period_end_date", show_label=False), Item("", resizable=True, width=1.0, show_label=False), HGroup(Item('quit_button', show_label=False), Item('query_button', show_label=False)), springy=True), HGroup( VGroup( HGroup( Item("severity_level_label", show_label=False, style="readonly")), Item("selected_list_of_event_severity_levels", editor=CheckListEditor( name="list_of_event_severity_levels"), style="custom", show_label=False)), VGroup( HGroup( Item("source_class_label", show_label=False, style="readonly")), Item("selected_list_of_source_classes", editor=CheckListEditor( name="list_of_source_classes"), style="custom", show_label=False)), # springy=True ), show_border=True), Item("_"), VGroup(Item("search", editor=HistoryEditor(auto_set=True), show_label=False, width=1.0, tooltip=help_text), Item( name='shown_event_names_list', style='readonly', resizable=True, show_label=False, ), scrollable=True, show_border=True), orientation='vertical', ), title='Select Events to Visualize', dock='horizontal', resizable=True, width=.5, height=.7) def __init__(self, query_object, **kwargs): ''' Creates a dialog window for selecting date period, source classes and event severity levels/types. :param query_object: :return: ''' assert isinstance(query_object, EventSelectionQuery) self.shown_event_names_list = "\n".join( list(query_object.list_of_event_names)) self.query_object = query_object self.query_start_date = query_object.period_start_date self.query_end_date = query_object.period_end_date HasTraits.__init__(self, **kwargs) def _search_changed(self): ''' Matches search query to the event names. :return: ''' query_st = str(self.search).strip() if re.match("^[_a-zA-Z0-9\*\.\$\^\?\s]*$", query_st) is None: return query_st = query_st.replace(".", "\.") query_st = query_st.replace("*", ".*") query_st = query_st.replace("?", ".?") queries = query_st.split() print self.search, query_st, queries, if len(queries) == 0: queries = [""] result = [ s for s in list(self.query_object.list_of_event_names) for q in queries if re.search((".*%s.*" % q), s) is not None ] self.query_object.selected_list_of_event_names = result self.shown_event_names_list = "\n".join(result) print len(self.shown_event_names_list) def _save_search(self): # A bug fix, stops the clearing of the search expression tmp = self.search self.search = " " self.search = tmp print len(self.query_object.selected_list_of_event_names) def _query_button_changed(self): self._save_search() self.query_object.execute_query() def _quit_button_changed(self): self._save_search() sys.exit(0)
class PosteriorPlot(PyannoPlotContainer): # data to be displayed posterior = Array ### plot-related traits plot_width = Float def _plot_width_default(self): return 450 if is_display_small() else 500 plot_height = Float def _plot_height_default(self): return 600 if is_display_small() else 750 colormap_low = Float(0.0) colormap_high = Float(1.0) origin = Str('top left') plot_container = Instance(HPlotContainer) plot_posterior = Instance(Plot) def _create_colormap(self): if self.colormap_low is None: self.colormap_low = self.posterior.min() if self.colormap_high is None: self.colormap_high = self.posterior.max() colormap = Reds( DataRange1D(low=self.colormap_low, high=self.colormap_high)) return colormap def _plot_container_default(self): data = self.posterior nannotations, nclasses = data.shape # create a plot data object plot_data = ArrayPlotData() plot_data.set_data("values", data) # create the plot plot = Plot(plot_data, origin=self.origin) img_plot = plot.img_plot("values", interpolation='nearest', xbounds=(0, nclasses), ybounds=(0, nannotations), colormap=self._create_colormap())[0] ndisp = 55 img_plot.y_mapper.range.high = ndisp img_plot.y_mapper.domain_limits = ((0, nannotations)) self._set_title(plot) plot.padding_top = 80 # create x axis for labels label_axis = self._create_increment_one_axis(plot, 0.5, nclasses, 'top') label_axis.title = 'classes' self._add_index_axis(plot, label_axis) plot.y_axis.title = 'items' # tweak plot aspect goal_aspect_ratio = 2.0 plot_width = (goal_aspect_ratio * self.plot_height * nclasses / ndisp) self.plot_width = min(max(plot_width, 200), 400) plot.aspect_ratio = self.plot_width / self.plot_height # add colorbar colormap = img_plot.color_mapper colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range), color_mapper=colormap, plot=img_plot, orientation='v', resizable='', width=15, height=250) colorbar.padding_top = plot.padding_top colorbar.padding_bottom = int(self.plot_height - colorbar.height - plot.padding_top) colorbar.padding_left = 0 colorbar.padding_right = 30 # create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(plot) container.add(colorbar) container.bgcolor = 0xFFFFFF # light gray: 0xEEEEEE # add pan tools img_plot.tools.append( PanTool(img_plot, constrain=True, constrain_direction="y", speed=7.)) self.decorate_plot(container, self.posterior) self.plot_posterior = plot return container def add_markings(self, mark_classes, mark_name, marker_shape, delta_x, delta_y, marker_size=5, line_width=1., marker_color='white'): plot = self.plot_posterior nannotations = plot.data.arrays['values'].shape[0] y_name = mark_name + '_y' x_name = mark_name + '_x' valid = is_valid(mark_classes) y_values = np.arange(nannotations)[valid] + delta_y + 0.5 x_values = mark_classes[valid].astype(float) + delta_x + 0.5 plot.data.set_data(y_name, y_values) plot.data.set_data(x_name, x_values) plot.plot((x_name, y_name), type='scatter', name=mark_name, marker=marker_shape, marker_size=marker_size, color='transparent', outline_color=marker_color, line_width=line_width) def remove_markings(self, mark_name): self.plot_posterior.delplot(mark_name) def _create_resizable_view(self): # resizable_view factory, as I need to compute the height of the plot # from the number of annotations, and I couldn't find any other way to # do that # "touch" posterior_plot to have it initialize self.plot_container if is_display_small(): height = 760 else: height = 800 resizable_plot_item = (Item( 'plot_container', editor=ComponentEditor(), resizable=True, show_label=False, width=self.plot_width, height=self.plot_height, )) resizable_view = View(VGroup( Include('instructions_group'), resizable_plot_item, ), width=450, height=height, resizable=True) return resizable_view def traits_view(self): return self._create_resizable_view() pan_instructions = Str def _pan_instructions_default(self): return 'Left-click and drag to navigate items' instructions_group = VGroup( HGroup(Spring(), Item('instructions', style='readonly', show_label=False), Spring()), HGroup(Spring(), Item('pan_instructions', style='readonly', show_label=False), Spring()))
def traits_view(self): v = View( VGroup(self._get_auto_group(), self._get_toggle_group(), self._get_fit_group())) return v
def traits_view(self): ## Model view # adjust sizes to display size if is_display_small(): # full view size w_view, h_view = 1024, 768 w_data_create_group = 350 w_data_info_group = 500 h_annotations_stats = 270 else: w_view, h_view = 1300, 850 w_data_create_group = 400 w_data_info_group = 700 h_annotations_stats = 330 model_create_group = (VGroup(HGroup( UItem(name='model_name', width=200), UItem(name='new_model', width=100), UItem(name='get_info_on_model', width=100, height=25), ), label='Create new model')) model_group = (VGroup( model_create_group, VGroup( Item('model_view', style='custom', show_label=False, width=400), label='Model view', ), ), ) ## Data view data_create_group = VGroup( #Label('Open annotation file:', width=800), HGroup( Item('annotations_file', style='simple', label='Open file:', width=w_data_create_group, height=25), UItem('new_annotations', height=25)), label='Load/create annotations', show_border=False, ) data_info_group = VGroup( Item( 'annotations_view', style='custom', show_label=False, visible_when='annotations_are_defined', width=w_data_info_group, ), Item('annotations_stats_view', style='custom', show_label=False, visible_when='annotations_are_defined', height=h_annotations_stats), label='Data view', ) data_group = (VGroup( data_create_group, data_info_group, ), ) ## (Model,Data) view model_data_group = ( VGroup( #Item('info_string', show_label=False, style='readonly'), Item('log_likelihood', label='Log likelihood', style='readonly'), HGroup( Item('ml_estimate', enabled_when='annotations_are_defined'), Item('map_estimate', enabled_when='annotations_are_defined'), Item('sample_posterior_over_accuracy', enabled_when='annotations_are_defined'), Item('estimate_labels', enabled_when='annotations_are_defined'), Spring(), Item('add_to_database', enabled_when='annotations_are_defined'), Item('open_database'), show_labels=False, ), label='Model-data view', )) ## Full view full_view = View( VGroup( HGroup(model_group, data_group), model_data_group, ), title='PyAnno - Models of data annotations by multiple curators', width=w_view, height=h_view, resizable=False) return full_view
class ProjectInfoUI(cmp.project.ProjectInfo): """Class that extends the :class:`ProjectInfo` with graphical components. It supports graphically the setting of all processing properties / attributes of an :class:`ProjectInfo` instance. Attributes ----------- creation_mode : traits.Enum Mode for loading the dataset. Valid values are 'Load BIDS dataset', 'Install Datalad BIDS dataset' install_datalad_dataset_via_ssh : traits.Bool If set to True install the datalad dataset from a remote server via ssh.(True by default) ssh_user : traits.Str Remote server username. (Required if ``install_datalad_dataset_via_ssh`` is True) ssh_pwd <traits.Password> Remote server password. (Required if ``install_datalad_dataset_via_ssh`` is True) ssh_remote : traits.Str Remote server IP or URL. (Required if ``install_datalad_dataset_via_ssh`` is True) datalad_dataset_path : traits.Directory Path to the datalad dataset on the remote server. (Required if ``install_datalad_dataset_via_ssh`` is True) summary_view_button : traits.ui.Button Button that shows the pipeline processing summary table pipeline_processing_summary_view : traits.ui.VGroup TraitsUI VGroup that contains ``Item('pipeline_processing_summary')`` dataset_view : traits.ui.View TraitsUI View that shows a summary of project settings and modality available for a given subject traits_view : QtView TraitsUI QtView that includes the View 'dataset_view' create_view : traits.ui.View Dialog view to create a BIDS Dataset subject_view : traits.ui.View Dialog view to select of subject subject_session_view : traits.ui.View Dialog view to select the subject session dmri_bids_acq_view : traits.ui.View Dialog view to select the diffusion acquisition model anat_warning_view : traits.ui.View View that displays a warning message regarding the anatomical T1w data anat_config_error_view : traits.ui.View Error view that displays an error message regarding the configuration of the anatomical pipeline dmri_warning_view : traits.ui.View View that displays a warning message regarding the diffusion MRI data dmri_config_error_view : traits.ui.View View that displays an error message regarding the configuration of the diffusion pipeline fmri_warning_view : traits.ui.View View that displays a warning message regarding the functional MRI data fmri_config_error_view : traits.ui.View View that displays an error message regarding the configuration of the fMRI pipeline open_view : traits.ui.View Dialog view to load a BIDS Dataset anat_select_config_to_load : traits.ui.View Dialog view to load the configuration file of the anatomical pipeline diffusion_imaging_model_select_view : traits.ui.View Dialog view to select the diffusion acquisition model dmri_select_config_to_load : traits.ui.View Dialog view to load the configuration file of the diffusion MRI pipeline fmri_select_config_to_load : traits.ui.View Dialog view to load the configuration file of the fMRI pipeline """ creation_mode = Enum("Load BIDS dataset", "Install Datalad BIDS dataset") install_datalad_dataset_via_ssh = Bool(True) ssh_user = String("remote_username") ssh_pwd = Password("") ssh_remote = String("IP address/ Machine name") datalad_dataset_path = Directory( "/shared/path/to/existing/datalad/dataset") anat_runs = List() anat_run = Enum(values="anat_runs") dmri_runs = List() dmri_run = Enum(values="dmri_runs") fmri_runs = List() fmri_run = Enum(values="fmri_runs") summary_view_button = Button("Pipeline processing summary") pipeline_processing_summary_view = VGroup( Item("pipeline_processing_summary")) dataset_view = VGroup( VGroup( HGroup( Item( "base_directory", width=-0.3, style="readonly", label="", resizable=True, ), Item( "number_of_subjects", width=-0.3, style="readonly", label="Number of participants", resizable=True, ), "summary_view_button", ), label="BIDS Dataset", ), spring, HGroup( Group( Item("subject", style="simple", show_label=True, resizable=True)), Group( Item("subject_session", style="simple", label="Session", resizable=True), visible_when='subject_session!=""', ), springy=True, ), spring, Group( Item("t1_available", style="readonly", label="T1", resizable=True), HGroup( Item( "dmri_available", style="readonly", label="Diffusion", resizable=True, ), Item( "diffusion_imaging_model", label="Model", resizable=True, enabled_when="dmri_available", ), ), Item("fmri_available", style="readonly", label="BOLD", resizable=True), label="Modalities", ), spring, Group( Item( "anat_last_date_processed", label="Anatomical pipeline", style="readonly", resizable=True, enabled_when="t1_available", ), Item( "dmri_last_date_processed", label="Diffusion pipeline", style="readonly", resizable=True, enabled_when="dmri_available", ), Item( "fmri_last_date_processed", label="fMRI pipeline", style="readonly", resizable=True, enabled_when="fmri_available", ), label="Last date processed", ), spring, Group(Item("number_of_cores", resizable=True), label="Processing configuration"), "550", spring, springy=True, ) traits_view = QtView(Include("dataset_view")) create_view = View( Item("creation_mode", style="custom"), Group( Group( Item("base_directory", label="BIDS Dataset"), visible_when='creation_mode=="Load BIDS dataset"', ), Group( Item("install_datalad_dataset_via_ssh"), visible_when='creation_mode=="Install Datalad/BIDS dataset"', ), Group( Item( "ssh_remote", label="Remote ssh server", visible_when="install_datalad_dataset_via_ssh", ), Item( "ssh_user", label="Remote username", visible_when="install_datalad_dataset_via_ssh", ), Item( "ssh_pwd", label="Remote password", visible_when="install_datalad_dataset_via_ssh", ), Item( "datalad_dataset_path", label="Datalad/BIDS Dataset Path/URL to be installed", ), Item("base_directory", label="Installation directory"), visible_when='creation_mode=="Install Datalad/BIDS dataset"', ), ), kind="livemodal", title="Data creation: BIDS dataset selection", # style_sheet=style_sheet, width=modal_width, buttons=["OK", "Cancel"], ) subject_view = View( Group(Item("subject", label="Selected Subject")), kind="modal", title="Subject and session selection", # style_sheet=style_sheet, width=modal_width, buttons=["OK", "Cancel"], ) subject_session_view = View( Group( Item("subject", style="readonly", label="Selected Subject"), Item("subject_session", label="Selected Session"), ), kind="modal", title="Session selection", # style_sheet=style_sheet, width=modal_width, buttons=["OK", "Cancel"], ) dmri_bids_acq_view = View( Group(Item("dmri_bids_acq", label="Selected model"), ), kind="modal", title="Selection of diffusion acquisition model", # style_sheet=style_sheet, width=modal_width, buttons=["OK", "Cancel"], ) anat_warning_view = View( Group(Item("anat_warning_msg", style="readonly", show_label=False), ), title="Warning : Anatomical T1w data", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) anat_config_error_view = View( Group( Item("anat_config_error_msg", style="readonly", show_label=False), ), title="Error", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) dmri_warning_view = View( Group(Item("dmri_warning_msg", style="readonly", show_label=False), ), title="Warning : Diffusion MRI data", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) dmri_config_error_view = View( Group( Item("dmri_config_error_msg", style="readonly", show_label=False), ), title="Error", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) fmri_warning_view = View( Group(Item("fmri_warning_msg", style="readonly", show_label=False), ), title="Warning : fMRI data", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) fmri_config_error_view = View( Group( Item("fmri_config_error_msg", style="readonly", show_label=False), ), title="Error", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) open_view = View( Item("creation_mode", label="Mode"), Group( Item("install_datalad_dataset_via_ssh"), Item( "ssh_remote", label="Remote ssh server", visible_when="install_datalad_dataset_via_ssh", ), Item( "ssh_user", label="Remote username", visible_when="install_datalad_dataset_via_ssh", ), Item( "ssh_pwd", label="Remote password", visible_when="install_datalad_dataset_via_ssh", ), Item( "datalad_dataset_path", label="Datalad/BIDS Dataset Path/URL to be installed", ), Item("base_directory", label="Installation directory"), visible_when='creation_mode=="Install Datalad BIDS dataset"', ), Group( Item("base_directory", label="BIDS Dataset"), visible_when='creation_mode=="Load BIDS dataset"', ), kind="livemodal", title="BIDS Dataset Creation/Loading", # style_sheet=style_sheet, width=600, height=250, buttons=["OK", "Cancel"], ) anat_select_config_to_load = View( Group( Item("anat_config_to_load_msg", style="readonly", show_label=False), Item( "anat_config_to_load", style="custom", editor=EnumEditor(name="anat_available_config"), show_label=False, ), ), title="Select configuration for anatomical pipeline", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) anat_custom_map_view = View( Group( Item( "anat_custom_last_stage", editor=EnumEditor(name="anat_stage_names"), style="custom", show_label=False, ), ), title="Select until which stage to process the anatomical pipeline.", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) diffusion_imaging_model_select_view = View( Group(Item("diffusion_imaging_model", label="Diffusion MRI modality"), ), title="Please select diffusion MRI modality", kind="modal", width=modal_width, buttons=["OK", "Cancel"], ) dmri_select_config_to_load = View( Group( Item("dmri_config_to_load_msg", style="readonly", show_label=False), ), Item( "dmri_config_to_load", style="custom", editor=EnumEditor(name="dmri_available_config"), show_label=False, ), title="Select configuration for diffusion pipeline", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) dmri_custom_map_view = View( Group( Item( "dmri_custom_last_stage", editor=EnumEditor(name="dmri_stage_names"), style="custom", show_label=False, ), ), title="Select until which stage to process the diffusion pipeline.", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) fmri_select_config_to_load = View( Group( Item("fmri_config_to_load_msg", style="readonly", show_label=False), ), Item( "fmri_config_to_load", style="custom", editor=EnumEditor(name="fmri_available_config"), show_label=False, ), title="Select configuration for fMRI pipeline", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) fmri_custom_map_view = View( Group( Item( "fmri_custom_last_stage", editor=EnumEditor(name="fmri_stage_names"), style="custom", show_label=False, ), ), title="Select until which stage to process the fMRI pipeline.", kind="modal", width=modal_width, # style_sheet=style_sheet, buttons=["OK", "Cancel"], ) def _summary_view_button_fired(self): self.configure_traits(view="pipeline_processing_summary_view")
class DummyDataView3(BaseDataView): description = ( "Empty dummy data view that actually has a even longer description") view = View(VGroup())
class DummyDataView2(BaseDataView): description = None view = View(VGroup())
class DummyDataView1(BaseDataView): description = "Empty data view with a long description" view = View(VGroup())
def traits_view(self): if is_display_small(): w_view = 400 else: w_view = 510 parameters_group = VGroup( Item('_'), HGroup( Item('handler.edit_prior', show_label=False, width=100), Spring(), ), Item('_'), HGroup( VGroup( Spring(), Item('handler.pi_hinton_diagram', style='custom', resizable=False, show_label=False, width=w_view), Spring(), ), Spring(), VGroup( Spring(), Item('handler.view_pi', show_label=False), Spring() ), ), Item('_'), HGroup( VGroup( Item('handler.theta_views', show_label=False), Item('handler.theta_view', style='custom', resizable=False, show_label=False, width = w_view), Spring() ), VGroup( Spring(), Item('handler.view_theta', show_label=False), Spring() ) ), ) body = VGroup( Include('info_group'), parameters_group ) traits_view = View(body, buttons=[OKButton], resizable=True) return traits_view
class Recorder(HasTraits, ICameraListener): """Container to save all records of a experiment""" #========================================================================= # Important components to interact #========================================================================= plotview = Instance(PlotView, ()) #========================================================================= # Properties of the recorder #========================================================================= input_ports = List(Port) container = List(List) record_information = List() images = List() record_mode = Bool() logger = getLogger('Application') def __init__(self, record_mode): self.logger.debug('Initialize Recorder') self.record_mode = record_mode self.plotview.model = self self.result_viewer = ResultViewer(self) def append(self, info, rec): """Appends new values to the recorder. :param info: Values of the input ports. :type info: List(Float) :param rec: Recording time. :type rec: str. """ pid, value = info for i in range(self.n): p = self.input_ports[i] if p.id == pid: self.container[i].append((rec, value)) def reset(self, input_ports): """Reset all information of the recorder :param input_ports: All input ports of the measuring card :type input_ports: List(Port) """ del self.input_ports[:] del self.container[:] del self.record_information[:] self.plotview.update_subplots(input_ports) self.n = len(input_ports) for i in range(self.n): self.input_ports.append(input_ports[i]) self.container.append([]) def get_values(self): """Returns all recorded values""" res = [] for i in range(len(self.container[0])): row = [] for j in range(self.n): rec, val = self.container[j][i] row.append(val) row.insert(0, time_to_secs(rec)) res.append(row) return array(res) #========================================================================= # Update methods #========================================================================= def _update_record_information(self, index): """Update the record information by the given index :param index: Index of the values which should show :type index: int """ self.index = index del self.record_information[:] for i in range(self.n): rec, val = self.container[i][index] label = '{0}: {1:.3f}'.format(self.input_ports[i].name, val) self.record_information.append(label) self.record_information.append('Time: {0}'.format(rec)) if not self.show_reference: files = get_all_files(images_dir) self.update_reference(files[0]) self.plotview.update_focus_point(index) self.result_viewer.update_image(index) def update_reference(self, f): """Load the reference image from the reference dir""" self.logger.debug("Update reference image [Recorder]") self.reference_image = ImageResource(join(resized_images_dir, f)) self.show_reference = True def _update_plots(self): # Update all values with the currently values of the recorder. self.plotview.update_values(self.get_values()) def update_image(self, index): self.result_viewer.show_recorded_image(index) #========================================================================= # Methods to save and load the data #========================================================================= def save(self): self.logger.debug("Save recorded values [Recorder]") Recorder.save_values(self.get_values()) Recorder.save_images(self.images) @staticmethod def save_values(values): save(join(recorder_dir, recording_file), values) @staticmethod def save_images(images): data = {} data["images"] = [] for img in images: data["images"].append(img) with open(join(recorder_dir, recorder_file), 'w') as f: dump(data, f, indent=2) def load(self, input_ports): self.logger.debug("Load recorded values [Recorder]") with open(join(recorder_dir, recorder_file), 'r') as f: data = jload(f) self.images = data["images"] values = load(join(recorder_dir, recording_file)) self.reset(input_ports) nv = len(values) nip = len(input_ports) self.plotview.update_subplots(input_ports) self.plotview.update_values(values) for i in range(nv): t = secs_to_time(values[i, 0]) for j in range(nip): self.container[j].append((t, values[i, j + 1])) self.result_viewer.show_images=False self._update_record_information(0) self.show_images=True #========================================================================= # Traitsview + Traitsevent #========================================================================= result_viewer = Instance(ResultViewer) scroll_able = Bool(True) show_images = Bool(False) show_reference = Bool(False) reference_image = Image() def _show_images_changed(self): self.result_viewer.show_images=self.show_images view = View( VGroup( HGroup( VGroup( InstanceUItem('plotview', style='custom', width=400), VGroup( UItem('record_information', editor=ListStrEditor(auto_add=False, editable=False)), label="Recorded values:", visible_when='show_images' ) ), VGroup( VGroup( UItem('reference_image', width=300, height=225), label='Reference Image:', visible_when='show_reference' ), VGroup( UItem('result_viewer', style='custom', visible_when='show_images'), ), layout='normal' ), ) ) )