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.