@@ -2061,6 +2061,61 @@ def sampfreq(record_name, pn_dir=None):
20612061 print ('{}\t {}' .format (sig ,samp ))
20622062
20632063
2064+ def signame (record_name , pn_dir = None , sig_nums = []):
2065+ """
2066+ Read a WFDB record file and return the signal names.
2067+
2068+ Parameters
2069+ ----------
2070+ record_name : str
2071+ The name of the WFDB record to be read, without any file
2072+ extensions. If the argument contains any path delimiter
2073+ characters, the argument will be interpreted as PATH/BASE_RECORD.
2074+ Both relative and absolute paths are accepted. If the `pn_dir`
2075+ parameter is set, this parameter should contain just the base
2076+ record name, and the files fill be searched for remotely.
2077+ Otherwise, the data files will be searched for in the local path.
2078+ pn_dir : str, optional
2079+ Option used to stream data from Physionet. The Physionet
2080+ database directory from which to find the required record files.
2081+ eg. For record '100' in 'http://physionet.org/content/mitdb'
2082+ pn_dir='mitdb'.
2083+ sig_nums : list, optional
2084+ A list of the signal numbers to be outputted.
2085+
2086+ Returns
2087+ -------
2088+ N/A
2089+
2090+ Examples
2091+ --------
2092+ >>> wfdb.signame('sample-data/test01_00s')
2093+ >>> ECG 1
2094+ >>> ECG 2
2095+ >>> ECG 3
2096+ >>> ECG 4
2097+
2098+ >>> wfdb.signame('sample-data/test01_00s', sig_nums=[1,3])
2099+ >>> ECG 2
2100+ >>> ECG 4
2101+
2102+ """
2103+ if (pn_dir is not None ) and ('.' not in pn_dir ):
2104+ dir_list = pn_dir .split (os .sep )
2105+ pn_dir = posixpath .join (dir_list [0 ], get_version (dir_list [0 ]),
2106+ * dir_list [1 :])
2107+
2108+ record = rdheader (record_name , pn_dir = pn_dir )
2109+ if len (sig_nums ) > 0 :
2110+ for n in sig_nums :
2111+ try :
2112+ print (record .sig_name [n ])
2113+ except IndexError :
2114+ raise Exception ('sig_nums value {} out of range' .format (n ))
2115+ else :
2116+ print (* record .sig_name , sep = '\n ' )
2117+
2118+
20642119def _get_wanted_channels (wanted_sig_names , record_sig_names , pad = False ):
20652120 """
20662121 Given some wanted signal names, and the signal names contained in a
0 commit comments