jianhuupenn / TESLA

Deciphering tumor ecosystems at super-resolution from spatial transcriptomics with TESLA
MIT License
46 stars 11 forks source link

Error in tutorial? #19

Open Jorges1000 opened 4 months ago

Jorges1000 commented 4 months ago

Hi,

I was following your tutorial and in your original code it seems that cnt will reflect the last step (contour by y, not cv2). I modified to look at the different contours with each algorithm, but the step #### 4.4 Plot gene expression image only works with cnty and not cntcv2.

#Three different algorithms to detect contour, select the best one. Here we use cv2.

#-----------------1. Detect contour using cv2-----------------
cntcv2=tesla.cv2_detect_contour(img, apertureSize=5,L2gradient = True)

#-----------------2. Scan contour by x-----------------
spots=counts.obs.loc[:, ['pixel_x', 'pixel_y', "array_x", "array_y"]]
#shape="hexagon" for 10X Visium, shape="square" for ST
cntx=tesla.scan_contour(spots, scan_x=True, shape="hexagon")

#-----------------3. Scan contour by y-----------------
spots=counts.obs.loc[:, ['pixel_x', 'pixel_y', "array_x", "array_y"]]
#shape="hexagon" for 10X Vsium, shape="square" for ST
cnty=tesla.scan_contour(spots, scan_x=False, shape="hexagon")
#_----------------------
cnt = cnty

Also, in this code:

6.2 Leading edge detection

ret_img=tesla.leading_edge_detection(img=img, 
                                     pred_refined=pred_refined, 
                                     resize_factor=resize_factor, 
                                     target_clusters=target_clusters, 
                                     binary=binary)

gives error: Traceback (most recent call last): File "", line 1, in File "/home/jsepulveda/.local/lib/python3.9/site-packages/TESLAforST-1.2.4-py3.9.egg/TESLA/tumor_edge_core.py", line 19, in leading_edge_detection cnt_info=cv2_detect_contour((target_img==0).astype(np.uint8), apertureSize=5,L2gradient = True, all_cnt_info=True) File "/home/jsepulveda/.local/lib/python3.9/site-packages/TESLAforST-1.2.4-py3.9.egg/TESLA/contour_util.py", line 73, in cv2_detect_contour cnt=cnt_info[0][0] IndexError: list index out of range

huskyth commented 1 month ago

have you any solutions?

huskyth commented 1 month ago

i have the same error, but how to solve