Skip to content

Commit e8dff30

Browse files
Online Augmentation Functions
1 parent cc8989a commit e8dff30

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

RhythmAttention_Hybrid_CNN_Transformer_Architecture_for_Arrhythmia_Classification.ipynb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,31 @@
196196
"for cls, w in class_weights_dict.items():\n",
197197
" print(f\" Class {cls}: {w:.4f}\")"
198198
]
199+
},
200+
{
201+
"cell_type": "markdown",
202+
"metadata": {},
203+
"source": [
204+
"## **Online Augmentation Functions**"
205+
]
206+
},
207+
{
208+
"cell_type": "code",
209+
"execution_count": 5,
210+
"metadata": {},
211+
"outputs": [],
212+
"source": [
213+
"# 6. Define physiological augmentation functions\n",
214+
"def add_gaussian_noise(signal, noise_level=0.005):\n",
215+
" \"\"\"Adds random Gaussian noise to mimic muscle artifacts or device interference.\"\"\"\n",
216+
" noise = np.random.normal(0, noise_level, signal.shape)\n",
217+
" return signal + noise\n",
218+
"\n",
219+
"def apply_amplitude_scaling(signal, factor_range=(0.9, 1.1)):\n",
220+
" \"\"\"Scales the amplitude to mimic different signal strengths across patients.\"\"\"\n",
221+
" factor = np.random.uniform(factor_range[0], factor_range[1])\n",
222+
" return signal * factor"
223+
]
199224
}
200225
],
201226
"metadata": {

0 commit comments

Comments
 (0)