简体   繁体   English

生成用余弦调制的正弦波

[英]Generate sine wave modulated with a cosine

For research purposes, I'm trying to recreate the following (note I'm new to signal processing): 出于研究目的,我尝试重新创建以下内容(请注意,我是信号处理的新手):

A sleep spindle is defined by a sine wave which length is longer than 500 msec and whose frequency is within the band 12 to 14 Hz. 睡眠主轴由正弦波定义,该正弦波的长度大于500毫秒,并且其频率在12到14 Hz的频带内。 The sleep spindle template was therefore defined by a 13 Hz sine wave modulated with a cosine (in which the 1/2 period is the length of the template). 因此,睡眠主轴模板由一个以余弦调制的13 Hz正弦波定义(其中1/2周期是模板的长度)。 The length of the template was set to 1 second. 模板的长度设置为1秒。 This defines a band-pass filter centred on 13 Hz. 这定义了一个以13 Hz为中心的带通滤波器。

Citation: Poiseau, E. & Jobert, M. (1991). 引用:Poiseau,E.&Jobert,M.(1991)。 Matched filtering applied to the detection of spindles and k-complexes in sleep eeg. 匹配过滤应用于睡眠eeg中纺锤体和k复合体的检测。 http://documents.irevues.inist.fr/bitstream/handle/2042/11699/AR2_30.pdf?...1 http://documents.irevues.inist.fr/bitstream/handle/2042/11699/AR2_30.pdf?...1

An example of what this is supposed to look like is in Figure 1 of the above paper. 上面的图1中给出了一个示例。 I've included a cut-out of the figure below: Sleep Spindle 我已包括下图的一部分: 睡眠主轴

Here's some code that I have so far. 到目前为止,这里是一些代码。 This just creates the sine wave: 这只会产生正弦波:

import numpy as np
import matplotlib.pyplot as plt

def sleep_spindle_match(sampling_freq):
    freq = 13 #Hz

    x = np.arange(0,1,1.0/sampling_freq)
    sine = np.sin(2 * np.pi * freq * x + (np.pi/2))

    spindle = {'x':x, 'sine':sine}

    return spindle



x = sleep_spindle_match(44100)
plt.plot(x['x'], x['sine'])
plt.show()

However, I have no clue what the "modulated with a cosine" means or how to go about implementing that. 但是,我不知道“用余弦调制”是什么意思,或者如何实现它。 Any help in explaining this in semi-lamens terms would be much appreciated. 我们将不胜感激以半透明的方式对此进行解释。

My ultimate goal (beyond this) is to create a match filter with the above as the template. 我的最终目标(超越此目标)是使用上面的模板创建匹配过滤器。 That's a whole other story though. 不过那是另外一回事了。

They are speaking about (amplitude) modulation . 他们正在谈论(振幅) 调制 A modulation is process of low frequency (slow) changes that happen to a high frequency signal. 调制是发生在高频信号上的低频(缓慢)变化的过程。 The former is called information signal and the latter is called carrier signal . 前者称为information signal ,后者称为carrier signal

Looking at your picture it becomes clear that they want a high frequency sine wave to have its amplitude modulated (slowly changed over time) by a cosine wave. 查看您的图片,很明显,他们希望高频正弦波的振幅被余弦波调制(随时间缓慢变化)。

So, the modulated signal will be just a sine wave with the amplitude being a cosine function: 因此,调制后的信号将只是一个正弦波,其幅度为余弦函数:

def get_signal_func(carrier_freq, carrier_phase0, signal_freq, signal_phase0):
    def signal(x):
        amplitude = math.cos(signal_freq*x + signal_phase0)
        return apmlitude * math.sin(carrier_freq*x + carrier_phase0)
    return signal

Probably that's how it will look in numpy (example): 也许这就是它在numpy外观(示例):

signal = np.cos(freq*x + (np.pi/2)) * np.sin(100*freq*x + (np.pi/2))

Please note that the sine frequency is 100 times greater than cosine one - carrier usually has higher frequency, because if a carrier and a modulator have similar frequencies, it would be difficult for receiver to reconstruct an information (cosine wave in your case). 请注意,正弦频率是一个余弦频率的100倍-载波通常具有更高的频率,因为如果载波和调制器具有相似的频率,则接收器将难以重构信息(在您的情况下为余弦波)。

My reading is that the 13Hz sine wave is scaled by a 0.5Hz cosine wave, given a 1s x axis. 我的阅读是,给定1s x轴,则13Hz正弦波被0.5Hz余弦波缩放。 Just multiply the samples. 只需将样本相乘即可。

import numpy as np
import matplotlib.pyplot as plt

def sleep_spindle_match(sampling_freq):
    freq = 13 #Hz

    x = np.arange(0,1,1.0/sampling_freq)
    y = np.sin(2 * np.pi * freq * x + (np.pi/2)) * np.cos(np.pi * x + (np.pi/2))

    spindle = {'x':x, 'y':y}

    return spindle



x = sleep_spindle_match(44100)
plt.plot(x['x'], x['y'])
plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM