py2ls 0.1.9.8__py3-none-any.whl → 0.1.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
py2ls/ich2ls.py ADDED
@@ -0,0 +1,590 @@
1
+ import numpy as np
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ from scipy.stats import pearsonr
5
+ from PIL import Image
6
+ from skimage import filters, morphology, measure, color
7
+
8
+ # 用来处理ich图像的初级工具包
9
+
10
+
11
+ def open_img(dir_img, convert="gray", plot=False):
12
+ # Step 1: Load the image
13
+ image = Image.open(dir_img)
14
+
15
+ if convert == "gray" or convert == "grey":
16
+ gray_image = image.convert("L")
17
+ image_array = np.array(gray_image)
18
+ else:
19
+ image_array = np.array(image)
20
+ if plot:
21
+ _, axs = plt.subplots(1, 2)
22
+ axs[0].imshow(image)
23
+ axs[1].imshow(image_array)
24
+ axs[0].set_title("img_raw")
25
+ axs[1].set_title(f"img_{convert}")
26
+ return image, image_array
27
+
28
+
29
+ from skimage import filters, morphology
30
+
31
+
32
+ def clean_img(
33
+ img,
34
+ method=["threshold_otsu", "objects", "holes"],
35
+ obj_min=50,
36
+ hole_min=50,
37
+ filter=None,
38
+ plot=False,
39
+ cmap="grey",
40
+ ):
41
+ if isinstance(method, str):
42
+ if method == "all":
43
+ method = ["threshold_otsu", "objects", "holes"]
44
+ else:
45
+ method = [method]
46
+ if any("thr" in met or "ot" in met for met in method) and filter is None:
47
+ thr_otsu = filters.threshold_otsu(img)
48
+ img_update = img > thr_otsu
49
+ if any("obj" in met for met in method):
50
+ img_update = morphology.remove_small_objects(img_update, min_size=obj_min)
51
+ if any("hol" in met for met in method):
52
+ img_update = morphology.remove_small_holes(img_update, area_threshold=hole_min)
53
+ if ("thr" in met for met in method) and filter: # threshold
54
+ mask = (img >= filter[0]) & (img <= filter[1])
55
+ img_update = np.where(mask, img, 0)
56
+
57
+ if plot:
58
+ plt.imshow(img_update, cmap=cmap)
59
+ return img_update
60
+
61
+
62
+ from skimage import filters, segmentation
63
+
64
+
65
+ def segment_img(
66
+ img,
67
+ filter=[30, 150],
68
+ plot=False,
69
+ mode="reflect", # 'reflect' or 'constant'
70
+ method="region", # 'region' or 'edge', 'threshold'
71
+ area_min=50,
72
+ cmap="jet",
73
+ connectivity=1,
74
+ output="segmentation",
75
+ ):
76
+ if "reg" in method: # region method
77
+ # 1. find an elevation map using the Sobel gradient of the image
78
+ elevation_map = filters.sobel(img, mode=mode)
79
+ # 2. find markers of the background and the coins based on the extreme parts of the histogram of gray values.
80
+ markers = np.zeros_like(img)
81
+ # Apply filtering based on provided filter values
82
+ if filter is not None:
83
+ markers[img < filter[0]] = 1
84
+ markers[img > filter[1]] = 2
85
+ else:
86
+ # If no filter is provided, set markers across the whole range of the image
87
+ markers[img == img.min()] = 1
88
+ markers[img == img.max()] = 2
89
+ # 3. watershed transform to fill regions of the elevation map starting from the markers
90
+ img_segmentation = segmentation.watershed(
91
+ elevation_map, markers=markers, connectivity=connectivity
92
+ )
93
+ if plot:
94
+ _, axs = plt.subplots(2, 2)
95
+ for i, ax in enumerate(axs.flatten().tolist()):
96
+ if i == 0:
97
+ ax.imshow(img)
98
+ ax.set_title("image")
99
+ elif i == 1:
100
+ ax.imshow(elevation_map, cmap=cmap)
101
+ ax.set_title("elevation map")
102
+ elif i == 2:
103
+ ax.imshow(markers, cmap=cmap)
104
+ ax.set_title("markers")
105
+ elif i == 3:
106
+ ax.imshow(img_segmentation, cmap=cmap)
107
+ ax.set_title("segmentation")
108
+ ax.set_axis_off()
109
+ if "el" in output:
110
+ return elevation_map
111
+ elif "mar" in output:
112
+ return markers
113
+ elif "seg" in output:
114
+ return img_segmentation
115
+ else:
116
+ return img_segmentation
117
+ elif "ed" in method: # edge
118
+ edges = cal_edges(img)
119
+ fills = fill_holes(edges)
120
+ img_segmentation = remove_holes(fills, area_min)
121
+ if plot:
122
+ _, axs = plt.subplots(2, 2)
123
+ for i, ax in enumerate(axs.flatten().tolist()):
124
+ if i == 0:
125
+ ax.imshow(img)
126
+ ax.set_title("image")
127
+ elif i == 1:
128
+ ax.imshow(edges, cmap=cmap)
129
+ ax.set_title("edges map")
130
+ elif i == 2:
131
+ ax.imshow(fills, cmap=cmap)
132
+ ax.set_title("fills")
133
+ elif i == 3:
134
+ ax.imshow(img_segmentation, cmap=cmap)
135
+ ax.set_title("segmentation")
136
+ ax.set_axis_off()
137
+ if "seg" in output:
138
+ return img_segmentation
139
+ elif "ed" in output:
140
+ return edges
141
+ elif "fill" in output:
142
+ return fills
143
+ else:
144
+ return img_segmentation
145
+ elif "thr" in method: # threshold
146
+ if filter:
147
+ mask = (img >= filter[0]) & (img <= filter[1])
148
+ img_threshold = np.where(mask, img, 0)
149
+ if plot:
150
+ plt.imshow(img_threshold, cmap=cmap)
151
+ return img_threshold
152
+ else:
153
+ return None
154
+
155
+
156
+ from skimage import measure
157
+
158
+
159
+ def label_img(img, plot=False):
160
+ img_label = measure.label(img)
161
+ if plot:
162
+ plt.imshow(img_label)
163
+ return img_label
164
+
165
+
166
+ def img_process(img, **kwargs):
167
+ convert = "gray"
168
+ method_clean_img = ["threshold_otsu", "objects", "holes"]
169
+ obj_min_clean_img = 50
170
+ hole_min_clean_img = 50
171
+ plot = True
172
+ for k, v in kwargs.items():
173
+ if "convert" in k.lower():
174
+ convert = v
175
+ if "met" in k.lower() and any(
176
+ ["clean" in k.lower(), "rem" in k.lower(), "rm" in k.lower()]
177
+ ):
178
+ method_clean_img = v
179
+ if "obj" in k.lower() and any(
180
+ ["clean" in k.lower(), "rem" in k.lower(), "rm" in k.lower()]
181
+ ):
182
+ obj_min_clean_img = v
183
+ if "hol" in k.lower() and any(
184
+ ["clean" in k.lower(), "rem" in k.lower(), "rm" in k.lower()]
185
+ ):
186
+ hole_min_clean_img = v
187
+ if "plot" in k.lower():
188
+ plot = v
189
+
190
+ if isinstance(img, str):
191
+ image, image_array = open_img(img, convert=convert)
192
+ normalized_image = image_array / 255.0
193
+ else:
194
+ cleaned_image = img
195
+ image_array = cleaned_image
196
+ normalized_image = cleaned_image
197
+ image = cleaned_image
198
+
199
+ # Remove small objects and fill small holes
200
+ cleaned_image = clean_img(
201
+ img=image_array,
202
+ method=method_clean_img,
203
+ obj_min=obj_min_clean_img,
204
+ hole_min=hole_min_clean_img,
205
+ plot=False,
206
+ )
207
+ # Label the regions
208
+ label_image = label_img(cleaned_image)
209
+ overlay_image = overlay_imgs(label_image, image=image_array)
210
+ regions = measure.regionprops(label_image, intensity_image=image_array)
211
+ region_props = measure.regionprops_table(
212
+ label_image, intensity_image=image_array, properties=props_list
213
+ )
214
+ df_regions = pd.DataFrame(region_props)
215
+ # Pack the results into a single output variable (dictionary)
216
+ output = {
217
+ "img": image,
218
+ "img_array": image_array,
219
+ "img_scale": normalized_image,
220
+ "img_clean": cleaned_image,
221
+ "img_label": label_image,
222
+ "img_overlay": overlay_image,
223
+ "regions": regions,
224
+ "df_regions": df_regions,
225
+ }
226
+ if plot:
227
+ imgs = []
228
+ [imgs.append(i) for i in list(output.keys()) if "img" in i]
229
+ for img_ in imgs:
230
+ plt.figure()
231
+ plt.imshow(output[img_])
232
+ plt.title(img_)
233
+ return output
234
+
235
+
236
+ # def img_preprocess(dir_img, subtract_background=True, size_obj=50, size_hole=50,**kwargs):
237
+ # """
238
+ # Processes an image by performing thresholding, morphological operations,
239
+ # and region labeling.
240
+
241
+ # Parameters:
242
+ # - dir_img: Path to the image file.
243
+ # - size_obj: Minimum size of objects to keep (default: 50).
244
+ # - size_hole: Maximum size of holes to fill (default: 50).
245
+
246
+ # Returns:
247
+ # - output: Dictionary containing the overlay image, threshold value, and regions.
248
+ # """
249
+ # props_list = [
250
+ # "area", # Number of pixels in the region. Useful for determining the size of regions.
251
+ # "area_bbox",
252
+ # "area_convex",
253
+ # "area_filled",
254
+ # "axis_major_length", # Lengths of the major and minor axes of the ellipse that fits the region. Useful for understanding the shape's elongation and orientation.
255
+ # "axis_minor_length",
256
+ # "bbox", # Bounding box coordinates (min_row, min_col, max_row, max_col). Useful for spatial localization of regions.
257
+ # "centroid", # Center of mass coordinates (centroid-0, centroid-1). Helps locate the center of each region.
258
+ # "centroid_local",
259
+ # "centroid_weighted",
260
+ # "centroid_weighted_local",
261
+ # "coords",
262
+ # "eccentricity", # Measure of how elongated the region is. Values range from 0 (circular) to 1 (line). Useful for assessing the shape of regions.
263
+ # "equivalent_diameter_area", # Diameter of a circle with the same area as the region. Provides a simple measure of size.
264
+ # "euler_number",
265
+ # "extent", # Ratio of the region's area to the area of its bounding box. Indicates how much of the bounding box is filled by the region.
266
+ # "feret_diameter_max", # Maximum diameter of the region, providing another measure of size.
267
+ # "image",
268
+ # "image_convex",
269
+ # "image_filled",
270
+ # "image_intensity",
271
+ # "inertia_tensor", # ensor describing the distribution of mass in the region, useful for more advanced shape analysis.
272
+ # "inertia_tensor_eigvals",
273
+ # "intensity_max", # Maximum intensity value within the region. Helps identify regions with high-intensity features.
274
+ # "intensity_mean", # Average intensity value within the region. Useful for distinguishing between regions based on their brightness.
275
+ # "intensity_min", # Minimum intensity value within the region. Useful for regions with varying intensity.
276
+ # "intensity_std",
277
+ # "label", # Unique identifier for each region.
278
+ # "moments",
279
+ # "moments_central",
280
+ # "moments_hu", # Hu moments are a set of seven invariant features that describe the shape of the region. Useful for shape recognition and classification.
281
+ # "moments_normalized",
282
+ # "moments_weighted",
283
+ # "moments_weighted_central",
284
+ # "moments_weighted_hu",
285
+ # "moments_weighted_normalized",
286
+ # "orientation", # ngle of the major axis of the ellipse that fits the region. Useful for determining the orientation of elongated regions.
287
+ # "perimeter", # Length of the boundary of the region. Useful for shape analysis.
288
+ # "perimeter_crofton",
289
+ # "slice",
290
+ # "solidity", # Ratio of the area of the region to the area of its convex hull. Indicates how solid or compact a region is.
291
+ # ]
292
+ # if isinstance(dir_img, str):
293
+ # # Step 1: Load the image
294
+ # image = Image.open(dir_img)
295
+
296
+ # # Step 2: Convert the image to grayscale and normalize
297
+ # gray_image = image.convert("L")
298
+ # image_array = np.array(gray_image)
299
+ # normalized_image = image_array / 255.0
300
+ # else:
301
+ # cleaned_image = dir_img
302
+ # image_array = cleaned_image
303
+ # normalized_image = cleaned_image
304
+ # image = cleaned_image
305
+ # binary_image = cleaned_image
306
+ # thr_val = None
307
+ # if subtract_background:
308
+ # # Step 3: Apply thresholding to segment the image
309
+ # thr_val = filters.threshold_otsu(image_array)
310
+ # print(f"Threshold value is: {thr_val}")
311
+
312
+ # # Apply thresholds and generate binary images
313
+ # binary_image = image_array > thr_val
314
+
315
+ # # Step 4: Perform morphological operations to clean the image
316
+ # # Remove small objects and fill small holes
317
+ # cleaned_image_rm_min_obj = morphology.remove_small_objects(
318
+ # binary_image, min_size=size_obj
319
+ # )
320
+ # cleaned_image = morphology.remove_small_holes(
321
+ # cleaned_image_rm_min_obj, area_threshold=size_hole
322
+ # )
323
+
324
+ # # Label the regions
325
+ # label_image = label_img(cleaned_image)
326
+
327
+ # # Optional: Overlay labels on the original image
328
+ # overlay_image = color.label2rgb(label_image, image_array)
329
+ # regions = measure.regionprops(label_image, intensity_image=image_array)
330
+ # region_props = measure.regionprops_table(
331
+ # label_image, intensity_image=image_array, properties=props_list
332
+ # )
333
+ # df_regions = pd.DataFrame(region_props)
334
+ # # Pack the results into a single output variable (dictionary)
335
+ # output = {
336
+ # "img": image,
337
+ # "img_array": image_array,
338
+ # "img_scale": normalized_image,
339
+ # "img_binary": binary_image,
340
+ # "img_clean": cleaned_image,
341
+ # "img_label": label_image,
342
+ # "img_overlay": overlay_image,
343
+ # "thr_val": thr_val,
344
+ # "regions": regions,
345
+ # "df_regions": df_regions,
346
+ # }
347
+
348
+ # return output
349
+
350
+
351
+ def cal_pearson(img1, img2):
352
+ """Compute Pearson correlation coefficient between two images."""
353
+ img1_flat = img1.flatten()
354
+ img2_flat = img2.flatten()
355
+ r, p = pearsonr(img1_flat, img2_flat)
356
+ return r, p
357
+
358
+
359
+ def cal_manders(img1, img2):
360
+ """Compute Manders' overlap coefficient between two binary images."""
361
+ img1_binary = img1 > filters.threshold_otsu(img1)
362
+ img2_binary = img2 > filters.threshold_otsu(img2)
363
+ overlap_coef = np.sum(img1_binary & img2_binary) / np.sum(img1_binary)
364
+ return overlap_coef
365
+
366
+
367
+ def overlay_imgs(
368
+ *imgs,
369
+ image=None,
370
+ colors=None,
371
+ alpha=0.3,
372
+ bg_label=0,
373
+ bg_color=(0, 0, 0),
374
+ image_alpha=1,
375
+ kind="overlay",
376
+ saturation=0,
377
+ channel_axis=-1,
378
+ ):
379
+ # Ensure all input images have the same shape
380
+ print(
381
+ f'\nusage:\nich2ls.overlay_imgs(res_b["img_binary"], res_r["img_binary"], bg_label=0)'
382
+ )
383
+ shapes = [img.shape for img in imgs]
384
+ if not all(shape == shapes[0] for shape in shapes):
385
+ raise ValueError("All input images must have the same shape")
386
+
387
+ # If no image is provided, use the first input image as the base
388
+ if image is None:
389
+ image = imgs[0]
390
+
391
+ # Combine the images into a label, with unique multipliers for each image
392
+ label = sum((img.astype(np.uint) * (i + 1) for i, img in enumerate(imgs)))
393
+
394
+ # Create the overlay image
395
+ overlay_image = color.label2rgb(
396
+ label,
397
+ image=image,
398
+ bg_label=bg_label,
399
+ colors=colors,
400
+ alpha=alpha,
401
+ bg_color=bg_color,
402
+ image_alpha=image_alpha,
403
+ saturation=saturation,
404
+ kind=kind,
405
+ channel_axis=channel_axis, # Corrected from saturation to channel_axis
406
+ )
407
+
408
+ return overlay_image
409
+
410
+
411
+ from skimage import exposure
412
+
413
+
414
+ # Comparing edge-based and region-based segmentation
415
+ def draw_hist(img, ax=None, **kwargs):
416
+ """
417
+ _, axs = plt.subplots(1, 2)
418
+ draw_hist(image, c="r", ax=axs[1], lw=2, ls=":")
419
+ """
420
+ print(f"img type: {type(img)}")
421
+ if not isinstance(img, np.ndarray):
422
+ img = np.array(img)
423
+ hist, hist_centers = exposure.histogram(img)
424
+ if ax is None:
425
+ ax = plt.gca()
426
+ ax.plot(hist_centers, hist, **kwargs)
427
+
428
+
429
+ from skimage import feature
430
+
431
+
432
+ # delineate the contours of the coins using edge-based segmentation
433
+ def cal_edges(img, plot=False, cmap=plt.cm.gray):
434
+ edges = feature.canny(img)
435
+ if plot:
436
+ plt.imshow(edges, cmap=cmap)
437
+ return edges
438
+
439
+
440
+ from scipy import ndimage as ndi
441
+
442
+
443
+ # These contours are then filled using mathematical morphology.
444
+ def fill_holes(img, plot=False):
445
+ img_fill_holes = ndi.binary_fill_holes(img)
446
+ if plot:
447
+ plt.imshow(img_fill_holes, cmap=plt.cm.gray)
448
+ return img_fill_holes
449
+
450
+
451
+ from skimage import morphology
452
+
453
+
454
+ def remove_holes(img, size=50, plot=False):
455
+ img_rm_holes = morphology.remove_small_objects(img, size)
456
+ if plot:
457
+ plt.imshow(img_rm_holes, cmap=plt.cm.gray)
458
+ return img_rm_holes
459
+
460
+
461
+ import matplotlib.patches as mpatches
462
+ from skimage import measure, color
463
+
464
+
465
+ def draw_bbox(
466
+ img,
467
+ df=None,
468
+ img_label=None,
469
+ img_label2rgb=None,
470
+ show=True, # plot the image
471
+ bg_alpha=1, # the alpha of the bg image
472
+ area_min=1,
473
+ area_max=None,
474
+ fill=False,
475
+ edgecolor="red",
476
+ linewidth=2,
477
+ ax=None,
478
+ **kwargs,
479
+ ):
480
+ """
481
+ ich2ls.draw_bbox(
482
+ res["img_label"], fill=False, color="r", lw=1, edgecolor="w", alpha=0.4)
483
+ """
484
+ if ax is None:
485
+ ax = plt.gca()
486
+ if img_label is None:
487
+ img_label = measure.label(img)
488
+ if isinstance(show, bool):
489
+ if show:
490
+ if img_label2rgb is None:
491
+ img_label2rgb = color.label2rgb(img_label, image=img, bg_label=0)
492
+ ax.imshow(img_label2rgb, alpha=bg_alpha)
493
+ elif isinstance(show, str):
494
+ if "raw" in show:
495
+ ax.imshow(img, alpha=bg_alpha)
496
+ elif "label" in show:
497
+ ax.imshow(img_label, alpha=bg_alpha)
498
+ elif "rgb" in show:
499
+ if img_label2rgb is None:
500
+ img_label2rgb = color.label2rgb(img_label, image=img, bg_label=0)
501
+ ax.imshow(img_label2rgb, alpha=bg_alpha)
502
+ elif "no" in show.lower():
503
+ pass
504
+ num = 0
505
+ if df is None:
506
+ for region in measure.regionprops(img_label):
507
+ # take regions with large enough areas
508
+ if area_max is None:
509
+ area_max = np.inf
510
+ if area_min <= region.area <= area_max:
511
+ minr, minc, maxr, maxc = region.bbox
512
+ rect = mpatches.Rectangle(
513
+ (minc, minr),
514
+ maxc - minc,
515
+ maxr - minr,
516
+ fill=fill,
517
+ edgecolor=edgecolor,
518
+ linewidth=linewidth,
519
+ **kwargs,
520
+ )
521
+ ax.add_patch(rect)
522
+ num += 1
523
+ else:
524
+ # Iterate over each row in the DataFrame and draw the bounding boxes
525
+ for _, row in df.iterrows():
526
+ minr = row["bbox-0"]
527
+ minc = row["bbox-1"]
528
+ maxr = row["bbox-2"]
529
+ maxc = row["bbox-3"]
530
+
531
+ # Optionally filter by area if needed
532
+ area = (maxr - minr) * (maxc - minc)
533
+ if area >= area_min:
534
+ rect = mpatches.Rectangle(
535
+ (minc, minr),
536
+ maxc - minc,
537
+ maxr - minr,
538
+ fill=fill,
539
+ edgecolor=edgecolor,
540
+ linewidth=linewidth,
541
+ **kwargs,
542
+ )
543
+ ax.add_patch(rect)
544
+ num += 1
545
+ return num
546
+
547
+
548
+ props_list = [
549
+ "area", # Number of pixels in the region. Useful for determining the size of regions.
550
+ "area_bbox",
551
+ "area_convex",
552
+ "area_filled",
553
+ "axis_major_length", # Lengths of the major and minor axes of the ellipse that fits the region. Useful for understanding the shape's elongation and orientation.
554
+ "axis_minor_length",
555
+ "bbox", # Bounding box coordinates (min_row, min_col, max_row, max_col). Useful for spatial localization of regions.
556
+ "centroid", # Center of mass coordinates (centroid-0, centroid-1). Helps locate the center of each region.
557
+ "centroid_local",
558
+ "centroid_weighted",
559
+ "centroid_weighted_local",
560
+ "coords",
561
+ "eccentricity", # Measure of how elongated the region is. Values range from 0 (circular) to 1 (line). Useful for assessing the shape of regions.
562
+ "equivalent_diameter_area", # Diameter of a circle with the same area as the region. Provides a simple measure of size.
563
+ "euler_number",
564
+ "extent", # Ratio of the region's area to the area of its bounding box. Indicates how much of the bounding box is filled by the region.
565
+ "feret_diameter_max", # Maximum diameter of the region, providing another measure of size.
566
+ "image",
567
+ "image_convex",
568
+ "image_filled",
569
+ "image_intensity",
570
+ "inertia_tensor", # ensor describing the distribution of mass in the region, useful for more advanced shape analysis.
571
+ "inertia_tensor_eigvals",
572
+ "intensity_max", # Maximum intensity value within the region. Helps identify regions with high-intensity features.
573
+ "intensity_mean", # Average intensity value within the region. Useful for distinguishing between regions based on their brightness.
574
+ "intensity_min", # Minimum intensity value within the region. Useful for regions with varying intensity.
575
+ "intensity_std",
576
+ "label", # Unique identifier for each region.
577
+ "moments",
578
+ "moments_central",
579
+ "moments_hu", # Hu moments are a set of seven invariant features that describe the shape of the region. Useful for shape recognition and classification.
580
+ "moments_normalized",
581
+ "moments_weighted",
582
+ "moments_weighted_central",
583
+ "moments_weighted_hu",
584
+ "moments_weighted_normalized",
585
+ "orientation", # ngle of the major axis of the ellipse that fits the region. Useful for determining the orientation of elongated regions.
586
+ "perimeter", # Length of the boundary of the region. Useful for shape analysis.
587
+ "perimeter_crofton",
588
+ "slice",
589
+ "solidity", # Ratio of the area of the region to the area of its convex hull. Indicates how solid or compact a region is.
590
+ ]
py2ls/ips.py CHANGED
@@ -1146,6 +1146,7 @@ def fload(fpath, kind=None, **kwargs):
1146
1146
  "spider",
1147
1147
  "tga",
1148
1148
  "tiff",
1149
+ "tif",
1149
1150
  "webp",
1150
1151
  "json",
1151
1152
  ]
py2ls/netfinder.py CHANGED
@@ -671,8 +671,8 @@ def downloader(
671
671
  if dir_save:
672
672
  if rm_folder:
673
673
  ips.rm_folder(dir_save)
674
- if verbose:
675
- print(f"\n... attempting to download to local\n")
674
+ # if verbose:
675
+ # print(f"\n... attempting to download to local\n")
676
676
  fnames = [file_link.split("/")[-1] for file_link in file_links_all]
677
677
 
678
678
  for idx, file_link in enumerate(file_links_all):
@@ -688,6 +688,9 @@ def downloader(
688
688
  ext = next(
689
689
  (ftype for ftype in kind if ftype in file_link), None
690
690
  )
691
+ if ext is None:
692
+ ext = kind_
693
+ print("ehereerere", ext)
691
694
  if ext:
692
695
  corrected_fname = fname_corrector(fnames[idx], ext)
693
696
  corrected_fname = check_and_modify_filename(