Re: Error when using TemporalApplicableEquation

46 views
Skip to first unread message
Message has been deleted

Lia Domide

unread,
Aug 3, 2022, 9:36:48 AM8/3/22
to TVB Users
Hi,

If I copy your code in a test.py module, and execute it, it does not generate errors.
Could you please be more explicit at what point you get the error ?

Best,
Lia.

Silvana Huertas

unread,
Aug 3, 2022, 9:47:56 AM8/3/22
to TVB Users
Hi, 
I get that error when I run this line:  stimulusFin = MultiStimuliRegion(trainLeft, trainRight)

Thanks, 

Silvana

Lia Domide

unread,
Aug 3, 2022, 9:52:52 AM8/3/22
to TVB Users
Hi Silvana,

For me that works, both in a python console and on Jupyter lab.
What is your configuration?
I have Python 3.10.4, numpy 1.21.5 and tvb-library 2.6.1 (dev from github master) - should be very similar with tvb-library 2.6 from Pypi.

Best,
Lia.


Silvana Huertas

unread,
Aug 3, 2022, 9:56:20 AM8/3/22
to TVB Users
Hi, 

I re-run it in another computer and it works. So no idea what happened. 

Thank you, 

Silvana

WOODMAN Michael

unread,
Aug 8, 2022, 8:52:37 AM8/8/22
to tvb-...@googlegroups.com

hi


Can you include the traceback as well please?


Thanks,

Marmaduke


From: tvb-...@googlegroups.com <tvb-...@googlegroups.com> on behalf of Silvana Huertas <s.huert...@gmail.com>
Sent: Wednesday, August 3, 2022 2:24:10 PM
To: TVB Users
Subject: [RESEAUX SOCIAUX] [TVB] Error when using TemporalApplicableEquation
 
Hi all, 

I'm trying to generate a code for multi stimuli in region. However, I get an error saying "required attribute referenced before assignment. Use a default or assign a value before reading it attribute tvb.datatypes.patterns.SpatioTemporalPattern.temporal = Attr(field_type=<class 'tvb.datatypes.equations.TemporalApplicableEquation'>, default=None, required=True)" . I based my code in another post in this forum https://groups.google.com/g/tvb-users/c/a5FUVYsHB14/m/zvTG3pUeFwAJ

Could you please help me? Thanks :)

# Here we load the packages that we will need
from tvb.simulator.lab import *
import numpy as np

#We load the necessary variables
np.array
#I use the connectome of TVB that has 76 regions
conn = connectivity.Connectivity.from_file('connectivity_76.zip')

# configure stimulus spatial pattern.
#In this case I put stimulation only in the lM1 (51) and rM2(13).
#Next stimulation can have more regions of stimulation with different weight values
weightingLeft = np.zeros((76, ))
weightingRight = np.zeros((76, ))
#The weight of the stimulation in these regions is equal to 1. (Values between 0 and 1)
weightingLeft[[51]] = 1
weightingRight[[13]] =1

#Here we determine the values of the stimulus (form and parameters)
eqn_t = equations.Sinusoid

amp = 2; f = 0.002; w=2*np.pi*f; phase1=0; phase2=0;


# configure stimulus
class MultiStimuliRegion(patterns.StimuliRegion):
        def __init__(self, *stimuli):
            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)

#Here we generate a function with the sinusoidal stimulus
def make_train(conn,weighting , params):
        eqn_t = equations.TemporalApplicableEquation(equation='A*sin(w*var+phi_0)', parameters=params)
        stimulus = patterns.StimuliRegion(
            temporal=eqn_t,
            connectivity=conn,
            weight=weighting)
        return stimulus
   

#Here we create the stimuli using the previos functions    
paramsLeft={"A": amp, "w": w, "phi_0":phase1, "B": 1}
paramsRight={"A": amp, "w": 5.0, "phi_0":phase2, "B": 1}
trainLeft = make_train(conn,weightingLeft, paramsLeft)
trainRight = make_train(conn,weightingRight, paramsRight)

stimulusFin = MultiStimuliRegion(trainLeft, trainRight)
stimulusFin.configure_space()
time = np.arange(0,1)*30000
stimulusFin.configure_time(time)

--
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/2277be69-acc4-438d-a028-7864f274920dn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages