Skip to content

Commit c4c6638

Browse files
authored
Merge pull request #2 from neuralkn0t/twig
Add computation of standard deviation and tSNR as multimodal metrics
2 parents eae7b9c + af20202 commit c4c6638

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

physioqc/metrics/multimodal.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,50 @@
11
"""These functions compute RETROICOR regressors (Glover et al. 2000)."""
2+
# import file
23
import numpy as np
34

45
from .. import references
56
from ..due import due
67

78

8-
pass
9+
def std(signal):
10+
"""
11+
Calculate standard deviation across input channels of signal.
12+
13+
Parameters
14+
----------
15+
std : function
16+
Calculate standard deviation across input channels.
17+
args : signal (X, n) :obj:`numpy.ndarray`
18+
ND array with signal of some human biometric data, hopefully from a living human.
19+
signal, of shape (n_channels, )
20+
21+
Returns
22+
-------
23+
N-sized array :obj:`numpy.ndarray`
24+
Standard deviation of signal.
25+
"""
26+
std_val = np.std(signal, axis=0)
27+
return std_val
28+
29+
30+
def tSNR(signal):
31+
"""
32+
Calculate temporal signal to noise ration of signal.
33+
34+
Parameters
35+
----------
36+
tSNR : function
37+
Calculate temporal signal to noise ratio.
38+
args : signal
39+
ND array with signal of some human biometric data, hopefully from a living human.
40+
41+
Returns
42+
-------
43+
N-sized array :obj:`numpy.ndarray`
44+
Temporal signal to noise ratio of signal.
45+
"""
46+
me = np.mean(signal, axis=0)
47+
std = np.std(signal, axis=0)
48+
tSNR_val = me / std
49+
return tSNR_val
50+

0 commit comments

Comments
 (0)