Пример #1
0
class SectionClassification(SectionCore):

    SECTION_NAME = SECTION_NAME_CLASSIFICATION

    OPTIONS = [('%s_classification' % x, [ ('%s_classification_envpath' % x, \
                                                StringTrait('', 1000, label='Classifier folder',
                                                            widget_info=StringTrait.STRING_PATH)),
                                           ('%s_classification_regionname' % x,
                                            SelectionTrait2(None, [], label='Region name')),
                                           ('%s_classification_annotationfileext' % x,
                                            StringTrait('xml', 50, label='Annotation ext.')) ]) \
                   for x in (CH_PRIMARY+CH_OTHER)] + \
            [('collectsamples', [ ('collectsamples', BooleanTrait(False)),
                                 ('collectsamples_prefix', StringTrait('',100))]),
             ('merged_channel', [ ('merge_primary', BooleanTrait(True, label='primary')),
                                  ('merge_secondary', BooleanTrait(True, label='secondary')),
                                  ('merge_tertiary', BooleanTrait(True, label='tertiary')) ])
             ] + \
             [('%s_classification' %CH_VIRTUAL[0],
               [ ('%s_classification_envpath' %CH_VIRTUAL[0], \
                      StringTrait('', 1000, label='Classifier folder',
                                  widget_info=StringTrait.STRING_PATH)),
                 ('%s_primary_region' %CH_VIRTUAL[0],
                  SelectionTrait2(None, [], label='')),
                 ('%s_secondary_region' %CH_VIRTUAL[0],
                  SelectionTrait2(None, [], label='')),
                 ('%s_tertiary_region' %CH_VIRTUAL[0],
                  SelectionTrait2(None, [], label='')),
                 ('%s_classification_annotationfileext' %CH_VIRTUAL[0],
                  StringTrait('xml', 50, label='Annotation ext.')),
                 ('%s_classification_regionname' %CH_VIRTUAL[0],
                  SelectionTrait2(None, [], label="Region name"))
                 ])]
Пример #2
0
class SectionEventSelection(SectionCore):

    SECTION_NAME = SECTION_NAME_EVENT_SELECTION

    OPTIONS = [
        ('event_selection',
         [('eventchannel',
           SelectionTrait2(None, [], label='Channel')),
          ('event_selection',
           BooleanTrait(True, label='Event Selection')),
          ('backwardrange',
           FloatTrait(0, -1, 4000, label='Duration [pre]')),
          ('forwardrange',
           FloatTrait(0, -1, 4000, label='Duration [post]')),

          ('duration_unit',
           SelectionTrait2(TimeConverter.FRAMES,
                           TimeConverter.units,
                           label='Duration unit')),
          ('backwardrange_min', BooleanTrait(False, label='Min.')),
          ('forwardrange_min', BooleanTrait(False, label='Min.')),
          ('maxindegree', IntTrait(1, 0, 4000, label='Max in-degree')),
          ('maxoutdegree', IntTrait(2, 0, 4000, label='Max out-degree')),
          ]),

        ('supervised_event_selection',
         [('supervised_event_selection',
           BooleanTrait(True, label='Supervised',
                        widget_info=BooleanTrait.RADIOBUTTON)),
          ('labeltransitions',
           StringTrait('', 200, label='Class transition motif(s)')),
          ('backwardlabels',
           StringTrait('', 200, label='Class filter [pre]',
                       mask='(\d+,)*\d+')),
          ('forwardlabels',
           StringTrait('', 200, label='Class filter [post]',
                       mask='(\d+,)*\d+')),
          ('backwardcheck',
           FloatTrait(2, 0, 4000, label='Filter duration [pre]')),
          ('forwardcheck',
           FloatTrait(2, 0, 4000, label='Filter duration [post]')),
          ]),

        ('unsupervised_event_selection',
         [('unsupervised_event_selection',
           BooleanTrait(False, label='Unsupervised',
                        widget_info=BooleanTrait.RADIOBUTTON)),
          ('min_event_duration',
           IntTrait(3, 1, 100, label='Min. event duration')),
          ('num_clusters',
           IntTrait(6, 2, 15, label='Number of clusters',)),
          ('min_cluster_size',
           IntTrait(2, 1, 10, label='Min. cluster size',)),
          ])
        ]
Пример #3
0
class SectionTracking(SectionCore):

    SECTION_NAME = SECTION_NAME_TRACKING

    OPTIONS = [
        ('tracking', [
            ('region', SelectionTrait2(None, [], label='Region name')),
            ('tracking_maxobjectdistance',
             IntTrait(0, 0, 4000, label='Max object x-y distance')),
            ('tracking_maxtrackinggap',
             IntTrait(0, 0, 4000, label='Max time-point gap')),
            ('tracking_maxsplitobjects',
             IntTrait(0, 0, 4000, label='Max split events')),
            ('tracking_exporttrackfeatures',
             BooleanTrait(True, label='Export tracks')),
            ('tracking_compressiontrackfeatures',
             SelectionTrait(COMPRESSION_FORMATS[0],
                            COMPRESSION_FORMATS,
                            label='Compression')),
        ]),
        ('visualization', [
            ('tracking_visualization',
             BooleanTrait(False, label='Visualization')),
            ('tracking_visualize_track_length',
             IntTrait(5, -1, 10000, label='Max. time-points')),
            ('tracking_centroid_radius',
             IntTrait(3, -1, 50, label='Centroid radius')),
        ]),
    ]
