You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subelements of the symbol field must be strings of length 1 to 3 error #201
I am using wrann to write the symbols and the indices into the reference annotation file. I am getting this error Subelements of the symbol field must be strings of length 1 to 3 for the symbols list. I checked the type of the list elements using for i in range(0,len(labels)): print(isinstance(labels[i], str_types)) and the result is True for all the elements of the list. If I use a dummy symbol list I am able to write to the annotation file. Could you tell me what is it that I am doing wrong.
Hey @MishalJasmine, thanks for posting your issues here! You are using custom labels? If so, this snippet here indicates that being an instance of str_types isn't the only condition that needs to be satisfied to raise this error. The length of each sublist must also be in the range of 1-3.
raiseValueError('The symbol values of the '+field+' field must be strings of length 1 to 3')
Maybe these errors should be separated to provide more clarity? An example symbol (or labels in your case) list would be the following (coming from 1003.atr in sample_data):
I tried creating a annotation file locally. These labels are not custom labels. The labels that I have used are N, S, F , Q and V which are included in the PhysioNet. The error that I am getting now is
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
The type of symbols and labels is <class 'numpy.ndarray'>. I have included a spinet of the code.
label and qrs is the output of my model. It is basically a list of all the symbols and the indices of the QRS peaks that I need to add in my annotation file.
Traceback (most recent call last):
File "internalTesting.py", line 18, in
main()
File "internalTesting.py", line 14, in main
localfunction(sys.argv[1].lower(), sys.argv[2])
File "/home/xxxx/GitHub/patch_python/local_test_scripts/internalTesting/qrsanalysis/databaseLocal.py", line 310, in localfunction
wfdb.wrann(record_name= recordlist[i], extension='atr',sample = qrs_index, symbol = label_array)
File "/home/xxxx/anaconda3/lib/python3.7/site-packages/wfdb/io/annotation.py", line 1160, in wrann
annotation.wrann(write_fs=True, write_dir=write_dir)
File "/home/xxxx/anaconda3/lib/python3.7/site-packages/wfdb/io/annotation.py", line 189, in wrann
self.wr_ann_file(write_fs=write_fs, write_dir=write_dir)
File "/home/xxxx/anaconda3/lib/python3.7/site-packages/wfdb/io/annotation.py", line 600, in wr_ann_file
core_bytes = self.calc_core_bytes()
File "/home/xxxx/anaconda3/lib/python3.7/site-packages/wfdb/io/annotation.py", line 705, in calc_core_bytes
data_bytes.append(field2bytes('samptype', [sampdiff[i], self.symbol[i]]))
File "/home/xxxx/anaconda3/lib/python3.7/site-packages/wfdb/io/annotation.py", line 1023, in field2bytes
data_bytes = [sd & 255, ((sd & 768) >> 8) + 4*typecode]
TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according
Okay, I think this attached pull request should fix the issue you are having. There was an error in the way that two binary numbers were being added which was causing your error. Feel free to update me if this fix doesn't help out! Thanks for posting!
Actually, this just seems to open another error.... I really need some kind of example of your labels that cause the error so I know whether or not I fixed it and maintains the current functionality as well.
Activity
Lucas-Mc commentedon Apr 30, 2020
Hey @MishalJasmine, thanks for posting your issues here! You are using custom labels? If so, this snippet here indicates that being an instance of
str_typesisn't the only condition that needs to be satisfied to raise this error. The length of each sublist must also be in the range of 1-3.wfdb-python/wfdb/io/annotation.py
Lines 294 to 295 in 0d4b5a6
Maybe these errors should be separated to provide more clarity? An example
symbol(orlabelsin your case) list would be the following (coming from1003.atrinsample_data):[(15, 'c', 'calibration pulse'), (17, '#', 'pressure line flushed'), (20, 'x', 'signal source change'), (21, 'w', 'wedge recording (PCW)'), (23, '*', 'pop test'), (24, 'z', 'zero pressure')]Does this help? If not, I need some more information about your
labelsvariable in order to make more suggestions. Thanks!MishalJasmine commentedon May 4, 2020
I think I understand.. let me check that out..
MishalJasmine commentedon May 8, 2020
I tried creating a annotation file locally. These labels are not custom labels. The labels that I have used are N, S, F , Q and V which are included in the PhysioNet. The error that I am getting now is
The type of symbols and labels is
<class 'numpy.ndarray'>. I have included a spinet of the code.Can I get some help on this.
Lucas-Mc commentedon May 8, 2020
Hey @MishalJasmine, I need to know what your
labelandqrsvariables are to find out the error here.MishalJasmine commentedon May 8, 2020
label and qrs is the output of my model. It is basically a list of all the symbols and the indices of the QRS peaks that I need to add in my annotation file.
Lucas-Mc commentedon May 8, 2020
What is the traceback for the error? I am trying to find the source of it now.
MishalJasmine commentedon May 9, 2020
Fixes binary operation #201
Lucas-Mc commentedon May 11, 2020
Okay, I think this attached pull request should fix the issue you are having. There was an error in the way that two binary numbers were being added which was causing your error. Feel free to update me if this fix doesn't help out! Thanks for posting!
Lucas-Mc commentedon May 11, 2020
Actually, this just seems to open another error.... I really need some kind of example of your labels that cause the error so I know whether or not I fixed it and maintains the current functionality as well.