Exemplo n.º 1
0
        def setup(self, ctx):
            self._name = None
            self.is_first_run = True
            self.should_run = False

            assert ctx.spec.settings is not None
            self.names = set(setting["name"] for setting in ctx.spec.settings)

            if "name" in settingdict:
                pass
            elif namefun is not None:
                self._name = namefun(ctx)
            else:
                self.should_run = True

                self._append_view(TextView(self.header_str))

                base = "preproc"
                suggestion = base
                index = 1
                while suggestion in self.names:
                    suggestion = f"{base}{index}"
                    index += 1

                self.input_view = TextInputView(
                    text=suggestion,
                    isokfun=lambda text: forbidden_chars.search(text) is None)

                self._append_view(self.input_view)
                self._append_view(SpacerView(1))
Exemplo n.º 2
0
    def setup(self, ctx):
        if not hasattr(ctx.spec.models[-1],
                       "contrasts") or ctx.spec.models[-1].contrasts is None:
            ctx.spec.models[-1].contrasts = []

        self.names = set(contrast["name"]
                         for contrast in ctx.spec.models[-1].contrasts
                         if "name" in contrast)

        base = "contrast"
        index = 1
        suggestion = f"{base}{index}"
        while suggestion in self.names:
            suggestion = f"{base}{index}"
            index += 1

        self._append_view(TextView("Specify contrast name"))

        self.input_view = TextInputView(
            text=suggestion,
            isokfun=lambda text: forbidden_chars.search(text) is None)

        self._append_view(self.input_view)
        self._append_view(SpacerView(1))
        self.value = None
Exemplo n.º 3
0
    def setup(self, ctx):
        if (not hasattr(ctx.spec.features[-1], "contrasts")
                or ctx.spec.features[-1].contrasts is None):
            ctx.spec.features[-1].contrasts = []

        if len(ctx.spec.features[-1].contrasts) == 0:
            self._append_view(TextView("Specify contrasts"))
            self._append_view(SpacerView(1))

        self.names = set(
            contrast.get("name")
            for contrast in ctx.spec.features[-1].contrasts)

        base = "contrast"
        index = 1
        suggestion = f"{base}{index}"
        while suggestion in self.names:
            suggestion = f"{base}{index}"
            index += 1

        self._append_view(TextView("Specify contrast name"))

        self.input_view = TextInputView(
            text=suggestion,
            isokfun=lambda text: forbidden_chars.search(text) is None)

        self._append_view(self.input_view)
        self._append_view(SpacerView(1))
Exemplo n.º 4
0
 def setup(self, ctx):
     if ctx.spec.analyses[-1].contrasts is None:
         index = 1
     else:
         index = min(1, len(ctx.spec.analyses[-1].contrasts))
     suggestion = make_name_suggestion("contrast", index=index)
     self._append_view(TextView("Specify contrast name"))
     self.input_view = TextInputView(text=suggestion)
     self._append_view(self.input_view)
     self._append_view(SpacerView(1))
     self.value = None
Exemplo n.º 5
0
 def setup(self, ctx):
     self._append_view(TextView("Specify analysis name"))
     assert ctx.spec.analyses is not None
     self.names = set(analysis.name for analysis in ctx.spec.analyses)
     index = 0
     for analysis in ctx.spec.analyses:
         assert analysis.level is not None
         if analysis.level == "higher" and analysis.across == "subject":
             index += 1
     suggestion = make_name_suggestion("group", "analysis", index=index)
     self.input_view = TextInputView(text=suggestion)
     self._append_view(self.input_view)
     self._append_view(SpacerView(1))
