sephonlee / PhyloParser

Automatically read tree structure from image format
http://viziometrics.org/about/
MIT License
2 stars 1 forks source link

Error in Preprocess step #1

Open stubbsrl opened 5 years ago

stubbsrl commented 5 years ago

I am getting an error at the preprocessing step. I've pasted the output for both debug = False and debug = True. I have no errors up to this point.

Also, I should note I am attempting to use the program on a figure from a paper (extracted as a jpg). I am not sure if the program is meant for more complicated trees like the one I am using.

Thanks for any help!

>>> image_data = phyloParser.preprocces(image_data, debug= False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 70, in preprocces
    image, edgeMask, hasBackground= PhyloParser.removeBackground(image)
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 122, in removeBackground
    horLines, verLines = PhyloParser.detectLines_light(newnewImage)
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 867, in detectLines_light
    verLines = PhyloParser.getLines(image, mode, minLength = minVerLine)
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 1088, in getLines
    if tmp != None:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
>>> image_data = phyloParser.preprocces(image_data, debug= True)
Preprocessing image ...
Input image:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 64, in preprocces
    PhyloParser.displayImage(image)
  File "/apps/phyloparser/20180404/envs/PhyloParser/PhyloParser.py", line 222, in displayImage
    plt.imshow(image, cmap='Greys_r')
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/pyplot.py", line 3189, in imshow
    ax = gca()
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/pyplot.py", line 984, in gca
    return gcf().gca(**kwargs)
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/pyplot.py", line 601, in gcf
    return figure()
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/pyplot.py", line 548, in figure
    **kwargs)
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 161, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "/apps/phyloparser/20180404/lib/python2.7/site-packages/matplotlib/backends/_backend_tk.py", line 1044, in new_figure_manager_given_figure
    window = Tk.Tk(className="matplotlib")
  File "/apps/phyloparser/20180404/lib/python2.7/lib-tk/Tkinter.py", line 1819, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
seanyang38 commented 5 years ago

Hello Rebecca,

Thank you for your question.

The error is caused by matplotlib package. You may take a look of this thread on StackOverflow. Please let me know if this solves the issue.

Our program is designed to parse the dendrogram (phylogenetic tree, more specific) from scientific literature. As long as the image matches the following criteria, it should be parsed successfully:

Hope this helps

stubbsrl commented 5 years ago

Thank you for the quick and helpful response! I added

import matplotlib
matplotlib.use('Agg')

before import cv2 as cv in the script. This loaded fine, but I am still getting the same error at the preprocessing step. I am running this on my university's HPC so I am writing them if there is another way to set matplotlib to not use the Xwindows backend.

If that doesn't work, do you have any other ideas?

Thanks, Rebecca

seanyang38 commented 5 years ago

Hello Rebecca,

I recommend to try the solutions offered from different posts in the same thread. If nothing on there solves the issue, you can try to change the code to display the image. Instead of using matplotlib to display the image, you could use the package that would be compatible with your environment.

To be more specific, you can change the function "displayImage", which should be around line 222 in PhyloParser.py, to use a different package to show the images.

I just found out that I didn't answer the other issue. For this error: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() I believe it can be solved by changing if tmp != None: on line 1088, to if tmp is not None:

Please feel free to let me know if you are still running into any errors. Also, it would be really helpful if you can share the image you are parsing. Thank you:)

stubbsrl commented 5 years ago

It was confirmed that

import matplotlib
matplotlib.use('Agg')

is the correct solution for the matplotlib problem.

I changed line 1088 as you specified. That line error then goes away but I then get the same error for line 1094. So, I changed it there too, but that did not fix it (changed it back now).

Attached is the tree I am trying to convert. Thank you so much for your help! I actually have dozens of trees I am converting to Newick and I have been doing the smaller ones by hand, so if we can get this to work it will be a huge help.

bignoniaceae_fig 1 olmstead_et_al-2009