@@ -2014,6 +2014,53 @@ def rdsamp(record_name, sampfrom=0, sampto=None, channels=None, pn_dir=None,
20142014 return signals , fields
20152015
20162016
2017+ def sampfreq (record_name , pn_dir = None ):
2018+ """
2019+ Read a WFDB header file and return the sampling frequency of
2020+ each of the signals in the record.
2021+
2022+ Parameters
2023+ ----------
2024+ record_name : str
2025+ The name of the WFDB record to be read, without any file
2026+ extensions. If the argument contains any path delimiter
2027+ characters, the argument will be interpreted as PATH/BASE_RECORD.
2028+ Both relative and absolute paths are accepted. If the `pn_dir`
2029+ parameter is set, this parameter should contain just the base
2030+ record name, and the files fill be searched for remotely.
2031+ Otherwise, the data files will be searched for in the local path.
2032+ pn_dir : str, optional
2033+ Option used to stream data from Physionet. The Physionet
2034+ database directory from which to find the required record files.
2035+ eg. For record '100' in 'http://physionet.org/content/mitdb'
2036+ pn_dir='mitdb'.
2037+
2038+ Returns
2039+ -------
2040+ N/A
2041+
2042+ Examples
2043+ --------
2044+ >>> wfdb.sampfreq('sample-data/test01_00s')
2045+ >>> ECG 1 500
2046+ >>> ECG 2 500
2047+ >>> ECG 3 500
2048+ >>> ECG 4 500
2049+
2050+ """
2051+ if (pn_dir is not None ) and ('.' not in pn_dir ):
2052+ dir_list = pn_dir .split (os .sep )
2053+ pn_dir = posixpath .join (dir_list [0 ], get_version (dir_list [0 ]),
2054+ * dir_list [1 :])
2055+
2056+ record = rdheader (record_name , pn_dir = pn_dir )
2057+ samps_per_frame = [record .fs * samp for samp in record .samps_per_frame ]
2058+ sig_name = record .sig_name
2059+
2060+ for sig ,samp in zip (sig_name , samps_per_frame ):
2061+ print ('{}\t {}' .format (sig ,samp ))
2062+
2063+
20172064def _get_wanted_channels (wanted_sig_names , record_sig_names , pad = False ):
20182065 """
20192066 Given some wanted signal names, and the signal names contained in a
0 commit comments