Exemplo n.º 6
0
 def setup(self, ctx):
     self._append_view(TextView("Specify analysis name"))
     assert ctx.spec.analyses is not None and len(ctx.spec.analyses) > 0
     self.names = set(analysis.name for analysis in ctx.spec.analyses)
     baseSuggestion = self.nameSuggestionByAnalysisType[
         ctx.spec.analyses[-1].type]
     suggestion = baseSuggestion
     index = 1
     while suggestion in self.names:
         suggestion = f"{baseSuggestion}_{index}"
         index += 1
     self.input_view = TextInputView(text=suggestion)
     self._append_view(self.input_view)
     self._append_view(SpacerView(1))
Exemplo n.º 7
0
    def setup(self, ctx):
        self._append_view(TextView("Specify feature name"))

        assert ctx.spec.features is not None and len(ctx.spec.features) > 0

        self.names = set(feature.name for feature in ctx.spec.features)

        base = self.suggestions_by_type[ctx.spec.features[-1].type]
        suggestion = base
        index = 1
        while suggestion in self.names:
            suggestion = f"{base}{index}"
            index += 1

        self.input_view = TextInputView(
            text=suggestion,
            isokfun=lambda text: forbidden_chars.search(text) is None)

        self._append_view(self.input_view)
        self._append_view(SpacerView(1))
Exemplo n.º 8
0
    def setup(self, ctx):
        self._append_view(TextView("Specify model name"))

        assert ctx.spec.models is not None and len(ctx.spec.models) > 0

        self.names = set(model.name for model in ctx.spec.models)

        base = "model"
        suggestion = base
        index = 1
        while suggestion in self.names:
            suggestion = f"{base}{index}"
            index += 1

        self.input_view = TextInputView(
            text=suggestion,
            isokfun=lambda text: forbidden_chars.search(text) is None)

        self._append_view(self.input_view)
        self._append_view(SpacerView(1))
Exemplo n.º 9
0
 def setup(self, ctx):
     self.is_first_run = True
     entites_in_path = get_entities_in_path(self.file_obj.path)
     self.tags_obj = self.file_obj.tags
     while len(self.ask_if_missing_entities) > 0:
         entity = self.ask_if_missing_entities.pop(0)
         if (hasattr(self.tags_obj, entity)
                 and getattr(self.tags_obj, entity) is None
                 and entity not in entites_in_path):
             self.cur_entity = entity
             break
     if self.cur_entity is not None:
         self._append_view(
             TextView(f"No {self.cur_entity} name was specified"))
         self._append_view(TextView(f"Specify the {self.cur_entity} name"))
         suggestion = ""
         if self.suggest_file_stem:
             suggestion, _ = splitext(self.file_obj.path)
         self.tagval_input_view = TextInputView(text=suggestion,
                                                isokfun=self._isok)
         self._append_view(self.tagval_input_view)
         self._append_view(SpacerView(1))
Exemplo n.º 10
0
    def setup(self, ctx):
        self.is_first_run = True

        entites_in_path = get_entities_in_path(ctx.spec.files[-1].path)

        tags = ctx.spec.files[-1].tags
        while len(self.ask_if_missing_entities) > 0:
            entity = self.ask_if_missing_entities.pop(0)

            if entity in entites_in_path:
                continue

            if tags.get(entity) is not None:
                continue

            self.entity = entity
            break

        if self.entity is not None:
            self.entity_str = self.entity
            if self.entity_str in self.entity_display_aliases:
                self.entity_str = self.entity_display_aliases[self.entity_str]

            self._append_view(TextView(f"No {self.entity_str} name was specified"))
            self._append_view(TextView(f"Specify the {self.entity_str} name"))

            suggestion = ""
            if self.suggest_file_stem:
                suggestion, _ = splitext(ctx.spec.files[-1].path)

            self.input_view = TextInputView(
                text=suggestion, isokfun=lambda text: forbidden_chars.search(text) is None
            )

            self._append_view(self.input_view)
            self._append_view(SpacerView(1))
Exemplo n.º 11
0
 def setup(self, ctx):
     self._append_view(TextView(f"Specify the spatial map name"))
     self.input_view = TextInputView(self.desc)
     self._append_view(self.input_view)
     self._append_view(SpacerView(1))