首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于来自analyze_recording()的“分析”中包含的信息,我如何在心理网络中试用后显示自定义反馈?

基于来自analyze_recording()的“分析”中包含的信息,我如何在心理网络中试用后显示自定义反馈?
EN

Stack Overflow用户
提问于 2021-10-28 16:02:22
回答 1查看 25关注 0票数 1

我想向参与者展示一个反馈页面,其中包含例如在他们刚刚完成的试验过程中检测到的点击次数。这是我想要做的:

代码语言:javascript
复制
class PracticeTrialMaker(StaticTrialMaker):
    give_end_feedback_passed = True
    performance_check_type = "performance"
    performance_check_threshold = 0
    end_performance_check_waits = True
    
    def get_end_feedback_passed_page(self, score):
    
        how_many_taps = "NA" if score is None else f"{(score):.0f}"
    
        return InfoPage(
            Markup(
                f"You tapped <strong>{how_many_taps}&#37 times;</strong>."
            ),
            time_estimate=5,
        )
    
    def performance_check(self, experiment, participant, participant_trials):
        # for now, just count number of taps detected
    
        n_taps_detected = participant_trials.analysis['num_resp_raw_all']
        failed = participant_trials.failed
    
        return {"score": n_taps_detected, "passed": not failed}

但我不知道如何找到/传递分析结果到performance_check……它们不包含在participant_trials或参与者或实验中,除非我完全遗漏了什么。

如何向参与者显示基于分析的反馈?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-28 18:43:38

方法get_end_feedback_passed_pageStaticTrialMaker结束时根据该试验生成器内所有试验的总体性能提供反馈。更准确地说,它仅在参与者成功达到性能阈值时显示反馈。

对于您的示例,我将在StaticTrial中使用show_feedback方法。这允许您在每个单独的试验之后提供反馈。然后,您可以通过调用试验中存储的分析输出(即self.details["analysis"] )来访问分析的输出(在方法analyze_recording中返回的字典)。以下是上下文中的一个示例:

代码语言:javascript
复制
class MyExperimentalTrial(StaticTrial):
    __mapper_args__ = {"polymorphic_identity": "custom_trial"}

    wait_for_feedback = True

    def gives_feedback(self, experiment, participant):
        return True

    def show_feedback(self, experiment, participant):
        output_analysis = self.details["analysis"]
        if output_analysis["num_taps"] > 20:
            return InfoPage(
                Markup(
                    f"""
                    <h3>Excellent!</h3>
                    <hr>
                    We detected {output_analysis["num_taps"]} taps. 
                    """
                ),
                time_estimate=5
            )
        else:
            return InfoPage(
                Markup(
                    f"""
                    <h3>VERY BAD...</h3>
                    """
                ),
                time_estimate=5
            )

请注意,您应该将其与gives_feedback结合使用,并在相应trialmaker check_performance_every_trial=False的定义中指定

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69757413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档