Multiple stimuli

72 views
Skip to first unread message

Asad Malik

unread,
Nov 27, 2016, 11:56:31 AM11/27/16
to TVB Users
Hi,

Is there a way for me to define two or more stimuli in a simulation? Basically, I'm looking to simulate a paradigm with multiple conditions.

Thanks,
Asad

Lia Domide

unread,
Nov 28, 2016, 7:05:25 AM11/28/16
to TVB Users
Hi Asad,

From the Web interface of TVB currently you can only apply one Stimulus.
But from the console interface, you could have multiple stimulus.
See attached iPython (author Marmaduke Woodman).

I hope this helps,
Lia.
multiple_stimuli.ipynb

Asad Malik

unread,
Nov 30, 2016, 6:09:11 AM11/30/16
to tvb-...@googlegroups.com
Hi Lia,

Many thanks. This is very helpful. 

Best,
Asad

--
You received this message because you are subscribed to a topic in the Google Groups "TVB Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tvb-users/z4XhuxZpZZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tvb-users+unsubscribe@googlegroups.com.
To post to this group, send email to tvb-...@googlegroups.com.
Visit this group at https://groups.google.com/group/tvb-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/tvb-users/781268e8-e3d2-495e-bb26-6a9741e4cb24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

anna.c...@gmail.com

unread,
Oct 1, 2020, 11:38:58 AM10/1/20
to TVB Users
Hello,

I got to this quite old discussion because I am interested to inject multiple stimuli in the network (I am using tvb running on Python 3). Using the same approach as in multiple_stimuli.ipynb, I obtain “stimulus" as a <__main__.MultiStimuliRegion at 0x1a1c266750> , where stimulus.stimuli is a tuple having the following elements:
(<tvb.datatypes.patterns.StimuliRegion at 0x1a1b603dd0>,
 <tvb.datatypes.patterns.StimuliRegion at 0x1a1c1db5d0>,
 <tvb.datatypes.patterns.StimuliRegion at 0x1a1c266a90>),
where each element is for one stimulus.

After running simulator.Simulator, I get the following error in sim.configure():
"
tvb.basic.neotraits.ex.TraitAttributeError: required attribute referenced before assignment. Use a default or assign a value before reading it
  attribute tvb.datatypes.patterns.StimuliRegion.connectivity = Attr(field_type=<class 'tvb.datatypes.connectivity.Connectivity'>, default=None, required=True)
"

On the contrary, if I provide to simulator.Simulator stimulus.stimuli[0] (i.e., only one of the three stimuli), then sim.configure() works smoothly. Do you have any hint on how to solve this?

Thank you for any help you can offer,
Anna

Il giorno mercoledì 30 novembre 2016 alle 06:09:11 UTC-5 asadm...@gmail.com ha scritto:
Hi Lia,

Many thanks. This is very helpful. 

Best,
Asad

On Mon, Nov 28, 2016 at 12:05 PM, Lia Domide <ldo...@gmail.com> wrote:
Hi Asad,

From the Web interface of TVB currently you can only apply one Stimulus.
But from the console interface, you could have multiple stimulus.
See attached iPython (author Marmaduke Woodman).

I hope this helps,
Lia.

--
You received this message because you are subscribed to a topic in the Google Groups "TVB Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tvb-users/z4XhuxZpZZY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tvb-users+...@googlegroups.com.

WOODMAN Michael

unread,
Oct 1, 2020, 3:08:27 PM10/1/20
to tvb-...@googlegroups.com
hi

It’s not very easy to understand why this happens without the full script / notebook.  Can you share it (direct email to me if you prefer is ok)?

Cheers,
Marmaduke

You received this message because you are subscribed to the Google Groups "TVB Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tvb-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tvb-users/4c9f8246-8360-4e2a-ae7d-03536431948dn%40googlegroups.com.

anna.c...@gmail.com

unread,
Oct 5, 2020, 10:56:31 AM10/5/20
to TVB Users
Hello,

For anyone willing to use multiple stimuli, Paula Popa proposed a solution at this link: https://req.thevirtualbrain.org/browse/TVB-2806 . The code snippet with the correct indentation is the following:

from tvb.basic.neotraits.api import NArray, Attr

class MultiStimuliRegion(patterns.StimuliRegion):
    connectivity = Attr(connectivity.Connectivity, required=False)
    temporal = Attr(field_type=equations.TemporalApplicableEquation, required=False)
    weight = NArray(required=False)

    def __init__(self, *stimuli):
        super(MultiStimuliRegion, self).__init__()
        self.stimuli = stimuli
    def configure_space(self, *args, **kwds):
        [stim.configure_space(*args, **kwds) for stim in self.stimuli]
    def configure_time(self, *args, **kwds):
        [stim.configure_time(*args, **kwds) for stim in self.stimuli]
    def __call__(self, *args, **kwds):
        return np.array([stim(*args, **kwds) for stim in self.stimuli]).sum(axis=0)

Thank you, Paula, for the solution you provided. It works perfectly! Also thank to Marmaduke Woodman for the prompt help.

Cheers,
Anna
Reply all
Reply to author
Forward
0 new messages