Пример #4
0
class SectionTracking(SectionCore):

    SECTION_NAME = SECTION_NAME_TRACKING

    OPTIONS = [
        ('tracking', [
            ('region', SelectionTrait2(None, [], label='Region name')),
            ('tracking_maxobjectdistance',
             IntTrait(0, 0, 4000, label='Max object x-y distance')),
            ('tracking_maxtrackinggap',
             IntTrait(0, 0, 4000, label='Max time-point gap')),
            ('tracking_maxsplitobjects',
             IntTrait(0, 0, 4000, label='Max split events')),
        ]),
    ]
Пример #5
0
    def __init__(self,
                 plugin_cls,
                 plugin_name,
                 settings,
                 manager,
                 set_default=True):
        self._settings = settings
        self._section = manager.section
        self._lookup = {}
        self._lookup_reverse = {}
        self._observer_traits = []
        self._plugin_name = plugin_name
        params = plugin_cls.PARAMS
        trait_name_template = manager.get_trait_name_template(
            plugin_cls.NAME, plugin_name)

        # inject traits controlling plugin requirements dynamically
        foreign_managers = dict([(mngr.name, mngr)
                                 for mngr in PLUGIN_MANAGERS])
        if not plugin_cls.REQUIRES is None:
            for idx, require in enumerate(plugin_cls.REQUIRES):
                # get the foreign manager that controls the requirement
                foreign_manager = foreign_managers[require]
                # get the names of plugin instances of the foreign manager
                names = foreign_manager.get_plugin_names()
                # define an update callback which is triggered every time the requirement (plugin instance) is changed
                update_callback = lambda referee: lambda new, old: foreign_manager.handle_referee(
                    new, old, referee)
                # define a new trait for the current requirement
                trait = SelectionTrait2(None if len(names) < 1 else names[0],
                                        names,
                                        label=foreign_manager.display_name,
                                        update_callback=update_callback(
                                            (manager.name, plugin_name)))
                # register this trait to the foreign manager which controls the dependency for change notifications
                foreign_manager.register_observer(trait)
                self._observer_traits.append((foreign_manager, trait))
                params.append((plugin_cls._REQUIRE_STR % idx, trait))

        for param_name, trait in params:
            trait_name = trait_name_template % param_name
            self._lookup[param_name] = trait_name
            self._lookup_reverse[trait_name] = param_name
            settings.register_trait(self._section, self.GROUP_NAME, trait_name,
                                    trait)
            if set_default or not settings.has_option(self._section,
                                                      trait_name):
                settings.set(self._section, trait_name, trait.default_value)
