persim
persim copied to clipboard
prism Persistent Image issue
I have an issue producing Persistent Images using Prism in Python. I'm generating Persistent Diagrams using Dionysus software in python. My problem is I can not generate persistent images from dionysus out. I have converted the output into a NumPy array but still give me a 'TypeError'. Below is my code and the error message:
import dionysus as d
import numpy as np
from sklearn.preprocessing import normalize
import matplotlib.pyplot as plt
from persim import PersImage
Image = plt.imread("8.png")
normed_matrix = normalize(Image, axis=1, norm='l1')
f_lower_star = d.fill_freudenthal(normed_matrix)
p = d.homology_persistence(f_lower_star)
dgms = d.init_diagrams(p, f_lower_star)
#### I do not have an issue until that point , it is the Persistent Image step that gives me error !
pim = PersImage(pixels=[20,20],spread=1,verbose=False )
img = pim.transform(dgms[1])
And the error I get is the following:
TypeError Traceback (most recent call last)
TypeError: order must be str, not type
I have later converted the dionysus output into a python list, and a numpy array using the following:
l = [(pt.birth, pt.death) for pt in dgms[1]]
f=np.asarray(l)
but I still get the same error !!!!
Any help will be appreciated. Many Thanks Aras
Hi,
I am using the Persim module to produce the persistent image based on the diagrams generated by RIPS (https://github.com/scikit-tda/ripser.py).
`rips = Rips(maxdim=0)
dgms = rips.fit_transform(data)
plot_diagrams(dgms, show=True)
pim = PersImage(pixels =[100,100],spread =1)
imgs = pim.transform(dgms)
plt.figure(figsize=(15,15))
pim.show(imgs)`
However, I get the following runtime warning: `Rips(maxdim=0, thresh=inf, coeff=2, do_cocycles=False, n_perm = None, verbose=True) I am done with rips PersImage(pixels=[100, 100], spread=1, specs=None, kernel_type="gaussian", weighting_type="linear") Traceback (most recent call last):
File "/Users/kianamac/Desktop/mahdi files/index.py", line 44, in
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 104, in transform imgs = [self._transform(dgm) for dgm in landscapes]
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 104, in
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 119, in _transform xs_lower = np.linspace(minBD, maxBD, self.nx)
File "<array_function internals>", line 5, in linspace
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/numpy/core/function_base.py", line 153, in linspace y *= step
RuntimeWarning: invalid value encountered in multiply`
Would you please help me to understand what could be the source of the problem?
Thanks,
Hi,
I am using the Persim module to produce the persistent image based on the diagrams generated by RIPS (https://github.com/scikit-tda/ripser.py).
`rips = Rips(maxdim=0)
dgms = rips.fit_transform(data)
plot_diagrams(dgms, show=True)
pim = PersImage(pixels =[100,100],spread =1)
imgs = pim.transform(dgms)
plt.figure(figsize=(15,15))
pim.show(imgs)`
However, I get the following runtime warning: `Rips(maxdim=0, thresh=inf, coeff=2, do_cocycles=False, n_perm = None, verbose=True) I am done with rips PersImage(pixels=[100, 100], spread=1, specs=None, kernel_type="gaussian", weighting_type="linear") Traceback (most recent call last):
File "/Users/kianamac/Desktop/mahdi files/index.py", line 44, in imgs = pim.transform(dgms)
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 104, in transform imgs = [self._transform(dgm) for dgm in landscapes]
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 104, in imgs = [self._transform(dgm) for dgm in landscapes]
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/persim/images.py", line 119, in _transform xs_lower = np.linspace(minBD, maxBD, self.nx)
File "<array_function internals>", line 5, in linspace
File "/Users/kianamac/Applications/anaconda3/lib/python3.8/site-packages/numpy/core/function_base.py", line 153, in linspace y *= step
RuntimeWarning: invalid value encountered in multiply`
Would you please help me to understand what could be the source of the problem?
Thanks,
@kalikhademi Not sure if it is still relevant, but I think the issue is that with Vietoris-Rips filtration, in dimension 0 all persistence pairs have birth=0, and thus there is not really a notion of 2D image there (as range of birth in birth-persistence diagram is [0, 0]).