Note
Click here to download the full example code
Conpute SVD#
import matplotlib.pyplot as plt
import numpy as np
import pycartool as cart
#### Import from Cartool files
#### Constants
### Simulate sources time course
Here we simulate the sources time course as random noise generators everywhere in the brain, expect in the first Region of interest where sources time course are simulated are sin waves in the x direction.
#### Create random noise
simulated_tc = np.random.normal(size=(n_sources, 3, n_times))
plt.figure()
plt.plot(simulated_tc[0, 0], color="navy")
plt.title("Time course of a source outside the first Roi")
plt.show()
#### Create sin wave in Roi
for elem in roi.groups_of_indexes[0]:
simulated_tc[elem][0] = sin
simulated_tc[elem][1] = np.zeros(sin.shape)
simulated_tc[elem][2] = np.zeros(sin.shape)
plt.figure()
plt.plot(sin, color="red")
plt.title("Time course of sources inside the first Roi (x direction)")
plt.show()
source_estimate_simulated = cart.ris.SourceEstimate(
simulated_tc, sfreq=sfreq, source_space=spi
)
#### Compute the regions of interest time course
plt.figure()
plt.plot(roi_t_simulated.sources_tc[0:4, 0, :].T)
plt.title("Rois time course")
plt.show()
Total running time of the script: ( 0 minutes 7.155 seconds)
Estimated memory usage: 502 MB