tbepler / topaz

Pipeline for particle picking in cryo-electron microscopy images using convolutional neural networks trained from positive and unlabeled examples. Also featuring micrograph and tomogram denoising with DNNs.
GNU General Public License v3.0
170 stars 62 forks source link

topaz convert: when image_name is numbers like "001", one error #174

Closed IAMCHF closed 10 months ago

IAMCHF commented 10 months ago

particles.txt like this:

image_name x_coord y_coord score 002 83 100 3.9545307 002 934 594 3.4888413 002 684 667 3.4556582

when i use command :

topaz convert ./particles.txt --verbose 1 --output ./particles.csv

Traceback (most recent call last): File "/home/ubuntu/.conda/envs/topaz/bin/topaz", line 33, in sys.exit(load_entry_point('topaz-em==0.2.5', 'console_scripts', 'topaz')()) File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/topaz/main.py", line 148, in main args.func(args) File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/topaz/commands/convert.py", line 217, in main file_utils.write_coordinates(output, coords, format=to_form, boxsize=boxsize, image_ext=image_ext, suffix=suffix) File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/topaz/utils/files.py", line 198, in write_coordinates write_via_csv(path, table) File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/topaz/utils/files.py", line 81, in write_via_csv filename = table['image_name'].apply(lambda x: x + '.png') # need to add .png extension File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/pandas/core/series.py", line 4213, in apply mapped = lib.map_infer(values, f, convert=convert_dtype) File "pandas/_libs/lib.pyx", line 2403, in pandas._libs.lib.map_infer File "/home/ubuntu/.conda/envs/topaz/lib/python3.6/site-packages/topaz/utils/files.py", line 81, in filename = table['image_name'].apply(lambda x: x + '.png') # need to add .png extension TypeError: unsupported operand type(s) for +: 'int' and 'str'

to solve this problem, modify the code on line 169 in topaz/utils/files.py:

change particles = pd.read_csv(path, sep='\t') to

particles = pd.read_csv(path, sep='\t', dtype={'image_name': str})

image

tbepler commented 10 months ago

Thanks for reporting this. Happy to accept a PR with the bugfix!

DarnellGranberry commented 10 months ago

Implemented. Thanks!