Пример #6
0
class SectionObjectdetection(SectionCore):

    SECTION_NAME = SECTION_NAME_OBJECTDETECTION

    OPTIONS = [
      ('primary_image',
       [('primary_channelid',
            SelectionTrait2(None, [], label='Primary channel ID')),
        ('primary_normalizemin',
            IntTrait(0, -2**16, 2**16, label='Min.')),
        ('primary_normalizemax',
            IntTrait(255, -2**16, 2**16, label='Max.')),
        ('primary_zslice_selection',
            BooleanTrait(True, label='Z-slice selection',
                         widget_info=BooleanTrait.RADIOBUTTON)),
        ('primary_flat_field_correction',
            BooleanTrait(False, label='Z-slice flat field correction',
                         widget_info=BooleanTrait.CHECKBOX)),
        ('primary_flat_field_correction_image_dir',
            StringTrait('', 1000, label='Correction image directory',
                                   widget_info=StringTrait.STRING_PATH)),
        ('primary_zslice_selection_slice',
            IntTrait(1, 0, 1000, label='Slice')),
        ('primary_zslice_projection',
            BooleanTrait(False, label='Z-slice projection',
                         widget_info=BooleanTrait.RADIOBUTTON)),
        ('primary_zslice_projection_method',
            SelectionTrait(ZSLICE_PROJECTION_METHODS[0],
                           ZSLICE_PROJECTION_METHODS, label='Method')),
        ('primary_zslice_projection_begin',
            IntTrait(1, 0, 1000, label='Begin')),
        ('primary_zslice_projection_end',
            IntTrait(1, 0, 1000, label='End')),
        ('primary_zslice_projection_step',
         IntTrait(1, 1, 1000, label='Step')),
        # these two options are nopes, just to have no
        # special casing in channel classes
        ('primary_channelregistration_x',
         IntTrait(0, -99999, 99999, label='Shift X')),
        ('primary_channelregistration_y',
         IntTrait(0, -99999, 99999, label='Shift Y')),
        ]),
      ] + \
      unlist(
      [[('%s_image' % prefix,
       [('%s_channelid' % prefix,
            SelectionTrait2(None, [], label='%s channel ID' % name)),
        ('%s_normalizemin' % prefix,
            IntTrait(0, -2**16, 2**16, label='Min.')),
        ('%s_normalizemax' % prefix,
            IntTrait(255, -2**16, 2**16, label='Max.')),

        ('%s_zslice_selection' % prefix,
            BooleanTrait(True, label='Z-slice selection',
                         widget_info=BooleanTrait.RADIOBUTTON)),
        ('%s_flat_field_correction' % prefix,
            BooleanTrait(False, label='Z-slice flat field correction',
                         widget_info=BooleanTrait.CHECKBOX)),
        ('%s_flat_field_correction_image_dir' % prefix,
            StringTrait('', 1000, label='Correction image directory',
                                   widget_info=StringTrait.STRING_PATH)),
        ('%s_zslice_selection_slice' % prefix,
            IntTrait(1, 0, 1000, label='Slice')),
        ('%s_zslice_projection' % prefix,
            BooleanTrait(False, label='Z-slice projection',
                         widget_info=BooleanTrait.RADIOBUTTON)),
        ('%s_zslice_projection_method' % prefix,
            SelectionTrait(ZSLICE_PROJECTION_METHODS[0],
                           ZSLICE_PROJECTION_METHODS, label='Method')),
        ('%s_zslice_projection_begin' % prefix,
            IntTrait(1, 0, 1000, label='Begin')),
        ('%s_zslice_projection_end' % prefix,
            IntTrait(1, 0, 1000, label='End')),
        ('%s_zslice_projection_step' % prefix,
            IntTrait(1, 1, 1000, label='Step')),
       ]),

      ('%s_registration' % prefix,
       [('%s_channelregistration_x' % prefix,
            IntTrait(0, -99999, 99999, label='Shift X')),
        ('%s_channelregistration_y' % prefix,
            IntTrait(0, -99999, 99999, label='Shift Y')),
       ]),

       ]
       for name, prefix in [('Secondary', 'secondary'),
                            ('Tertiary', 'tertiary'),
                            # moste merged channel options are nopes
                            # to avoid special casing
                            ('Merged', 'merged')
                            ]]
      )
Пример #7
0
class SectionTracking(SectionCore):

    SECTION_NAME = SECTION_NAME_TRACKING

    OPTIONS = [
        ('tracking', [
            ('tracking_regionname',
             SelectionTrait2(None, [], label='Region name')),
            ('tracking_maxobjectdistance',
             IntTrait(0, 0, 4000, label='Max object x-y distance')),
            ('tracking_maxtrackinggap',
             IntTrait(0, 0, 4000, label='Max time-point gap')),
            ('tracking_maxsplitobjects',
             IntTrait(0, 0, 4000, label='Max split events')),
            ('tracking_maxindegree', IntTrait(1,
                                              0,
                                              4000,
                                              label='Max in-degree')),
            ('tracking_maxoutdegree',
             IntTrait(2, 0, 4000, label='Max out-degree')),
            ('tracking_exporttrackfeatures',
             BooleanTrait(True, label='Export tracks')),
            ('tracking_compressiontrackfeatures',
             SelectionTrait(COMPRESSION_FORMATS[0],
                            COMPRESSION_FORMATS,
                            label='Compression')),
        ]),
        ('event_selection', [
            ('tracking_labeltransitions',
             StringTrait('',
                         200,
                         label='Class transition motif(s)',
                         mask='(\(\d+,\d+\),)*\(\d+,\d+\)')),
            ('tracking_backwardrange',
             FloatTrait(0, -1, 4000, label='Duration [pre]')),
            ('tracking_forwardrange',
             FloatTrait(0, -1, 4000, label='Duration [post]')),
            ('tracking_backwardlabels',
             StringTrait('',
                         200,
                         label='Class filter [pre]',
                         mask='(\d+,)*\d+')),
            ('tracking_forwardlabels',
             StringTrait('',
                         200,
                         label='Class filter [post]',
                         mask='(\d+,)*\d+')),
            ('tracking_backwardcheck',
             FloatTrait(2, 0, 4000, label='Filter duration [pre]')),
            ('tracking_forwardcheck',
             FloatTrait(2, 0, 4000, label='Filter duration [post]')),
            ('tracking_duration_unit',
             SelectionTrait2(TRACKING_DURATION_UNITS_DEFAULT[0],
                             TRACKING_DURATION_UNITS_DEFAULT,
                             label='Duration unit')),
            ('tracking_backwardrange_min', BooleanTrait(False, label='Min.')),
            ('tracking_forwardrange_min', BooleanTrait(False, label='Min.')),
        ]),
        ('visualization', [
            ('tracking_visualization',
             BooleanTrait(False, label='Visualization')),
            ('tracking_visualize_track_length',
             IntTrait(5, -1, 10000, label='Max. time-points')),
            ('tracking_centroid_radius',
             IntTrait(3, -1, 50, label='Centroid radius')),
        ]),
    ]