[27c943]: / docs / index.html

Download this file

2863 lines (2580 with data), 194.8 kB

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to PathFlowAI’s documentation! &mdash; PathFlowAI 0.1 documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="#" class="icon icon-home"> PathFlowAI
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<!-- Local TOC -->
<div class="local-toc"><ul>
<li><a class="reference internal" href="#">Welcome to PathFlowAI’s documentation!</a><ul>
<li><a class="reference internal" href="#pathflowai-preprocess">pathflowai-preprocess</a><ul>
<li><a class="reference internal" href="#pathflowai-preprocess-alter-masks">alter_masks</a></li>
<li><a class="reference internal" href="#pathflowai-preprocess-collapse-annotations">collapse_annotations</a></li>
<li><a class="reference internal" href="#pathflowai-preprocess-preprocess-pipeline">preprocess_pipeline</a></li>
<li><a class="reference internal" href="#pathflowai-preprocess-remove-basename-from-db">remove_basename_from_db</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pathflowai-visualize">pathflowai-visualize</a><ul>
<li><a class="reference internal" href="#pathflowai-visualize-extract-patch">extract_patch</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-overlay-new-annotations">overlay_new_annotations</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-plot-embeddings">plot_embeddings</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-plot-image">plot_image</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-plot-image-umap-embeddings">plot_image_umap_embeddings</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-plot-predictions">plot_predictions</a></li>
<li><a class="reference internal" href="#pathflowai-visualize-shapley-plot">shapley_plot</a></li>
</ul>
</li>
<li><a class="reference internal" href="#pathflowai-monitor">pathflowai-monitor</a><ul>
<li><a class="reference internal" href="#pathflowai-monitor-monitor-usage">monitor_usage</a></li>
</ul>
</li>
<li><a class="reference internal" href="#datasets-py">datasets.py</a></li>
<li><a class="reference internal" href="#losses-py">losses.py</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#sampler-py">sampler.py</a></li>
<li><a class="reference internal" href="#schedulers-py">schedulers.py</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#visualize-py">visualize.py</a><ul>
</ul>
</li>
<li><a class="reference internal" href="#utils-py">utils.py</a></li>
</ul>
</li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
</ul>
</div>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">PathFlowAI</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="#">Docs</a> &raquo;</li>
<li>Welcome to PathFlowAI’s documentation!</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="welcome-to-pathflowai-s-documentation">
<h1>Welcome to PathFlowAI’s documentation!<a class="headerlink" href="#welcome-to-pathflowai-s-documentation" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
</div>
<a class="reference internal image-reference" href="_images/1.jpeg"><img alt="Download" class="align-center" src="_images/1.jpeg" style="width: 480.0px; height: 360.0px;" /></a>
<a class="reference internal image-reference" href="_images/2.jpeg"><img alt="Download" class="align-center" src="_images/2.jpeg" style="width: 480.0px; height: 360.0px;" /></a>
<a class="reference internal image-reference" href="_images/3.jpeg"><img alt="Download" class="align-center" src="_images/3.jpeg" style="width: 480.0px; height: 360.0px;" /></a>
<a class="reference internal image-reference" href="_images/4.jpeg"><img alt="Download" class="align-center" src="_images/4.jpeg" style="width: 480.0px; height: 360.0px;" /></a>
<div class="section" id="pathflowai-preprocess">
<h2>pathflowai-preprocess<a class="headerlink" href="#pathflowai-preprocess" title="Permalink to this headline"></a></h2>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>...
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-version">
<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-version" title="Permalink to this definition"></a></dt>
<dd><p>Show the version and exit.</p>
</dd></dl>
<div class="section" id="pathflowai-preprocess-alter-masks">
<h3>alter_masks<a class="headerlink" href="#pathflowai-preprocess-alter-masks" title="Permalink to this headline"></a></h3>
<p>Map list of values to other values in mask.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess alter_masks <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-alter-masks-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--mask_dir</code><code class="sig-prename descclassname"> &lt;mask_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-i" title="Permalink to this definition"></a></dt>
<dd><p>Input directory for masks. [default: ./inputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-alter-masks-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_dir</code><code class="sig-prename descclassname"> &lt;output_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-o" title="Permalink to this definition"></a></dt>
<dd><p>Output directory for new masks. [default: ./outputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-alter-masks-fr">
<code class="sig-name descname">-fr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--from_annotations</code><code class="sig-prename descclassname"> &lt;from_annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-fr" title="Permalink to this definition"></a></dt>
<dd><p>Annotations to switch from. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-alter-masks-to">
<code class="sig-name descname">-to</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--to_annotations</code><code class="sig-prename descclassname"> &lt;to_annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-alter-masks-to" title="Permalink to this definition"></a></dt>
<dd><p>Annotations to switch to. [default: ]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-preprocess-collapse-annotations">
<h3>collapse_annotations<a class="headerlink" href="#pathflowai-preprocess-collapse-annotations" title="Permalink to this headline"></a></h3>
<p>Adds annotation classes areas to other annotation classes in SQL DB when getting rid of some annotation classes.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess collapse_annotations <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_patch_db</code><code class="sig-prename descclassname"> &lt;input_patch_db&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-i" title="Permalink to this definition"></a></dt>
<dd><p>Input db. [default: patch_info_input.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_patch_db</code><code class="sig-prename descclassname"> &lt;output_patch_db&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-o" title="Permalink to this definition"></a></dt>
<dd><p>Output db. [default: patch_info_output.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-fr">
<code class="sig-name descname">-fr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--from_annotations</code><code class="sig-prename descclassname"> &lt;from_annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-fr" title="Permalink to this definition"></a></dt>
<dd><p>Annotations to switch from. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-to">
<code class="sig-name descname">-to</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--to_annotations</code><code class="sig-prename descclassname"> &lt;to_annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-to" title="Permalink to this definition"></a></dt>
<dd><p>Annotations to switch to. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-ps">
<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> &lt;patch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-ps" title="Permalink to this definition"></a></dt>
<dd><p>Patch size. [default: 224]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-rb">
<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> &lt;remove_background_annotation&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-rb" title="Permalink to this definition"></a></dt>
<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-collapse-annotations-ma">
<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> &lt;max_background_area&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-collapse-annotations-ma" title="Permalink to this definition"></a></dt>
<dd><p>Max background area before exclusion. [default: 0.05]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-preprocess-preprocess-pipeline">
<h3>preprocess_pipeline<a class="headerlink" href="#pathflowai-preprocess-preprocess-pipeline" title="Permalink to this headline"></a></h3>
<p>Preprocessing pipeline that accomplishes 3 things. 1: storage into ZARR format, 2: optional mask adjustment, 3: storage of patch-level information into SQL DB</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess preprocess_pipeline <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-npy">
<code class="sig-name descname">-npy</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--img2npy</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-npy" title="Permalink to this definition"></a></dt>
<dd><p>Image to numpy for faster read. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename of patches. [default: A01]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> &lt;input_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-i" title="Permalink to this definition"></a></dt>
<dd><p>Input directory for patches. [default: ./inputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-a">
<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"> &lt;annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-a" title="Permalink to this definition"></a></dt>
<dd><p>Annotations in image in order. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-pr">
<code class="sig-name descname">-pr</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--preprocess</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-pr" title="Permalink to this definition"></a></dt>
<dd><p>Run preprocessing pipeline. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-pa">
<code class="sig-name descname">-pa</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patches</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-pa" title="Permalink to this definition"></a></dt>
<dd><p>Add patches to SQL. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-t">
<code class="sig-name descname">-t</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--threshold</code><code class="sig-prename descclassname"> &lt;threshold&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-t" title="Permalink to this definition"></a></dt>
<dd><p>Threshold to remove non-purple slides. [default: 0.05]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-ps">
<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> &lt;patch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-ps" title="Permalink to this definition"></a></dt>
<dd><p>Patch size. [default: 224]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-it">
<code class="sig-name descname">-it</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--intensity_threshold</code><code class="sig-prename descclassname"> &lt;intensity_threshold&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-it" title="Permalink to this definition"></a></dt>
<dd><p>Intensity threshold to rate a pixel as non-white. [default: 100.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-g">
<code class="sig-name descname">-g</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--generate_finetune_segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-g" title="Permalink to this definition"></a></dt>
<dd><p>Generate patches for one segmentation mask class for targeted finetuning. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-tc">
<code class="sig-name descname">-tc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--target_segmentation_class</code><code class="sig-prename descclassname"> &lt;target_segmentation_class&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-tc" title="Permalink to this definition"></a></dt>
<dd><p>Segmentation Class to finetune on, output patches to another db. [default: 0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-tt">
<code class="sig-name descname">-tt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--target_threshold</code><code class="sig-prename descclassname"> &lt;target_threshold&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-tt" title="Permalink to this definition"></a></dt>
<dd><p>Threshold to include target for segmentation if saving one class. [default: 0.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-odb">
<code class="sig-name descname">-odb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--out_db</code><code class="sig-prename descclassname"> &lt;out_db&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-odb" title="Permalink to this definition"></a></dt>
<dd><p>Output patch database. [default: ./patch_info.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-am">
<code class="sig-name descname">-am</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--adjust_mask</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-am" title="Permalink to this definition"></a></dt>
<dd><p>Remove additional background regions from annotation mask. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-nn">
<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> &lt;n_neighbors&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-nn" title="Permalink to this definition"></a></dt>
<dd><p>If adjusting mask, number of neighbors connectivity to remove. [default: 5]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-preprocess-pipeline-bp">
<code class="sig-name descname">-bp</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basic_preprocess</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-preprocess-pipeline-bp" title="Permalink to this definition"></a></dt>
<dd><p>Basic preprocessing pipeline, annotation areas are not saved. Used for benchmarking tool against comparable pipelines [default: False]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-preprocess-remove-basename-from-db">
<h3>remove_basename_from_db<a class="headerlink" href="#pathflowai-preprocess-remove-basename-from-db" title="Permalink to this headline"></a></h3>
<p>Removes basename/ID from SQL DB.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-preprocess remove_basename_from_db <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_patch_db</code><code class="sig-prename descclassname"> &lt;input_patch_db&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-i" title="Permalink to this definition"></a></dt>
<dd><p>Input db. [default: patch_info_input.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--output_patch_db</code><code class="sig-prename descclassname"> &lt;output_patch_db&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-o" title="Permalink to this definition"></a></dt>
<dd><p>Output db. [default: patch_info_output.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename. [default: A01]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-preprocess-remove-basename-from-db-ps">
<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> &lt;patch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-preprocess-remove-basename-from-db-ps" title="Permalink to this definition"></a></dt>
<dd><p>Patch size. [default: 224]</p>
</dd></dl>
</div>
</div>
<div class="section" id="pathflowai-visualize">
<h2>pathflowai-visualize<a class="headerlink" href="#pathflowai-visualize" title="Permalink to this headline"></a></h2>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>...
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-version">
<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-version" title="Permalink to this definition"></a></dt>
<dd><p>Show the version and exit.</p>
</dd></dl>
<div class="section" id="pathflowai-visualize-extract-patch">
<h3>extract_patch<a class="headerlink" href="#pathflowai-visualize-extract-patch" title="Permalink to this headline"></a></h3>
<p>Extract image of patch of any size/location and output to image file</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize extract_patch <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> &lt;input_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-i" title="Permalink to this definition"></a></dt>
<dd><p>Input directory for patches. [default: ./inputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename of patches. [default: A01]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-p">
<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_info_file</code><code class="sig-prename descclassname"> &lt;patch_info_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-p" title="Permalink to this definition"></a></dt>
<dd><p>Datbase containing all patches [default: patch_info.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-ps">
<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> &lt;patch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-ps" title="Permalink to this definition"></a></dt>
<dd><p>Patch size. [default: 224]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-x">
<code class="sig-name descname">-x</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--x</code><code class="sig-prename descclassname"> &lt;x&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-x" title="Permalink to this definition"></a></dt>
<dd><p>X Coordinate of patch. [default: 0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-y">
<code class="sig-name descname">-y</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--y</code><code class="sig-prename descclassname"> &lt;y&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-y" title="Permalink to this definition"></a></dt>
<dd><p>Y coordinate of patch. [default: 0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> &lt;outputfname&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-o" title="Permalink to this definition"></a></dt>
<dd><p>Output extracted image. [default: ./output_image.png]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-s">
<code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-s" title="Permalink to this definition"></a></dt>
<dd><p>Plot segmentations. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-sc">
<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_segmentation_classes</code><code class="sig-prename descclassname"> &lt;n_segmentation_classes&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-sc" title="Permalink to this definition"></a></dt>
<dd><p>Number segmentation classes [default: 4]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-extract-patch-c">
<code class="sig-name descname">-c</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--custom_segmentation</code><code class="sig-prename descclassname"> &lt;custom_segmentation&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-extract-patch-c" title="Permalink to this definition"></a></dt>
<dd><p>Add custom segmentation map from prediction, in npy [default: ]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-overlay-new-annotations">
<h3>overlay_new_annotations<a class="headerlink" href="#pathflowai-visualize-overlay-new-annotations" title="Permalink to this headline"></a></h3>
<p>Custom annotations, in format [Point: x, y, Point: x, y … ] one line like this per polygon, overlap these polygons on top of WSI.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize overlay_new_annotations <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--img_file</code><code class="sig-prename descclassname"> &lt;img_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-i" title="Permalink to this definition"></a></dt>
<dd><p>Input image. [default: image.txt]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-a">
<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotation_txt</code><code class="sig-prename descclassname"> &lt;annotation_txt&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-a" title="Permalink to this definition"></a></dt>
<dd><p>Column of annotations [default: annotation.txt]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-ocf">
<code class="sig-name descname">-ocf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--original_compression_factor</code><code class="sig-prename descclassname"> &lt;original_compression_factor&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-ocf" title="Permalink to this definition"></a></dt>
<dd><p>How much compress image. [default: 1.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-cf">
<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> &lt;compression_factor&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-cf" title="Permalink to this definition"></a></dt>
<dd><p>How much compress image. [default: 3.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-overlay-new-annotations-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> &lt;outputfilename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-overlay-new-annotations-o" title="Permalink to this definition"></a></dt>
<dd><p>Output extracted image. [default: ./output_image.png]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-plot-embeddings">
<h3>plot_embeddings<a class="headerlink" href="#pathflowai-visualize-plot-embeddings" title="Permalink to this headline"></a></h3>
<p>Perform UMAP embeddings of patches and plot using plotly.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_embeddings <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--embeddings_file</code><code class="sig-prename descclassname"> &lt;embeddings_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-i" title="Permalink to this definition"></a></dt>
<dd><p>Embeddings. [default: predictions/embeddings.pkl]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--plotly_output_file</code><code class="sig-prename descclassname"> &lt;plotly_output_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-o" title="Permalink to this definition"></a></dt>
<dd><p>Plotly output file. [default: predictions/embeddings.html]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-a">
<code class="sig-name descname">-a</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"> &lt;annotations&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-a" title="Permalink to this definition"></a></dt>
<dd><p>Multiple annotations to color image. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-rb">
<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> &lt;remove_background_annotation&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-rb" title="Permalink to this definition"></a></dt>
<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-ma">
<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> &lt;max_background_area&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-ma" title="Permalink to this definition"></a></dt>
<dd><p>Max background area before exclusion. [default: 0.05]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename of patches. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-embeddings-nn">
<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> &lt;n_neighbors&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-embeddings-nn" title="Permalink to this definition"></a></dt>
<dd><p>Number nearest neighbors. [default: 8]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-plot-image">
<h3>plot_image<a class="headerlink" href="#pathflowai-visualize-plot-image" title="Permalink to this headline"></a></h3>
<p>Plots the whole slide image supplied.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_image <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--image_file</code><code class="sig-prename descclassname"> &lt;image_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-i" title="Permalink to this definition"></a></dt>
<dd><p>Input image file. [default: ./inputs/a.svs]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-cf">
<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> &lt;compression_factor&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-cf" title="Permalink to this definition"></a></dt>
<dd><p>How much compress image. [default: 3.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> &lt;outputfname&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-o" title="Permalink to this definition"></a></dt>
<dd><p>Output extracted image. [default: ./output_image.png]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-plot-image-umap-embeddings">
<h3>plot_image_umap_embeddings<a class="headerlink" href="#pathflowai-visualize-plot-image-umap-embeddings" title="Permalink to this headline"></a></h3>
<p>Plots a UMAP embedding with each point as its corresponding patch image.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_image_umap_embeddings <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> &lt;input_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-i" title="Permalink to this definition"></a></dt>
<dd><p>Input directory for patches. [default: ./inputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-e">
<code class="sig-name descname">-e</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--embeddings_file</code><code class="sig-prename descclassname"> &lt;embeddings_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-e" title="Permalink to this definition"></a></dt>
<dd><p>Embeddings. [default: predictions/embeddings.pkl]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename of patches. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> &lt;outputfilename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-o" title="Permalink to this definition"></a></dt>
<dd><p>Embedding visualization. [default: predictions/shap_plots.png]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-mpl">
<code class="sig-name descname">-mpl</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--mpl_scatter</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-mpl" title="Permalink to this definition"></a></dt>
<dd><p>Plot segmentations. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-rb">
<code class="sig-name descname">-rb</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--remove_background_annotation</code><code class="sig-prename descclassname"> &lt;remove_background_annotation&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-rb" title="Permalink to this definition"></a></dt>
<dd><p>If selected, removes 100% background patches based on this annotation. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-ma">
<code class="sig-name descname">-ma</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--max_background_area</code><code class="sig-prename descclassname"> &lt;max_background_area&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-ma" title="Permalink to this definition"></a></dt>
<dd><p>Max background area before exclusion. [default: 0.05]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-z">
<code class="sig-name descname">-z</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--zoom</code><code class="sig-prename descclassname"> &lt;zoom&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-z" title="Permalink to this definition"></a></dt>
<dd><p>Size of images. [default: 0.05]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-nn">
<code class="sig-name descname">-nn</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_neighbors</code><code class="sig-prename descclassname"> &lt;n_neighbors&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-nn" title="Permalink to this definition"></a></dt>
<dd><p>Number nearest neighbors. [default: 8]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sc">
<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--sort_col</code><code class="sig-prename descclassname"> &lt;sort_col&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sc" title="Permalink to this definition"></a></dt>
<dd><p>Sort samples on this column. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sm">
<code class="sig-name descname">-sm</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--sort_mode</code><code class="sig-prename descclassname"> &lt;sort_mode&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-image-umap-embeddings-sm" title="Permalink to this definition"></a></dt>
<dd><p>Sort ascending or descending. [default: asc]</p>
<dl class="field-list simple">
<dt class="field-odd">Options</dt>
<dd class="field-odd"><p>asc|desc</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-plot-predictions">
<h3>plot_predictions<a class="headerlink" href="#pathflowai-visualize-plot-predictions" title="Permalink to this headline"></a></h3>
<p>Overlays classification, regression and segmentation patch level predictions on top of whole slide image.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize plot_predictions <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-i">
<code class="sig-name descname">-i</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--input_dir</code><code class="sig-prename descclassname"> &lt;input_dir&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-i" title="Permalink to this definition"></a></dt>
<dd><p>Input directory for patches. [default: ./inputs/]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-b">
<code class="sig-name descname">-b</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--basename</code><code class="sig-prename descclassname"> &lt;basename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-b" title="Permalink to this definition"></a></dt>
<dd><p>Basename of patches. [default: A01]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-p">
<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_info_file</code><code class="sig-prename descclassname"> &lt;patch_info_file&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-p" title="Permalink to this definition"></a></dt>
<dd><p>Datbase containing all patches [default: patch_info.db]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-ps">
<code class="sig-name descname">-ps</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--patch_size</code><code class="sig-prename descclassname"> &lt;patch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-ps" title="Permalink to this definition"></a></dt>
<dd><p>Patch size. [default: 224]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfname</code><code class="sig-prename descclassname"> &lt;outputfname&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-o" title="Permalink to this definition"></a></dt>
<dd><p>Output extracted image. [default: ./output_image.png]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-an">
<code class="sig-name descname">-an</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotations</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-an" title="Permalink to this definition"></a></dt>
<dd><p>Plot annotations instead of predictions. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-cf">
<code class="sig-name descname">-cf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--compression_factor</code><code class="sig-prename descclassname"> &lt;compression_factor&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-cf" title="Permalink to this definition"></a></dt>
<dd><p>How much compress image. [default: 3.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-al">
<code class="sig-name descname">-al</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--alpha</code><code class="sig-prename descclassname"> &lt;alpha&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-al" title="Permalink to this definition"></a></dt>
<dd><p>How much to give annotations/predictions versus original image. [default: 0.8]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-s">
<code class="sig-name descname">-s</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--segmentation</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-s" title="Permalink to this definition"></a></dt>
<dd><p>Plot segmentations. [default: False]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-sc">
<code class="sig-name descname">-sc</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_segmentation_classes</code><code class="sig-prename descclassname"> &lt;n_segmentation_classes&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-sc" title="Permalink to this definition"></a></dt>
<dd><p>Number segmentation classes [default: 4]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-c">
<code class="sig-name descname">-c</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--custom_segmentation</code><code class="sig-prename descclassname"> &lt;custom_segmentation&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-c" title="Permalink to this definition"></a></dt>
<dd><p>Add custom segmentation map from prediction, npy format. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-ac">
<code class="sig-name descname">-ac</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--annotation_col</code><code class="sig-prename descclassname"> &lt;annotation_col&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-ac" title="Permalink to this definition"></a></dt>
<dd><p>Column of annotations [default: annotation]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-sf">
<code class="sig-name descname">-sf</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--scaling_factor</code><code class="sig-prename descclassname"> &lt;scaling_factor&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-sf" title="Permalink to this definition"></a></dt>
<dd><p>Multiply all prediction scores by this amount. [default: 1.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-plot-predictions-tif">
<code class="sig-name descname">-tif</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--tif_file</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-visualize-plot-predictions-tif" title="Permalink to this definition"></a></dt>
<dd><p>Write to tiff file. [default: False]</p>
</dd></dl>
</div>
<div class="section" id="pathflowai-visualize-shapley-plot">
<h3>shapley_plot<a class="headerlink" href="#pathflowai-visualize-shapley-plot" title="Permalink to this headline"></a></h3>
<p>Run SHAPley attribution method on patches after classification task to see where model made prediction based on.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-visualize shapley_plot <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-m">
<code class="sig-name descname">-m</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--model_pkl</code><code class="sig-prename descclassname"> &lt;model_pkl&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-m" title="Permalink to this definition"></a></dt>
<dd><p>Plotly output file. [default: ]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-bs">
<code class="sig-name descname">-bs</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--batch_size</code><code class="sig-prename descclassname"> &lt;batch_size&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-bs" title="Permalink to this definition"></a></dt>
<dd><p>Batch size. [default: 32]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-o">
<code class="sig-name descname">-o</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--outputfilename</code><code class="sig-prename descclassname"> &lt;outputfilename&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-o" title="Permalink to this definition"></a></dt>
<dd><p>SHAPley visualization. [default: predictions/shap_plots.png]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-mth">
<code class="sig-name descname">-mth</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--method</code><code class="sig-prename descclassname"> &lt;method&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-mth" title="Permalink to this definition"></a></dt>
<dd><p>Method of explaining. [default: deep]</p>
<dl class="field-list simple">
<dt class="field-odd">Options</dt>
<dd class="field-odd"><p>deep|gradient</p>
</dd>
</dl>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-l">
<code class="sig-name descname">-l</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--local_smoothing</code><code class="sig-prename descclassname"> &lt;local_smoothing&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-l" title="Permalink to this definition"></a></dt>
<dd><p>Local smoothing of SHAP scores. [default: 0.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-ns">
<code class="sig-name descname">-ns</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--n_samples</code><code class="sig-prename descclassname"> &lt;n_samples&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-ns" title="Permalink to this definition"></a></dt>
<dd><p>Number shapley samples for shapley regression (gradient explainer). [default: 32]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-visualize-shapley-plot-p">
<code class="sig-name descname">-p</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--pred_out</code><code class="sig-prename descclassname"> &lt;pred_out&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-visualize-shapley-plot-p" title="Permalink to this definition"></a></dt>
<dd><p>If not none, output prediction as shap label. [default: none]</p>
<dl class="field-list simple">
<dt class="field-odd">Options</dt>
<dd class="field-odd"><p>none|sigmoid|softmax</p>
</dd>
</dl>
</dd></dl>
</div>
</div>
<div class="section" id="pathflowai-monitor">
<h2>pathflowai-monitor<a class="headerlink" href="#pathflowai-monitor" title="Permalink to this headline"></a></h2>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-monitor <span class="o">[</span>OPTIONS<span class="o">]</span> COMMAND <span class="o">[</span>ARGS<span class="o">]</span>...
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-monitor-version">
<code class="sig-name descname">--version</code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pathflowai-monitor-version" title="Permalink to this definition"></a></dt>
<dd><p>Show the version and exit.</p>
</dd></dl>
<div class="section" id="pathflowai-monitor-monitor-usage">
<h3>monitor_usage<a class="headerlink" href="#pathflowai-monitor-monitor-usage" title="Permalink to this headline"></a></h3>
<p>Monitor Usage over Time Interval.</p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>pathflowai-monitor monitor_usage <span class="o">[</span>OPTIONS<span class="o">]</span>
</pre></div>
</div>
<p class="rubric">Options</p>
<dl class="option">
<dt id="cmdoption-pathflowai-monitor-monitor-usage-csv">
<code class="sig-name descname">-csv</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--records_output_csv</code><code class="sig-prename descclassname"> &lt;records_output_csv&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-csv" title="Permalink to this definition"></a></dt>
<dd><p>Where to store records. [default: records.csv]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-monitor-monitor-usage-tt">
<code class="sig-name descname">-tt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--total_time</code><code class="sig-prename descclassname"> &lt;total_time&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-tt" title="Permalink to this definition"></a></dt>
<dd><p>Total time to monitor for in minutes. [default: 1.0]</p>
</dd></dl>
<dl class="option">
<dt id="cmdoption-pathflowai-monitor-monitor-usage-dt">
<code class="sig-name descname">-dt</code><code class="sig-prename descclassname"></code><code class="sig-prename descclassname">, </code><code class="sig-name descname">--delay_time</code><code class="sig-prename descclassname"> &lt;delay_time&gt;</code><a class="headerlink" href="#cmdoption-pathflowai-monitor-monitor-usage-dt" title="Permalink to this definition"></a></dt>
<dd><p>Time between samples, in seconds. [default: 1.0]</p>
</dd></dl>
</div>
</div>
<span class="target" id="module-pathflowai.datasets"></span><div class="section" id="datasets-py">
<h2>datasets.py<a class="headerlink" href="#datasets-py" title="Permalink to this headline"></a></h2>
<p>Houses the DynamicImageDataset class, also functions to help with image color channel normalization, transformers, etc..</p>
<dl class="class">
<dt id="pathflowai.datasets.DynamicImageDataset">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">DynamicImageDataset</code><span class="sig-paren">(</span><em class="sig-param">dataset_df</em>, <em class="sig-param">set</em>, <em class="sig-param">patch_info_file</em>, <em class="sig-param">transformers</em>, <em class="sig-param">input_dir</em>, <em class="sig-param">target_names</em>, <em class="sig-param">pos_annotation_class</em>, <em class="sig-param">other_annotations=[]</em>, <em class="sig-param">segmentation=False</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">fix_names=True</em>, <em class="sig-param">target_segmentation_class=-1</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">oversampling_factor=1.0</em>, <em class="sig-param">n_segmentation_classes=4</em>, <em class="sig-param">gdl=False</em>, <em class="sig-param">mt_bce=False</em>, <em class="sig-param">classify_annotations=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset" title="Permalink to this definition"></a></dt>
<dd><p>Generate image dataset that accesses images and annotations via dask.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>dataset_df:dataframe</strong></dt><dd><p>Dataframe with WSI, which set it is in (train/test/val) and corresponding WSI labels if applicable.</p>
</dd>
<dt><strong>set:str</strong></dt><dd><p>Whether train, test, val or pass (normalization) set.</p>
</dd>
<dt><strong>patch_info_file:str</strong></dt><dd><p>SQL db with positional and annotation information on each slide.</p>
</dd>
<dt><strong>transformers:dict</strong></dt><dd><p>Contains transformers to apply on images.</p>
</dd>
<dt><strong>input_dir:str</strong></dt><dd><p>Directory where images comes from.</p>
</dd>
<dt><strong>target_names:list/str</strong></dt><dd><p>Names of initial targets, which may be modified.</p>
</dd>
<dt><strong>pos_annotation_class:str</strong></dt><dd><p>If selected and predicting on WSI, this class is labeled as a positive from the WSI, while the other classes are not.</p>
</dd>
<dt><strong>other_annotations:list</strong></dt><dd><p>Other annotations to consider from patch info db.</p>
</dd>
<dt><strong>segmentation:bool</strong></dt><dd><p>Conducting segmentation task?</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
<dt><strong>fix_names:bool</strong></dt><dd><p>Whether to change the names of dataset_df.</p>
</dd>
<dt><strong>target_segmentation_class:list</strong></dt><dd><p>Now can be used for classification as well, matched with two below options, samples images only from this class. Can specify this and below two options multiple times.</p>
</dd>
<dt><strong>target_threshold:list</strong></dt><dd><p>Sampled only if above this threshold of occurence in the patches.</p>
</dd>
<dt><strong>oversampling_factor:list</strong></dt><dd><p>Over sample them at this amount.</p>
</dd>
<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Number classes to segment.</p>
</dd>
<dt><strong>gdl:bool</strong></dt><dd><p>Using generalized dice loss?</p>
</dd>
<dt><strong>mt_bce:bool</strong></dt><dd><p>For multi-target prediction tasks.</p>
</dd>
<dt><strong>classify_annotations:bool</strong></dt><dd><p>For classifying annotations.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.binarize_annotations" title="pathflowai.datasets.DynamicImageDataset.binarize_annotations"><code class="xref py py-obj docutils literal notranslate"><span class="pre">binarize_annotations</span></code></a>(self[, binarizer, …])</p></td>
<td><p>Label binarize some annotations or threshold them if classifying slide annotations.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.concat" title="pathflowai.datasets.DynamicImageDataset.concat"><code class="xref py py-obj docutils literal notranslate"><span class="pre">concat</span></code></a>(self, other_dataset)</p></td>
<td><p>Concatenate this dataset with others.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.get_class_weights" title="pathflowai.datasets.DynamicImageDataset.get_class_weights"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_class_weights</span></code></a>(self[, i])</p></td>
<td><p>Weight loss function with weights inversely proportional to the class appearence.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.retain_ID" title="pathflowai.datasets.DynamicImageDataset.retain_ID"><code class="xref py py-obj docutils literal notranslate"><span class="pre">retain_ID</span></code></a>(self, ID)</p></td>
<td><p>Reduce the sample set to just images from one ID.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.split_by_ID" title="pathflowai.datasets.DynamicImageDataset.split_by_ID"><code class="xref py py-obj docutils literal notranslate"><span class="pre">split_by_ID</span></code></a>(self)</p></td>
<td><p>Generator similar to groupby, but splits up by ID, generates (ID,data) using retain_ID.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.datasets.DynamicImageDataset.subsample" title="pathflowai.datasets.DynamicImageDataset.subsample"><code class="xref py py-obj docutils literal notranslate"><span class="pre">subsample</span></code></a>(self, p)</p></td>
<td><p>Sample subset of dataset.</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.binarize_annotations">
<code class="sig-name descname">binarize_annotations</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">binarizer=None</em>, <em class="sig-param">num_targets=1</em>, <em class="sig-param">binary_threshold=0.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.binarize_annotations"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.binarize_annotations" title="Permalink to this definition"></a></dt>
<dd><p>Label binarize some annotations or threshold them if classifying slide annotations.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>binarizer:LabelBinarizer</strong></dt><dd><p>Binarizes the labels of a column(s)</p>
</dd>
<dt><strong>num_targets:int</strong></dt><dd><p>Number of desired targets to preidict on.</p>
</dd>
<dt><strong>binary_threshold:float</strong></dt><dd><p>Amount of annotation in patch before positive annotation.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>binarizer</dt><dd></dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.concat">
<code class="sig-name descname">concat</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">other_dataset</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.concat"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.concat" title="Permalink to this definition"></a></dt>
<dd><p>Concatenate this dataset with others. Updates its own internal attributes.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>other_dataset:DynamicImageDataset</strong></dt><dd><p>Other image dataset.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.get_class_weights">
<code class="sig-name descname">get_class_weights</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">i=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.get_class_weights"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.get_class_weights" title="Permalink to this definition"></a></dt>
<dd><p>Weight loss function with weights inversely proportional to the class appearence.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>i:int</strong></dt><dd><p>If multi-target, class used for weighting.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>self</dt><dd><p>Dataset.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.retain_ID">
<code class="sig-name descname">retain_ID</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.retain_ID"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.retain_ID" title="Permalink to this definition"></a></dt>
<dd><p>Reduce the sample set to just images from one ID.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>ID:str</strong></dt><dd><p>Basename/ID to predict on.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>self</dt><dd></dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.split_by_ID">
<code class="sig-name descname">split_by_ID</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.split_by_ID"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.split_by_ID" title="Permalink to this definition"></a></dt>
<dd><p>Generator similar to groupby, but splits up by ID, generates (ID,data) using retain_ID.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>generator</dt><dd><p>ID, DynamicDataset</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.datasets.DynamicImageDataset.subsample">
<code class="sig-name descname">subsample</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">p</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#DynamicImageDataset.subsample"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.DynamicImageDataset.subsample" title="Permalink to this definition"></a></dt>
<dd><p>Sample subset of dataset.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>p:float</strong></dt><dd><p>Fraction to subsample.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.datasets.RandomRotate90">
<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">RandomRotate90</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#RandomRotate90"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.RandomRotate90" title="Permalink to this definition"></a></dt>
<dd><p>Transformer for random 90 degree rotation image.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>function</dt><dd><p>Transformer function for operation.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.datasets.create_transforms">
<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">create_transforms</code><span class="sig-paren">(</span><em class="sig-param">mean</em>, <em class="sig-param">std</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#create_transforms"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.create_transforms" title="Permalink to this definition"></a></dt>
<dd><p>Create transformers.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>mean:list</strong></dt><dd><p>See get_data_transforms.</p>
</dd>
<dt><strong>std:list</strong></dt><dd><p>See get_data_transforms.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dict</dt><dd><p>Transformers.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.datasets.get_data_transforms">
<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">get_data_transforms</code><span class="sig-paren">(</span><em class="sig-param">patch_size=None</em>, <em class="sig-param">mean=[]</em>, <em class="sig-param">std=[]</em>, <em class="sig-param">resize=False</em>, <em class="sig-param">transform_platform='torch'</em>, <em class="sig-param">elastic=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#get_data_transforms"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.get_data_transforms" title="Permalink to this definition"></a></dt>
<dd><p>Get data transformers for training test and validation sets.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>patch_size:int</strong></dt><dd><p>Original patch size being transformed.</p>
</dd>
<dt><strong>mean:list of float</strong></dt><dd><p>Mean RGB</p>
</dd>
<dt><strong>std:list of float</strong></dt><dd><p>Std RGB</p>
</dd>
<dt><strong>resize:int</strong></dt><dd><p>Which patch size to resize to.</p>
</dd>
<dt><strong>transform_platform:str</strong></dt><dd><p>Use pytorch or albumentation transforms.</p>
</dd>
<dt><strong>elastic:bool</strong></dt><dd><p>Whether to add elastic deformations from albumentations.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dict</dt><dd><p>Transformers.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.datasets.get_normalizer">
<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">get_normalizer</code><span class="sig-paren">(</span><em class="sig-param">normalization_file</em>, <em class="sig-param">dataset_opts</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#get_normalizer"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.get_normalizer" title="Permalink to this definition"></a></dt>
<dd><p>Find mean and standard deviation of images in batches.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>normalization_file:str</strong></dt><dd><p>File to store normalization information.</p>
</dd>
<dt><strong>dataset_opts:type</strong></dt><dd><p>Dictionary storing information to create DynamicDataset class.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dict</dt><dd><p>Stores RGB mean, stdev.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.datasets.segmentation_transform">
<code class="sig-prename descclassname">pathflowai.datasets.</code><code class="sig-name descname">segmentation_transform</code><span class="sig-paren">(</span><em class="sig-param">img</em>, <em class="sig-param">mask</em>, <em class="sig-param">transformer</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/datasets.html#segmentation_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.datasets.segmentation_transform" title="Permalink to this definition"></a></dt>
<dd><p>Run albumentations and return an image and its segmentation mask.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>img:array</strong></dt><dd><p>Image as array</p>
</dd>
<dt><strong>mask:array</strong></dt><dd><p>Categorical pixel by pixel.</p>
</dd>
<dt><strong>transformer :</strong></dt><dd><p>Transformation object.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>tuple arrays</dt><dd><p>Image and mask array.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</div>
<span class="target" id="module-pathflowai.losses"></span><div class="section" id="losses-py">
<h2>losses.py<a class="headerlink" href="#losses-py" title="Permalink to this headline"></a></h2>
<p>Some additional loss functions that can be called using the pipeline, some of which still to be implemented.</p>
<dl class="class">
<dt id="pathflowai.losses.FocalLoss">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">FocalLoss</code><span class="sig-paren">(</span><em class="sig-param">num_class</em>, <em class="sig-param">alpha=None</em>, <em class="sig-param">gamma=2</em>, <em class="sig-param">balance_index=-1</em>, <em class="sig-param">smooth=None</em>, <em class="sig-param">size_average=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#FocalLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.FocalLoss" title="Permalink to this definition"></a></dt>
<dd><p># <a class="reference external" href="https://raw.githubusercontent.com/Hsuxu/Loss_ToolBox-PyTorch/master/FocalLoss/FocalLoss.py">https://raw.githubusercontent.com/Hsuxu/Loss_ToolBox-PyTorch/master/FocalLoss/FocalLoss.py</a>
This is a implementation of Focal Loss with smooth label cross entropy supported which is proposed in
‘Focal Loss for Dense Object Detection. (<a class="reference external" href="https://arxiv.org/abs/1708.02002">https://arxiv.org/abs/1708.02002</a>)’</p>
<blockquote>
<div><p>Focal_Loss= -1*alpha*(1-pt)*log(pt)</p>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>num_class</strong></p></li>
<li><p><strong>alpha</strong> – (tensor) 3D or 4D the scalar factor for this criterion</p></li>
<li><p><strong>gamma</strong> – (float,double) gamma &gt; 0 reduces the relative loss for well-classified examples (p&gt;0.5) putting more
focus on hard misclassified example</p></li>
<li><p><strong>smooth</strong> – (float,double) smooth value when cross entropy</p></li>
<li><p><strong>balance_index</strong> – (int) balance class index, should be specific when alpha is float</p></li>
<li><p><strong>size_average</strong> – (bool, optional) By default, the losses are averaged over each loss element in the batch.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, \*input, \*\*kwargs)</p></td>
<td><p>Call self as a function.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_module</span></code>(self, name, module)</p></td>
<td><p>Adds a child module to the current module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply</span></code>(self, fn)</p></td>
<td><p>Applies <code class="docutils literal notranslate"><span class="pre">fn</span></code> recursively to every submodule (as returned by <code class="docutils literal notranslate"><span class="pre">.children()</span></code>) as well as self.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">buffers</span></code>(self[, recurse])</p></td>
<td><p>Returns an iterator over module buffers.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">children</span></code>(self)</p></td>
<td><p>Returns an iterator over immediate children modules.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code>(self)</p></td>
<td><p>Moves all model parameters and buffers to the CPU.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code>(self[, device])</p></td>
<td><p>Moves all model parameters and buffers to the GPU.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">double</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">double</span></code> datatype.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval</span></code>(self)</p></td>
<td><p>Sets the module in evaluation mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">extra_repr</span></code>(self)</p></td>
<td><p>Set the extra representation of the module</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">float</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to float datatype.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.losses.FocalLoss.forward" title="pathflowai.losses.FocalLoss.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(self, logit, target)</p></td>
<td><p>Defines the computation performed at every call.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">half</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">half</span></code> datatype.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict[, strict])</p></td>
<td><p>Copies parameters and buffers from <code class="xref py py-attr docutils literal notranslate"><span class="pre">state_dict</span></code> into this module and its descendants.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">modules</span></code>(self)</p></td>
<td><p>Returns an iterator over all modules in the network.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_buffers</span></code>(self[, prefix, recurse])</p></td>
<td><p>Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_children</span></code>(self)</p></td>
<td><p>Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_modules</span></code>(self[, memo, prefix])</p></td>
<td><p>Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_parameters</span></code>(self[, prefix, recurse])</p></td>
<td><p>Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">parameters</span></code>(self[, recurse])</p></td>
<td><p>Returns an iterator over module parameters.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_backward_hook</span></code>(self, hook)</p></td>
<td><p>Registers a backward hook on the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_buffer</span></code>(self, name, tensor)</p></td>
<td><p>Adds a persistent buffer to the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_hook</span></code>(self, hook)</p></td>
<td><p>Registers a forward hook on the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_pre_hook</span></code>(self, hook)</p></td>
<td><p>Registers a forward pre-hook on the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_parameter</span></code>(self, name, param)</p></td>
<td><p>Adds a parameter to the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self[, destination, prefix, …])</p></td>
<td><p>Returns a dictionary containing a whole state of the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">to</span></code>(self, \*args, \*\*kwargs)</p></td>
<td><p>Moves and/or casts the parameters and buffers.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">train</span></code>(self[, mode])</p></td>
<td><p>Sets the module in training mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">type</span></code>(self, dst_type)</p></td>
<td><p>Casts all parameters and buffers to <code class="xref py py-attr docutils literal notranslate"><span class="pre">dst_type</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">zero_grad</span></code>(self)</p></td>
<td><p>Sets gradients of all model parameters to zero.</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 62%" />
<col style="width: 38%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>share_memory</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.losses.FocalLoss.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">logit</em>, <em class="sig-param">target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#FocalLoss.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.FocalLoss.forward" title="Permalink to this definition"></a></dt>
<dd><p>Defines the computation performed at every call.</p>
<p>Should be overridden by all subclasses.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Although the recipe for forward pass needs to be defined within
this function, one should call the <code class="xref py py-class docutils literal notranslate"><span class="pre">Module</span></code> instance afterwards
instead of this since the former takes care of running the
registered hooks while the latter silently ignores them.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pathflowai.losses.GeneralizedDice">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">GeneralizedDice</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDice" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py</a></p>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, probs, target, _)</p></td>
<td><p>Call self as a function.</p></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="pathflowai.losses.GeneralizedDiceLoss">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">GeneralizedDiceLoss</code><span class="sig-paren">(</span><em class="sig-param">weight=None</em>, <em class="sig-param">channelwise=False</em>, <em class="sig-param">eps=1e-06</em>, <em class="sig-param">add_softmax=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDiceLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDiceLoss" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/extensions/criteria/set_similarity_measures.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/extensions/criteria/set_similarity_measures.py</a>
Computes the scalar Generalized Dice Loss defined in <a class="reference external" href="https://arxiv.org/abs/1707.03237">https://arxiv.org/abs/1707.03237</a></p>
<p>This version works for multiple classes and expects predictions for every class (e.g. softmax output) and
one-hot targets for every class.</p>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, \*input, \*\*kwargs)</p></td>
<td><p>Call self as a function.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_module</span></code>(self, name, module)</p></td>
<td><p>Adds a child module to the current module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">apply</span></code>(self, fn)</p></td>
<td><p>Applies <code class="docutils literal notranslate"><span class="pre">fn</span></code> recursively to every submodule (as returned by <code class="docutils literal notranslate"><span class="pre">.children()</span></code>) as well as self.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">buffers</span></code>(self[, recurse])</p></td>
<td><p>Returns an iterator over module buffers.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">children</span></code>(self)</p></td>
<td><p>Returns an iterator over immediate children modules.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cpu</span></code>(self)</p></td>
<td><p>Moves all model parameters and buffers to the CPU.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">cuda</span></code>(self[, device])</p></td>
<td><p>Moves all model parameters and buffers to the GPU.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">double</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">double</span></code> datatype.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">eval</span></code>(self)</p></td>
<td><p>Sets the module in evaluation mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">extra_repr</span></code>(self)</p></td>
<td><p>Set the extra representation of the module</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">float</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to float datatype.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.losses.GeneralizedDiceLoss.forward" title="pathflowai.losses.GeneralizedDiceLoss.forward"><code class="xref py py-obj docutils literal notranslate"><span class="pre">forward</span></code></a>(self, input, target)</p></td>
<td><p>input: torch.FloatTensor or torch.cuda.FloatTensor target: torch.FloatTensor or torch.cuda.FloatTensor</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">half</span></code>(self)</p></td>
<td><p>Casts all floating point parameters and buffers to <code class="docutils literal notranslate"><span class="pre">half</span></code> datatype.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict[, strict])</p></td>
<td><p>Copies parameters and buffers from <code class="xref py py-attr docutils literal notranslate"><span class="pre">state_dict</span></code> into this module and its descendants.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">modules</span></code>(self)</p></td>
<td><p>Returns an iterator over all modules in the network.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_buffers</span></code>(self[, prefix, recurse])</p></td>
<td><p>Returns an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_children</span></code>(self)</p></td>
<td><p>Returns an iterator over immediate children modules, yielding both the name of the module as well as the module itself.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_modules</span></code>(self[, memo, prefix])</p></td>
<td><p>Returns an iterator over all modules in the network, yielding both the name of the module as well as the module itself.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">named_parameters</span></code>(self[, prefix, recurse])</p></td>
<td><p>Returns an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">parameters</span></code>(self[, recurse])</p></td>
<td><p>Returns an iterator over module parameters.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_backward_hook</span></code>(self, hook)</p></td>
<td><p>Registers a backward hook on the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_buffer</span></code>(self, name, tensor)</p></td>
<td><p>Adds a persistent buffer to the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_hook</span></code>(self, hook)</p></td>
<td><p>Registers a forward hook on the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_forward_pre_hook</span></code>(self, hook)</p></td>
<td><p>Registers a forward pre-hook on the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">register_parameter</span></code>(self, name, param)</p></td>
<td><p>Adds a parameter to the module.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self[, destination, prefix, …])</p></td>
<td><p>Returns a dictionary containing a whole state of the module.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">to</span></code>(self, \*args, \*\*kwargs)</p></td>
<td><p>Moves and/or casts the parameters and buffers.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">train</span></code>(self[, mode])</p></td>
<td><p>Sets the module in training mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">type</span></code>(self, dst_type)</p></td>
<td><p>Casts all parameters and buffers to <code class="xref py py-attr docutils literal notranslate"><span class="pre">dst_type</span></code>.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">zero_grad</span></code>(self)</p></td>
<td><p>Sets gradients of all model parameters to zero.</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 62%" />
<col style="width: 38%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>share_memory</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.losses.GeneralizedDiceLoss.forward">
<code class="sig-name descname">forward</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">input</em>, <em class="sig-param">target</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#GeneralizedDiceLoss.forward"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.GeneralizedDiceLoss.forward" title="Permalink to this definition"></a></dt>
<dd><p>input: torch.FloatTensor or torch.cuda.FloatTensor
target: torch.FloatTensor or torch.cuda.FloatTensor</p>
<dl class="simple">
<dt>Expected shape of the inputs:</dt><dd><ul class="simple">
<li><p>if not channelwise: (batch_size, nb_classes, …)</p></li>
<li><p>if channelwise: (batch_size, nb_channels, nb_classes, …)</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="exception">
<dt id="pathflowai.losses.ShapeError">
<em class="property">exception </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">ShapeError</code><a class="reference internal" href="_modules/pathflowai/losses.html#ShapeError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.ShapeError" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="pathflowai.losses.SurfaceLoss">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">SurfaceLoss</code><span class="sig-paren">(</span><em class="sig-param">**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#SurfaceLoss"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.SurfaceLoss" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/losses.py</a></p>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">__call__</span></code>(self, probs, dist_maps, _)</p></td>
<td><p>Call self as a function.</p></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.assert_">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">assert_</code><span class="sig-paren">(</span><em class="sig-param">condition</em>, <em class="sig-param">message=''</em>, <em class="sig-param">exception_type=&lt;class 'AssertionError'&gt;</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#assert_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.assert_" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/exceptions.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/exceptions.py</a>
Like assert, but with arbitrary exception types.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.class2one_hot">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">class2one_hot</code><span class="sig-paren">(</span><em class="sig-param">seg:torch.Tensor</em>, <em class="sig-param">C:int</em><span class="sig-paren">)</span> &#x2192; torch.Tensor<a class="reference internal" href="_modules/pathflowai/losses.html#class2one_hot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.class2one_hot" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.eq">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">eq</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em>, <em class="sig-param">b</em><span class="sig-paren">)</span> &#x2192; bool<a class="reference internal" href="_modules/pathflowai/losses.html#eq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.eq" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.flatten_samples">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">flatten_samples</code><span class="sig-paren">(</span><em class="sig-param">input_</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/losses.html#flatten_samples"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.flatten_samples" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/torch_utils.py">https://raw.githubusercontent.com/inferno-pytorch/inferno/0561e8a95cde6bfc5e10a3609841b7b0ca5b03ca/inferno/utils/torch_utils.py</a>
Flattens a tensor or a variable such that the channel axis is first and the sample axis
is second. The shapes are transformed as follows:</p>
<blockquote>
<div><p>(N, C, H, W) –&gt; (C, N * H * W)
(N, C, D, H, W) –&gt; (C, N * D * H * W)
(N, C) –&gt; (C, N)</p>
</div></blockquote>
<p>The input must be atleast 2d.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.one_hot">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">one_hot</code><span class="sig-paren">(</span><em class="sig-param">t:torch.Tensor</em>, <em class="sig-param">axis=1</em><span class="sig-paren">)</span> &#x2192; bool<a class="reference internal" href="_modules/pathflowai/losses.html#one_hot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.one_hot" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.one_hot2dist">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">one_hot2dist</code><span class="sig-paren">(</span><em class="sig-param">seg:numpy.ndarray</em><span class="sig-paren">)</span> &#x2192; numpy.ndarray<a class="reference internal" href="_modules/pathflowai/losses.html#one_hot2dist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.one_hot2dist" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.simplex">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">simplex</code><span class="sig-paren">(</span><em class="sig-param">t:torch.Tensor</em>, <em class="sig-param">axis=1</em><span class="sig-paren">)</span> &#x2192; bool<a class="reference internal" href="_modules/pathflowai/losses.html#simplex"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.simplex" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.sset">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">sset</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em>, <em class="sig-param">sub:Iterable</em><span class="sig-paren">)</span> &#x2192; bool<a class="reference internal" href="_modules/pathflowai/losses.html#sset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.sset" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.losses.uniq">
<code class="sig-prename descclassname">pathflowai.losses.</code><code class="sig-name descname">uniq</code><span class="sig-paren">(</span><em class="sig-param">a:torch.Tensor</em><span class="sig-paren">)</span> &#x2192; Set<a class="reference internal" href="_modules/pathflowai/losses.html#uniq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.losses.uniq" title="Permalink to this definition"></a></dt>
<dd><p><a class="reference external" href="https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py">https://raw.githubusercontent.com/LIVIAETS/surface-loss/master/utils.py</a></p>
</dd></dl>
</div>
<span class="target" id="module-pathflowai.sampler"></span><div class="section" id="sampler-py">
<h2>sampler.py<a class="headerlink" href="#sampler-py" title="Permalink to this headline"></a></h2>
<p>Balanced sampling based on one of the columns of the patch information.</p>
<dl class="class">
<dt id="pathflowai.sampler.ImbalancedDatasetSampler">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.sampler.</code><code class="sig-name descname">ImbalancedDatasetSampler</code><span class="sig-paren">(</span><em class="sig-param">dataset</em>, <em class="sig-param">indices=None</em>, <em class="sig-param">num_samples=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/sampler.html#ImbalancedDatasetSampler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.sampler.ImbalancedDatasetSampler" title="Permalink to this definition"></a></dt>
<dd><p>Samples elements randomly from a given list of indices for imbalanced dataset
<a class="reference external" href="https://raw.githubusercontent.com/ufoym/imbalanced-dataset-sampler/master/sampler.py">https://raw.githubusercontent.com/ufoym/imbalanced-dataset-sampler/master/sampler.py</a>
Arguments:</p>
<blockquote>
<div><p>indices (list, optional): a list of indices
num_samples (int, optional): number of samples to draw</p>
</div></blockquote>
</dd></dl>
</div>
<span class="target" id="module-pathflowai.schedulers"></span><div class="section" id="schedulers-py">
<h2>schedulers.py<a class="headerlink" href="#schedulers-py" title="Permalink to this headline"></a></h2>
<p>Modulates the learning rate during the training process.</p>
<dl class="class">
<dt id="pathflowai.schedulers.CosineAnnealingWithRestartsLR">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.schedulers.</code><code class="sig-name descname">CosineAnnealingWithRestartsLR</code><span class="sig-paren">(</span><em class="sig-param">optimizer</em>, <em class="sig-param">T_max</em>, <em class="sig-param">eta_min=0</em>, <em class="sig-param">last_epoch=-1</em>, <em class="sig-param">T_mult=1.0</em>, <em class="sig-param">alpha_decay=1.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#CosineAnnealingWithRestartsLR"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.CosineAnnealingWithRestartsLR" title="Permalink to this definition"></a></dt>
<dd><p>Set the learning rate of each parameter group using a cosine annealing
schedule, where <span class="math notranslate nohighlight">\(\eta_{max}\)</span> is set to the initial lr and
<span class="math notranslate nohighlight">\(T_{cur}\)</span> is the number of epochs since the last restart in SGDR:</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[\eta_t = \eta_{min} + \frac{1}{2}(\eta_{max} - \eta_{min})(1 +
\cos(\frac{T_{cur}}{T_{max}}\pi))\]</div>
<p>When last_epoch=-1, sets initial lr as lr.
It has been proposed in</p>
</div></blockquote>
<p><a class="reference external" href="https://arxiv.org/abs/1608.03983">SGDR: Stochastic Gradient Descent with Warm Restarts</a>. This implements
the cosine annealing part of SGDR, the restarts and number of iterations multiplier.</p>
<blockquote>
<div><dl class="simple">
<dt>Args:</dt><dd><p>optimizer (Optimizer): Wrapped optimizer.
T_max (int): Maximum number of iterations.
T_mult (float): Multiply T_max by this number after each restart. Default: 1.
eta_min (float): Minimum learning rate. Default: 0.
last_epoch (int): The index of last epoch. Default: -1.</p>
</dd>
</dl>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Attributes</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>step_n</strong></dt><dd></dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">load_state_dict</span></code>(self, state_dict)</p></td>
<td><p>Loads the schedulers state.</p></td>
</tr>
<tr class="row-even"><td><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">state_dict</span></code>(self)</p></td>
<td><p>Returns the state of the scheduler as a <code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code>.</p></td>
</tr>
</tbody>
</table>
<table class="docutils align-default">
<colgroup>
<col style="width: 52%" />
<col style="width: 48%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><strong>cosine</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>get_lr</strong></p></td>
<td></td>
</tr>
<tr class="row-odd"><td><p><strong>restart</strong></p></td>
<td></td>
</tr>
<tr class="row-even"><td><p><strong>step</strong></p></td>
<td></td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="pathflowai.schedulers.Scheduler">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.schedulers.</code><code class="sig-name descname">Scheduler</code><span class="sig-paren">(</span><em class="sig-param">optimizer=None</em>, <em class="sig-param">opts={'T_max': 10</em>, <em class="sig-param">'T_mult': 2</em>, <em class="sig-param">'eta_min': 5e-08</em>, <em class="sig-param">'lr_scheduler_decay': 0.5</em>, <em class="sig-param">'scheduler': 'null'}</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler" title="Permalink to this definition"></a></dt>
<dd><p>Scheduler class that modulates learning rate of torch optimizers over epochs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>optimizer</strong><span class="classifier">type</span></dt><dd><p>torch.Optimizer object</p>
</dd>
<dt><strong>opts</strong><span class="classifier">type</span></dt><dd><p>Options of setting the learning rate scheduler, see default.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Attributes</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>schedulers</strong><span class="classifier">type</span></dt><dd><p>Different types of schedulers to choose from.</p>
</dd>
<dt><strong>scheduler_step_fn</strong><span class="classifier">type</span></dt><dd><p>How scheduler updates learning rate.</p>
</dd>
<dt><strong>initial_lr</strong><span class="classifier">type</span></dt><dd><p>Initial set learning rate.</p>
</dd>
<dt><strong>scheduler_choice</strong><span class="classifier">type</span></dt><dd><p>What scheduler type was chosen.</p>
</dd>
<dt><strong>scheduler</strong><span class="classifier">type</span></dt><dd><p>Scheduler object chosen that will more directly update optimizer LR.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.schedulers.Scheduler.get_lr" title="pathflowai.schedulers.Scheduler.get_lr"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_lr</span></code></a>(self)</p></td>
<td><p>Return current learning rate.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.schedulers.Scheduler.step" title="pathflowai.schedulers.Scheduler.step"><code class="xref py py-obj docutils literal notranslate"><span class="pre">step</span></code></a>(self)</p></td>
<td><p>Update optimizer learning rate</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.schedulers.Scheduler.get_lr">
<code class="sig-name descname">get_lr</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler.get_lr"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler.get_lr" title="Permalink to this definition"></a></dt>
<dd><p>Return current learning rate.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>float</dt><dd><p>Current learning rate.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.schedulers.Scheduler.step">
<code class="sig-name descname">step</code><span class="sig-paren">(</span><em class="sig-param">self</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/schedulers.html#Scheduler.step"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.schedulers.Scheduler.step" title="Permalink to this definition"></a></dt>
<dd><p>Update optimizer learning rate</p>
</dd></dl>
</dd></dl>
</div>
<span class="target" id="module-pathflowai.visualize"></span><div class="section" id="visualize-py">
<h2>visualize.py<a class="headerlink" href="#visualize-py" title="Permalink to this headline"></a></h2>
<p>Plots SHAP outputs, UMAP embeddings, and overlays predictions on top of WSI.</p>
<dl class="class">
<dt id="pathflowai.visualize.PlotlyPlot">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">PlotlyPlot</code><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot" title="Permalink to this definition"></a></dt>
<dd><p>Creates plotly html plots.</p>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PlotlyPlot.add_plot" title="pathflowai.visualize.PlotlyPlot.add_plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_plot</span></code></a>(self, t_data_df[, G, color_col, …])</p></td>
<td><p>Adds plotting data to be plotted.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PlotlyPlot.plot" title="pathflowai.visualize.PlotlyPlot.plot"><code class="xref py py-obj docutils literal notranslate"><span class="pre">plot</span></code></a>(self, output_fname[, axes_off])</p></td>
<td><p>Plot embedding of patches to html file.</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.visualize.PlotlyPlot.add_plot">
<code class="sig-name descname">add_plot</code><span class="sig-paren">(</span><em class="sig-param">self, t_data_df, G=None, color_col='color', name_col='name', xyz_cols=['x', 'y', 'z'], size=2, opacity=1.0, custom_colors=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot.add_plot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot.add_plot" title="Permalink to this definition"></a></dt>
<dd><p>Adds plotting data to be plotted.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>t_data_df:dataframe</strong></dt><dd><p>3-D transformed dataframe.</p>
</dd>
<dt><strong>G:nx.Graph</strong></dt><dd><p>Networkx graph.</p>
</dd>
<dt><strong>color_col:str</strong></dt><dd><p>Column to use to color points.</p>
</dd>
<dt><strong>name_col:str</strong></dt><dd><p>Column to use to name points.</p>
</dd>
<dt><strong>xyz_cols:list</strong></dt><dd><p>3 columns that denote x,y,z coords.</p>
</dd>
<dt><strong>size:int</strong></dt><dd><p>Marker size.</p>
</dd>
<dt><strong>opacity:float</strong></dt><dd><p>Marker opacity.</p>
</dd>
<dt><strong>custom_colors:list</strong></dt><dd><p>Custom colors to supply.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.visualize.PlotlyPlot.plot">
<code class="sig-name descname">plot</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">output_fname</em>, <em class="sig-param">axes_off=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PlotlyPlot.plot"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PlotlyPlot.plot" title="Permalink to this definition"></a></dt>
<dd><p>Plot embedding of patches to html file.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>output_fname:str</strong></dt><dd><p>Output html file.</p>
</dd>
<dt><strong>axes_off:bool</strong></dt><dd><p>Remove axes.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="pathflowai.visualize.PredictionPlotter">
<em class="property">class </em><code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">PredictionPlotter</code><span class="sig-paren">(</span><em class="sig-param">dask_arr_dict</em>, <em class="sig-param">patch_info_db</em>, <em class="sig-param">compression_factor=3</em>, <em class="sig-param">alpha=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">no_db=False</em>, <em class="sig-param">plot_annotation=False</em>, <em class="sig-param">segmentation=False</em>, <em class="sig-param">n_segmentation_classes=4</em>, <em class="sig-param">input_dir=''</em>, <em class="sig-param">annotation_col='annotation'</em>, <em class="sig-param">scaling_factor=1.0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter" title="Permalink to this definition"></a></dt>
<dd><p>Plots predictions over entire image.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>dask_arr_dict:dict</strong></dt><dd><p>Stores all dask arrays corresponding to all of the images.</p>
</dd>
<dt><strong>patch_info_db:str</strong></dt><dd><p>Patch level information, eg. prediction.</p>
</dd>
<dt><strong>compression_factor:float</strong></dt><dd><p>How much to compress image by.</p>
</dd>
<dt><strong>alpha:float</strong></dt><dd><p>Low value assigns higher weight to prediction over original image.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
<dt><strong>no_db:bool</strong></dt><dd><p>Don’t use patch information.</p>
</dd>
<dt><strong>plot_annotation:bool</strong></dt><dd><p>Plot annotations from patch information.</p>
</dd>
<dt><strong>segmentation:bool</strong></dt><dd><p>Plot segmentation mask.</p>
</dd>
<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Number segmentation classes.</p>
</dd>
<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p>
</dd>
<dt><strong>annotation_col:str</strong></dt><dd><p>Annotation column to plot.</p>
</dd>
<dt><strong>scaling_factor:float</strong></dt><dd><p>Multiplies the prediction scores to make them appear darker on the images when predicting.</p>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.add_custom_segmentation" title="pathflowai.visualize.PredictionPlotter.add_custom_segmentation"><code class="xref py py-obj docutils literal notranslate"><span class="pre">add_custom_segmentation</span></code></a>(self, basename, npy)</p></td>
<td><p>Replace segmentation mask with new custom segmentation.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.generate_image" title="pathflowai.visualize.PredictionPlotter.generate_image"><code class="xref py py-obj docutils literal notranslate"><span class="pre">generate_image</span></code></a>(self, ID)</p></td>
<td><p>Generate the image array for the whole slide image with predictions overlaid.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.output_image" title="pathflowai.visualize.PredictionPlotter.output_image"><code class="xref py py-obj docutils literal notranslate"><span class="pre">output_image</span></code></a>(self, img, filename[, tif])</p></td>
<td><p>Output calculated image to file.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#pathflowai.visualize.PredictionPlotter.return_patch" title="pathflowai.visualize.PredictionPlotter.return_patch"><code class="xref py py-obj docutils literal notranslate"><span class="pre">return_patch</span></code></a>(self, ID, x, y, patch_size)</p></td>
<td><p>Return one single patch instead of entire image.</p></td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="pathflowai.visualize.PredictionPlotter.add_custom_segmentation">
<code class="sig-name descname">add_custom_segmentation</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">basename</em>, <em class="sig-param">npy</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.add_custom_segmentation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.add_custom_segmentation" title="Permalink to this definition"></a></dt>
<dd><p>Replace segmentation mask with new custom segmentation.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>basename:str</strong></dt><dd><p>Patient ID</p>
</dd>
<dt><strong>npy:str</strong></dt><dd><p>Numpy mask.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.visualize.PredictionPlotter.generate_image">
<code class="sig-name descname">generate_image</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.generate_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.generate_image" title="Permalink to this definition"></a></dt>
<dd><p>Generate the image array for the whole slide image with predictions overlaid.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>ID:str</strong></dt><dd><p>patient ID.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Resulting overlaid whole slide image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.visualize.PredictionPlotter.output_image">
<code class="sig-name descname">output_image</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">img</em>, <em class="sig-param">filename</em>, <em class="sig-param">tif=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.output_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.output_image" title="Permalink to this definition"></a></dt>
<dd><p>Output calculated image to file.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>img:array</strong></dt><dd><p>Image.</p>
</dd>
<dt><strong>filename:str</strong></dt><dd><p>Output file name.</p>
</dd>
<dt><strong>tif:bool</strong></dt><dd><p>Store in TIF format?</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="method">
<dt id="pathflowai.visualize.PredictionPlotter.return_patch">
<code class="sig-name descname">return_patch</code><span class="sig-paren">(</span><em class="sig-param">self</em>, <em class="sig-param">ID</em>, <em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#PredictionPlotter.return_patch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.PredictionPlotter.return_patch" title="Permalink to this definition"></a></dt>
<dd><p>Return one single patch instead of entire image.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>ID:str</strong></dt><dd><p>Patient ID</p>
</dd>
<dt><strong>x:int</strong></dt><dd><p>X coordinate.</p>
</dd>
<dt><strong>y:int</strong></dt><dd><p>Y coordinate.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.annotation2rgb">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">annotation2rgb</code><span class="sig-paren">(</span><em class="sig-param">i</em>, <em class="sig-param">palette</em>, <em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#annotation2rgb"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.annotation2rgb" title="Permalink to this definition"></a></dt>
<dd><p>Go from annotation of patch to color.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>i:int</strong></dt><dd><p>Annotation index.</p>
</dd>
<dt><strong>palette:palette</strong></dt><dd><p>Index to color mapping.</p>
</dd>
<dt><strong>arr:array</strong></dt><dd><p>Image array.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Resulting image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.blend">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">blend</code><span class="sig-paren">(</span><em class="sig-param">arr1</em>, <em class="sig-param">arr2</em>, <em class="sig-param">alpha=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#blend"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.blend" title="Permalink to this definition"></a></dt>
<dd><p>Blend 2 arrays together, mixing with alpha.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>arr1:array</strong></dt><dd><p>Image 1.</p>
</dd>
<dt><strong>arr2:array</strong></dt><dd><p>Image 2.</p>
</dd>
<dt><strong>alpha:float</strong></dt><dd><p>Higher alpha makes image more like image 1.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Resulting image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.plot_image_">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_image_</code><span class="sig-paren">(</span><em class="sig-param">image_file</em>, <em class="sig-param">compression_factor=2.0</em>, <em class="sig-param">test_image_name='test.png'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_image_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_image_" title="Permalink to this definition"></a></dt>
<dd><p>Plots entire SVS/other image.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>image_file:str</strong></dt><dd><p>Image file.</p>
</dd>
<dt><strong>compression_factor:float</strong></dt><dd><p>Amount to shrink each dimension of image.</p>
</dd>
<dt><strong>test_image_name:str</strong></dt><dd><p>Output image file.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.plot_shap">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_shap</code><span class="sig-paren">(</span><em class="sig-param">model</em>, <em class="sig-param">dataset_opts</em>, <em class="sig-param">transform_opts</em>, <em class="sig-param">batch_size</em>, <em class="sig-param">outputfilename</em>, <em class="sig-param">n_outputs=1</em>, <em class="sig-param">method='deep'</em>, <em class="sig-param">local_smoothing=0.0</em>, <em class="sig-param">n_samples=20</em>, <em class="sig-param">pred_out=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_shap"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_shap" title="Permalink to this definition"></a></dt>
<dd><p>Plot shapley attributions overlaid on images for classification tasks.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>model:nn.Module</strong></dt><dd><p>Pytorch model.</p>
</dd>
<dt><strong>dataset_opts:dict</strong></dt><dd><p>Options used to configure dataset</p>
</dd>
<dt><strong>transform_opts:dict</strong></dt><dd><p>Options used to configure transformers.</p>
</dd>
<dt><strong>batch_size:int</strong></dt><dd><p>Batch size for training.</p>
</dd>
<dt><strong>outputfilename:str</strong></dt><dd><p>Output filename.</p>
</dd>
<dt><strong>n_outputs:int</strong></dt><dd><p>Number of top outputs.</p>
</dd>
<dt><strong>method:str</strong></dt><dd><p>Gradient or deep explainer.</p>
</dd>
<dt><strong>local_smoothing:float</strong></dt><dd><p>How much to smooth shapley map.</p>
</dd>
<dt><strong>n_samples:int</strong></dt><dd><p>Number shapley samples to draw.</p>
</dd>
<dt><strong>pred_out:bool</strong></dt><dd><p>Label images with binary prediction score?</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.plot_umap_images">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">plot_umap_images</code><span class="sig-paren">(</span><em class="sig-param">dask_arr_dict</em>, <em class="sig-param">embeddings_file</em>, <em class="sig-param">ID=None</em>, <em class="sig-param">cval=1.0</em>, <em class="sig-param">image_res=300.0</em>, <em class="sig-param">outputfname='output_embedding.png'</em>, <em class="sig-param">mpl_scatter=True</em>, <em class="sig-param">remove_background_annotation=''</em>, <em class="sig-param">max_background_area=0.01</em>, <em class="sig-param">zoom=0.05</em>, <em class="sig-param">n_neighbors=10</em>, <em class="sig-param">sort_col=''</em>, <em class="sig-param">sort_mode='asc'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#plot_umap_images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.plot_umap_images" title="Permalink to this definition"></a></dt>
<dd><p>Make UMAP embedding plot, overlaid with images.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>dask_arr_dict:dict</strong></dt><dd><p>Stored dask arrays for each WSI.</p>
</dd>
<dt><strong>embeddings_file:str</strong></dt><dd><p>Embeddings pickle file stored from running using after trainign the model.</p>
</dd>
<dt><strong>ID:str</strong></dt><dd><p>Patient ID.</p>
</dd>
<dt><strong>cval:float</strong></dt><dd><p>Deprecated</p>
</dd>
<dt><strong>image_res:float</strong></dt><dd><p>Image resolution.</p>
</dd>
<dt><strong>outputfname:str</strong></dt><dd><p>Output image file.</p>
</dd>
<dt><strong>mpl_scatter:bool</strong></dt><dd><p>Recommended: Use matplotlib for scatter plot.</p>
</dd>
<dt><strong>remove_background_annotation:str</strong></dt><dd><p>Remove the background annotations. Enter for annotation to remove.</p>
</dd>
<dt><strong>max_background_area:float</strong></dt><dd><p>Maximum backgrund area in each tile for inclusion.</p>
</dd>
<dt><strong>zoom:float</strong></dt><dd><p>How much to zoom in on each patch, less than 1 is zoom out.</p>
</dd>
<dt><strong>n_neighbors:int</strong></dt><dd><p>Number of neighbors for UMAP embedding.</p>
</dd>
<dt><strong>sort_col:str</strong></dt><dd><p>Patch info column to sort on.</p>
</dd>
<dt><strong>sort_mode:str</strong></dt><dd><p>Sort ascending or descending.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>type</dt><dd><p>Description of returned object.</p>
</dd>
<dt>Inspired by: <a class="reference external" href="https://gist.github.com/lukemetz/be6123c7ee3b366e333a">https://gist.github.com/lukemetz/be6123c7ee3b366e333a</a></dt><dd></dd>
<dt>WIP!! Needs testing.</dt><dd></dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.prob2rbg">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">prob2rbg</code><span class="sig-paren">(</span><em class="sig-param">prob</em>, <em class="sig-param">palette</em>, <em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#prob2rbg"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.prob2rbg" title="Permalink to this definition"></a></dt>
<dd><p>Convert probability score to rgb image.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>prob:float</strong></dt><dd><p>Between 0 and 1 score.</p>
</dd>
<dt><strong>palette:palette</strong></dt><dd><p>Pallet converts between prob and color.</p>
</dd>
<dt><strong>arr:array</strong></dt><dd><p>Original array.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>New image colored by prediction score.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.seg2rgb">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">seg2rgb</code><span class="sig-paren">(</span><em class="sig-param">seg</em>, <em class="sig-param">palette</em>, <em class="sig-param">n_segmentation_classes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#seg2rgb"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.seg2rgb" title="Permalink to this definition"></a></dt>
<dd><p>Color each pixel by segmentation class.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>seg:array</strong></dt><dd><p>Segmentation mask.</p>
</dd>
<dt><strong>palette:palette</strong></dt><dd><p>Color to RGB map.</p>
</dd>
<dt><strong>n_segmentation_classes:int</strong></dt><dd><p>Total number segmentation classes.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Returned segmentation image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.visualize.to_pil">
<code class="sig-prename descclassname">pathflowai.visualize.</code><code class="sig-name descname">to_pil</code><span class="sig-paren">(</span><em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/visualize.html#to_pil"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.visualize.to_pil" title="Permalink to this definition"></a></dt>
<dd><p>Numpy array to pil.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>arr:array</strong></dt><dd><p>Numpy array.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>Image</dt><dd><p>PIL Image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</div>
<span class="target" id="module-pathflowai.utils"></span><div class="section" id="utils-py">
<h2>utils.py<a class="headerlink" href="#utils-py" title="Permalink to this headline"></a></h2>
<p>General utilities that still need to be broken up into preprocessing, machine learning input preparation, and output submodules.</p>
<dl class="function">
<dt id="pathflowai.utils.add_purple_mask">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">add_purple_mask</code><span class="sig-paren">(</span><em class="sig-param">arr</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#add_purple_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.add_purple_mask" title="Permalink to this definition"></a></dt>
<dd><p>Optional add intensity mask to the dask array.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>arr:dask.array</strong></dt><dd><p>Image data.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Image data with intensity added as forth channel.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.adjust_mask">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">adjust_mask</code><span class="sig-paren">(</span><em class="sig-param">mask_file</em>, <em class="sig-param">dask_img_array_file</em>, <em class="sig-param">out_npy</em>, <em class="sig-param">n_neighbors</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#adjust_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.adjust_mask" title="Permalink to this definition"></a></dt>
<dd><p>Fixes segmentation masks to reduce coarse annotations over empty regions.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>mask_file:str</strong></dt><dd><p>NPY segmentation mask.</p>
</dd>
<dt><strong>dask_img_array_file:str</strong></dt><dd><p>Dask image file.</p>
</dd>
<dt><strong>out_npy:str</strong></dt><dd><p>Output numpy file.</p>
</dd>
<dt><strong>n_neighbors:int</strong></dt><dd><p>Number nearest neighbors for dilation and erosion of mask from background to not background.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>str</dt><dd><p>Output numpy file.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.boxes2interior">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">boxes2interior</code><span class="sig-paren">(</span><em class="sig-param">img_size</em>, <em class="sig-param">polygons</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#boxes2interior"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.boxes2interior" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.create_purple_mask">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_purple_mask</code><span class="sig-paren">(</span><em class="sig-param">arr</em>, <em class="sig-param">img_size=None</em>, <em class="sig-param">sparse=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_purple_mask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_purple_mask" title="Permalink to this definition"></a></dt>
<dd><p>Create a gray scale intensity mask. This will be changed soon to support other thresholding QC methods.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>arr:dask.array</strong></dt><dd><p>Dask array containing image information.</p>
</dd>
<dt><strong>img_size:int</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>sparse:bool</strong></dt><dd><p>Deprecated</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dask.array</dt><dd><p>Intensity, grayscale array over image.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.create_sparse_annotation_arrays">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_sparse_annotation_arrays</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">img_size</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_sparse_annotation_arrays"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_sparse_annotation_arrays" title="Permalink to this definition"></a></dt>
<dd><p>Convert annotation xml to shapely objects and store in dictionary.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>xml_file:str</strong></dt><dd><p>XML file containing annotations.</p>
</dd>
<dt><strong>img_size:int</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>Annotations to look for in xml export.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dict</dt><dd><p>Dictionary with annotation-shapely object pairs.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.create_train_val_test">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">create_train_val_test</code><span class="sig-paren">(</span><em class="sig-param">train_val_test_pkl</em>, <em class="sig-param">input_info_db</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#create_train_val_test"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.create_train_val_test" title="Permalink to this definition"></a></dt>
<dd><p>Create dataframe that splits slides into training validation and test.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>train_val_test_pkl:str</strong></dt><dd><p>Pickle for training validation and test slides.</p>
</dd>
<dt><strong>input_info_db:str</strong></dt><dd><p>Patch information SQL database.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size looking to access.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dataframe</dt><dd><p>Train test validation splits.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.df2sql">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">df2sql</code><span class="sig-paren">(</span><em class="sig-param">df</em>, <em class="sig-param">sql_file</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">mode='replace'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#df2sql"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.df2sql" title="Permalink to this definition"></a></dt>
<dd><p>Write dataframe containing patch level information to SQL db.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>df:dataframe</strong></dt><dd><p>Dataframe containing patch information.</p>
</dd>
<dt><strong>sql_file:str</strong></dt><dd><p>SQL database.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Size of patches.</p>
</dd>
<dt><strong>mode:str</strong></dt><dd><p>Replace or append.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.dir2images">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">dir2images</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#dir2images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.dir2images" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.extract_patch_information">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">extract_patch_information</code><span class="sig-paren">(</span><em class="sig-param">basename</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">generate_finetune_segmentation=False</em>, <em class="sig-param">target_class=0</em>, <em class="sig-param">intensity_threshold=100.0</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">adj_mask=''</em>, <em class="sig-param">basic_preprocess=False</em>, <em class="sig-param">tries=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#extract_patch_information"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.extract_patch_information" title="Permalink to this definition"></a></dt>
<dd><p>Final step of preprocessing pipeline. Break up image into patches, include if not background and of a certain intensity, find area of each annotation type in patch, spatial information, image ID and dump data to SQL table.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>basename:str</strong></dt><dd><p>Patient ID.</p>
</dd>
<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>List of annotations to record, these can be different tissue types, must correspond with XML labels.</p>
</dd>
<dt><strong>threshold:float</strong></dt><dd><p>Value between 0 and 1 that indicates the minimum amount of patch that musn’t be background for inclusion.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size of patches; this will become one of the tables.</p>
</dd>
<dt><strong>generate_finetune_segmentation:bool</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>target_class:int</strong></dt><dd><p>Number of segmentation classes desired, from 0th class to target_class-1 will be annotated in SQL.</p>
</dd>
<dt><strong>intensity_threshold:float</strong></dt><dd><p>Value between 0 and 255 that represents minimum intensity to not include as background. Will be modified with new transforms.</p>
</dd>
<dt><strong>target_threshold:float</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>adj_mask:str</strong></dt><dd><p>Adjusted mask if performed binary opening operations in previous preprocessing step.</p>
</dd>
<dt><strong>basic_preprocess:bool</strong></dt><dd><p>Do not store patch level information.</p>
</dd>
<dt><strong>tries:int</strong></dt><dd><p>Number of tries in case there is a Dask timeout, run again.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dataframe</dt><dd><p>Patch information.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.fix_name">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">fix_name</code><span class="sig-paren">(</span><em class="sig-param">basename</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#fix_name"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.fix_name" title="Permalink to this definition"></a></dt>
<dd><p>Fixes illegitimate basename, deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.fix_names">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">fix_names</code><span class="sig-paren">(</span><em class="sig-param">file_dir</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#fix_names"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.fix_names" title="Permalink to this definition"></a></dt>
<dd><p>Fixes basenames, deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.generate_patch_pipeline">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">generate_patch_pipeline</code><span class="sig-paren">(</span><em class="sig-param">basename</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">out_db='patch_info.db'</em>, <em class="sig-param">generate_finetune_segmentation=False</em>, <em class="sig-param">target_class=0</em>, <em class="sig-param">intensity_threshold=100.0</em>, <em class="sig-param">target_threshold=0.0</em>, <em class="sig-param">adj_mask=''</em>, <em class="sig-param">basic_preprocess=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#generate_patch_pipeline"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.generate_patch_pipeline" title="Permalink to this definition"></a></dt>
<dd><p>Short summary.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>basename:str</strong></dt><dd><p>Patient ID.</p>
</dd>
<dt><strong>input_dir:str</strong></dt><dd><p>Input directory.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>List of annotations to record, these can be different tissue types, must correspond with XML labels.</p>
</dd>
<dt><strong>threshold:float</strong></dt><dd><p>Value between 0 and 1 that indicates the minimum amount of patch that musn’t be background for inclusion.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size of patches; this will become one of the tables.</p>
</dd>
<dt><strong>out_db:str</strong></dt><dd><p>Output SQL database.</p>
</dd>
<dt><strong>generate_finetune_segmentation:bool</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>target_class:int</strong></dt><dd><p>Number of segmentation classes desired, from 0th class to target_class-1 will be annotated in SQL.</p>
</dd>
<dt><strong>intensity_threshold:float</strong></dt><dd><p>Value between 0 and 255 that represents minimum intensity to not include as background. Will be modified with new transforms.</p>
</dd>
<dt><strong>target_threshold:float</strong></dt><dd><p>Deprecated.</p>
</dd>
<dt><strong>adj_mask:str</strong></dt><dd><p>Adjusted mask if performed binary opening operations in previous preprocessing step.</p>
</dd>
<dt><strong>basic_preprocess:bool</strong></dt><dd><p>Do not store patch level information.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.grab_interior_points">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">grab_interior_points</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">img_size</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#grab_interior_points"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.grab_interior_points" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.image2coords">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">image2coords</code><span class="sig-paren">(</span><em class="sig-param">image_file</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#image2coords"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.image2coords" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.images2coord_dict">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">images2coord_dict</code><span class="sig-paren">(</span><em class="sig-param">images</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#images2coord_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.images2coord_dict" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.img2npy_">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">img2npy_</code><span class="sig-paren">(</span><em class="sig-param">input_dir</em>, <em class="sig-param">basename</em>, <em class="sig-param">svs_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#img2npy_"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.img2npy_" title="Permalink to this definition"></a></dt>
<dd><p>Convert SVS, TIF, TIFF to NPY.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>input_dir:str</strong></dt><dd><p>Output file dir.</p>
</dd>
<dt><strong>basename:str</strong></dt><dd><p>Basename of output file</p>
</dd>
<dt><strong>svs_file:str</strong></dt><dd><p>SVS, TIF, TIFF file input.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>str</dt><dd><p>NPY output file.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.is_coords_in_box">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_coords_in_box</code><span class="sig-paren">(</span><em class="sig-param">coords</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">boxes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_coords_in_box"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_coords_in_box" title="Permalink to this definition"></a></dt>
<dd><p>Get area of annotation in patch.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>coords:array</strong></dt><dd><p>X,Y coordinates of patch.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
<dt><strong>boxes:list</strong></dt><dd><p>Shapely objects for annotations.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>float</dt><dd><p>Area of annotation type.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.is_image_in_boxes">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_image_in_boxes</code><span class="sig-paren">(</span><em class="sig-param">image_coord_dict</em>, <em class="sig-param">boxes</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_image_in_boxes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_image_in_boxes" title="Permalink to this definition"></a></dt>
<dd><p>Find if image intersects with annotations.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>image_coord_dict:dict</strong></dt><dd><p>Dictionary of patches.</p>
</dd>
<dt><strong>boxes:list</strong></dt><dd><p>Shapely annotation shapes.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dict</dt><dd><p>Dictionary of whether image intersects with any of the annotations.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.is_valid_patch">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">is_valid_patch</code><span class="sig-paren">(</span><em class="sig-param">xs</em>, <em class="sig-param">ys</em>, <em class="sig-param">patch_size</em>, <em class="sig-param">purple_mask</em>, <em class="sig-param">intensity_threshold</em>, <em class="sig-param">threshold=0.5</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#is_valid_patch"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.is_valid_patch" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated, computes whether patch is valid.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.load_dataset">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_dataset</code><span class="sig-paren">(</span><em class="sig-param">in_zarr</em>, <em class="sig-param">in_pkl</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_dataset" title="Permalink to this definition"></a></dt>
<dd><p>Load ZARR image and annotations pickle.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>in_zarr:str</strong></dt><dd><p>Input image.</p>
</dd>
<dt><strong>in_pkl:str</strong></dt><dd><p>Input annotations.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dask.array</dt><dd><p>Image array.</p>
</dd>
<dt>dict</dt><dd><p>Annotations dictionary.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.load_image">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_image</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_image" title="Permalink to this definition"></a></dt>
<dd><p>Load SVS, TIF, TIFF</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>svs_file:type</strong></dt><dd><p>Description of parameter <cite>svs_file</cite>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>type</dt><dd><p>Description of returned object.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.load_process_image">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_process_image</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file=None</em>, <em class="sig-param">npy_mask=None</em>, <em class="sig-param">annotations=[]</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_process_image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_process_image" title="Permalink to this definition"></a></dt>
<dd><p>Load SVS-like image (including NPY), segmentation/classification annotations, generate dask array and dictionary of annotations.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>svs_file:str</strong></dt><dd><p>Image file</p>
</dd>
<dt><strong>xml_file:str</strong></dt><dd><p>Annotation file.</p>
</dd>
<dt><strong>npy_mask:array</strong></dt><dd><p>Numpy segmentation mask.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>List of annotations in xml.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>array</dt><dd><p>Dask array of image.</p>
</dd>
<dt>dict</dt><dd><p>Annotation masks.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.load_sql_df">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">load_sql_df</code><span class="sig-paren">(</span><em class="sig-param">sql_file</em>, <em class="sig-param">patch_size</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#load_sql_df"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.load_sql_df" title="Permalink to this definition"></a></dt>
<dd><p>Load pandas dataframe from SQL, accessing particular patch size within SQL.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>sql_file:str</strong></dt><dd><p>SQL db.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dataframe</dt><dd><p>Patch level information.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt>
<code class="sig-name descname">modify_patch_info(input_info_db='patch_info.db', slide_labels=Empty DataFrame</code></dt>
<dt>
<code class="sig-name descname">Columns: []</code></dt>
<dt>
<code class="sig-name descname">Index: [], pos_annotation_class='', patch_size=224, segmentation=False, other_annotations=[], target_segmentation_class=-1, target_threshold=0.0, classify_annotations=False)</code></dt>
<dd><p>Modify the patch information to get ready for deep learning, incorporate whole slide labels if needed.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>input_info_db:str</strong></dt><dd><p>SQL DB file.</p>
</dd>
<dt><strong>slide_labels:dataframe</strong></dt><dd><p>Dataframe with whole slide labels.</p>
</dd>
<dt><strong>pos_annotation_class:str</strong></dt><dd><p>Tissue/annotation label to label with whole slide image label, if not supplied, any slide’s patches receive the whole slide label.</p>
</dd>
<dt><strong>patch_size:int</strong></dt><dd><p>Patch size.</p>
</dd>
<dt><strong>segmentation:bool</strong></dt><dd><p>Segmentation?</p>
</dd>
<dt><strong>other_annotations:list</strong></dt><dd><p>Other annotations to access from patch information.</p>
</dd>
<dt><strong>target_segmentation_class:int</strong></dt><dd><p>Segmentation class to threshold.</p>
</dd>
<dt><strong>target_threshold:float</strong></dt><dd><p>Include patch if patch has target area greater than this.</p>
</dd>
<dt><strong>classify_annotations:bool</strong></dt><dd><p>Classifying annotations for pretraining, or final model?</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dataframe</dt><dd><p>Modified patch information.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.npy2da">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">npy2da</code><span class="sig-paren">(</span><em class="sig-param">npy_file</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#npy2da"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.npy2da" title="Permalink to this definition"></a></dt>
<dd><p>Numpy to dask array.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>npy_file:str</strong></dt><dd><p>Input npy file.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dask.array</dt><dd><p>Converted numpy array to dask.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.parse_coord_return_boxes">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">parse_coord_return_boxes</code><span class="sig-paren">(</span><em class="sig-param">xml_file</em>, <em class="sig-param">annotation_name=''</em>, <em class="sig-param">return_coords=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#parse_coord_return_boxes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.parse_coord_return_boxes" title="Permalink to this definition"></a></dt>
<dd><p>Get list of shapely objects for each annotation in the XML object.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>xml_file:str</strong></dt><dd><p>Annotation file.</p>
</dd>
<dt><strong>annotation_name:str</strong></dt><dd><p>Name of xml annotation.</p>
</dd>
<dt><strong>return_coords:bool</strong></dt><dd><p>Just return list of coords over shapes.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>list</dt><dd><p>List of shapely objects.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.process_svs">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">process_svs</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">output_dir='./'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#process_svs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.process_svs" title="Permalink to this definition"></a></dt>
<dd><p>Store images into npy format and store annotations into pickle dictionary.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>svs_file:str</strong></dt><dd><p>Image file.</p>
</dd>
<dt><strong>xml_file:str</strong></dt><dd><p>Annotations file.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>List of annotations in image.</p>
</dd>
<dt><strong>output_dir:str</strong></dt><dd><p>Output directory.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.retain_images">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">retain_images</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotation=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#retain_images"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.retain_images" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.return_image_coord">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">return_image_coord</code><span class="sig-paren">(</span><em class="sig-param">nx=0</em>, <em class="sig-param">ny=0</em>, <em class="sig-param">xl=3333</em>, <em class="sig-param">yl=3333</em>, <em class="sig-param">xi=0</em>, <em class="sig-param">yi=0</em>, <em class="sig-param">xc=3</em>, <em class="sig-param">yc=3</em>, <em class="sig-param">dimx=224</em>, <em class="sig-param">dimy=224</em>, <em class="sig-param">output_point=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#return_image_coord"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.return_image_coord" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.return_image_in_boxes_dict">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">return_image_in_boxes_dict</code><span class="sig-paren">(</span><em class="sig-param">image_dir</em>, <em class="sig-param">xml_file</em>, <em class="sig-param">annotation=''</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#return_image_in_boxes_dict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.return_image_in_boxes_dict" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.run_preprocessing_pipeline">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">run_preprocessing_pipeline</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">xml_file=None</em>, <em class="sig-param">npy_mask=None</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">out_zarr='output_zarr.zarr'</em>, <em class="sig-param">out_pkl='output.pkl'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#run_preprocessing_pipeline"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.run_preprocessing_pipeline" title="Permalink to this definition"></a></dt>
<dd><p>Run preprocessing pipeline. Store image into zarr format, segmentations maintain as npy, and xml annotations as pickle.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>svs_file:str</strong></dt><dd><p>Input image file.</p>
</dd>
<dt><strong>xml_file:str</strong></dt><dd><p>Input annotation file.</p>
</dd>
<dt><strong>npy_mask:str</strong></dt><dd><p>NPY segmentation mask.</p>
</dd>
<dt><strong>annotations:list</strong></dt><dd><p>List of annotations.</p>
</dd>
<dt><strong>out_zarr:str</strong></dt><dd><p>Output zarr for image.</p>
</dd>
<dt><strong>out_pkl:str</strong></dt><dd><p>Output pickle for annotations.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.save_all_patch_info">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">save_all_patch_info</code><span class="sig-paren">(</span><em class="sig-param">basenames</em>, <em class="sig-param">input_dir='./'</em>, <em class="sig-param">annotations=[]</em>, <em class="sig-param">threshold=0.5</em>, <em class="sig-param">patch_size=224</em>, <em class="sig-param">output_pkl='patch_info.pkl'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#save_all_patch_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.save_all_patch_info" title="Permalink to this definition"></a></dt>
<dd><p>Deprecated.</p>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.save_dataset">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">save_dataset</code><span class="sig-paren">(</span><em class="sig-param">arr</em>, <em class="sig-param">masks</em>, <em class="sig-param">out_zarr</em>, <em class="sig-param">out_pkl</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#save_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.save_dataset" title="Permalink to this definition"></a></dt>
<dd><p>Saves dask array image, dictionary of annotations to zarr and pickle respectively.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>arr:array</strong></dt><dd><p>Image.</p>
</dd>
<dt><strong>masks:dict</strong></dt><dd><p>Dictionary of annotation shapes.</p>
</dd>
<dt><strong>out_zarr:str</strong></dt><dd><p>Zarr output file for image.</p>
</dd>
<dt><strong>out_pkl:str</strong></dt><dd><p>Pickle output file.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.segmentation_predictions2npy">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">segmentation_predictions2npy</code><span class="sig-paren">(</span><em class="sig-param">y_pred</em>, <em class="sig-param">patch_info</em>, <em class="sig-param">segmentation_map</em>, <em class="sig-param">npy_output</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#segmentation_predictions2npy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.segmentation_predictions2npy" title="Permalink to this definition"></a></dt>
<dd><p>Convert segmentation predictions from model to numpy masks.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>y_pred:list</strong></dt><dd><p>List of patch segmentation masks</p>
</dd>
<dt><strong>patch_info:dataframe</strong></dt><dd><p>Patch information from DB.</p>
</dd>
<dt><strong>segmentation_map:array</strong></dt><dd><p>Existing segmentation mask.</p>
</dd>
<dt><strong>npy_output:str</strong></dt><dd><p>Output npy file.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pathflowai.utils.svs2dask_array">
<code class="sig-prename descclassname">pathflowai.utils.</code><code class="sig-name descname">svs2dask_array</code><span class="sig-paren">(</span><em class="sig-param">svs_file</em>, <em class="sig-param">tile_size=1000</em>, <em class="sig-param">overlap=0</em>, <em class="sig-param">remove_last=True</em>, <em class="sig-param">allow_unknown_chunksizes=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pathflowai/utils.html#svs2dask_array"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pathflowai.utils.svs2dask_array" title="Permalink to this definition"></a></dt>
<dd><p>Convert SVS, TIF or TIFF to dask array.</p>
<dl class="field-list">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>svs_file:str</strong></dt><dd><p>Image file.</p>
</dd>
<dt><strong>tile_size:int</strong></dt><dd><p>Size of chunk to be read in.</p>
</dd>
<dt><strong>overlap:int</strong></dt><dd><p>Do not modify, overlap between neighboring tiles.</p>
</dd>
<dt><strong>remove_last:bool</strong></dt><dd><p>Remove last tile because it has a custom size.</p>
</dd>
<dt><strong>allow_unknown_chunksizes: bool</strong></dt><dd><p>Allow different chunk sizes, more flexible, but slowdown.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt>dask.array</dt><dd><p>Dask Array.</p>
</dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">arr</span><span class="o">=</span><span class="n">svs2dask_array</span><span class="p">(</span><span class="n">svs_file</span><span class="p">,</span> <span class="n">tile_size</span><span class="o">=</span><span class="mi">1000</span><span class="p">,</span> <span class="n">overlap</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">remove_last</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">allow_unknown_chunksizes</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go"> ..</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">arr2</span><span class="o">=</span><span class="n">arr</span><span class="o">.</span><span class="n">compute</span><span class="p">()</span>
<span class="go"> ..</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">arr3</span><span class="o">=</span><span class="n">to_pil</span><span class="p">(</span><span class="n">cv2</span><span class="o">.</span><span class="n">resize</span><span class="p">(</span><span class="n">arr2</span><span class="p">,</span> <span class="n">dsize</span><span class="o">=</span><span class="p">(</span><span class="mi">1440</span><span class="p">,</span><span class="mi">700</span><span class="p">),</span> <span class="n">interpolation</span><span class="o">=</span><span class="n">cv2</span><span class="o">.</span><span class="n">INTER_CUBIC</span><span class="p">))</span>
<span class="go"> ..</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">arr3</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">test_image_name</span><span class="p">)</span>
<span class="go"> ..</span>
</pre></div>
</div>
</dd>
</dl>
</dd></dl>
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><p><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></p></li>
<li><p><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></p></li>
<li><p><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></p></li>
</ul>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2019, Joshua Levy
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>