pyhgf icon indicating copy to clipboard operation
pyhgf copied to clipboard

Switching HGF

Open sumiya-kuroda opened this issue 3 months ago • 9 comments

Hello, PyHGF community!

I am interested in implementing switching HGF, e.g., https://ieeexplore.ieee.org/document/9518229, to model my animal behavior dataset.

Has anyone managed to implement switching HGF with PyHGF?

sumiya-kuroda avatar Oct 13 '25 13:10 sumiya-kuroda

Hi @sumiya-kuroda ,

Thank you for pointing that out :) We do not have the switching HGF in PyHGF at the moment, and I don't think this is implemented in the Julia toolbox either (@PTWaade ?), but this would be a nice addition to the package. I won't have the time to do this in the coming week, but I will let the issue open so I can go back to it at some point. In the meantime, if you want to give it a try, I can provide guidance on how to add custom nodes.

LegrandNico avatar Oct 20 '25 07:10 LegrandNico

@SylvainEstebe, maybe a nice project for you once you are done with the Beta nodes?

LegrandNico avatar Oct 20 '25 07:10 LegrandNico

Thank you very much! @SylvainEstebe @LegrandNico

I am still trying to get familiar with HGF, so it would be super helpful if you could help us!

sumiya-kuroda avatar Oct 22 '25 13:10 sumiya-kuroda

Hey @sumiya-kuroda - just chiming in to say that this is interesting, of course :) Would you say a little of why exactly you want the switching HGF specifically? Is it a task where that is particularly appropriate? :)

PTWaade avatar Oct 30 '25 14:10 PTWaade

Hello @PTWaade, thanks for getting back to me! Yes, and happy to hear any feedback, since I’m still a beginner with HGF.

In our lab, we have collected behavioral data from two species—mice and humans—performing the same change detection task to study how they integrate sensory evidence to decide when to act. In this task, animals can also form expectations about when the stimulus change is likely to occur, since the changes follow a block structure. The block type switches multiple times within a session, requiring the animals to continually update their “block prior” as they perform the task.

One thing we found is that there are striking differences in behavioral performance between the two species, and we hypothesize that this may arise from the use of different strategies (we also have behavioral quantifications that I can share with you if you’re interested). Even within a single species, we’ve observed that animals behave quite differently across trial epochs, which is consistent with what others have reported using HMM-based analyses of behavior. e.g. https://anneurai.net/2024/01/26/a-glm-hmm-deep-dive/

To model their behavior, I first built a simplified version of an IO-HMM using multinomial GLMs. However, it did not capture the behavioral variance very well, which we think is because the model did not incorporate all of the rich behavioral readouts available in our dataset. I believe the HGF framework could help address this by allowing us to design a complicated response model — I just need to figure out how to implement it :) My initial idea was to combine the HGF with an IO-HMM, similar to what I did with the GLM, but then I came across the paper on switching HGF that I shared with you.

sumiya-kuroda avatar Oct 30 '25 19:10 sumiya-kuroda

Dear @sumiya-kuroda

This sounds very interesting indeed! Our group have also been ding some work on comparing human and mouse behavior on tasks, modeled with the HGF, although I have not personally been involved in this.

Perhaps you would like to present your data at one of our group meetings, and we can discuss in a bit more detail how we might be able to help, and how an HGF model of this data might look? The switching HGF is a good suggestion, and we would like to implement this in our software to be readily available, but we should ensure that it is compatible with the larger framework we are building. It might also be an option to use RxInfer.jl (the software in which the model described in the paper you linked was originally implemented), in combination with the Julia HGF package (which would allow it to be fit to behavioural data); we have wanted to combine these two softwares for a while, but haven't done it yet.

Well, in other words: I think it might be useful to speak in person, and you would be welcome to do a short presentation at our group meeting so that the group can participate in the discussion, if you would like! Does that sound useful!

With all the best, Peter

PTWaade avatar Nov 07 '25 12:11 PTWaade

Hello @PTWaade ,

That sounds great — thank you! Any feedback would be extremely helpful, as I’ve been a bit stuck with this PhD project. I’ll send you an email later today. Feel free to leave this issue open or closed, whichever you prefer.

sumiya-kuroda avatar Nov 09 '25 20:11 sumiya-kuroda

Perfect - let's talk more on email!

PTWaade avatar Nov 10 '25 07:11 PTWaade

We can keep this open until we have something implemented.

LegrandNico avatar Nov 10 '25 11:11 LegrandNico