From 35feb5b30f4e0d97d0fb4f62b3fb38e56cc378d4 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 9 Dec 2024 10:26:51 -0500 Subject: [PATCH] Update groundtruth file for fsd Fix an issue where the fsd feature boundaries could vary because of a failure to check or guard bounds. --- histomicstk/features/compute_fsd_features.py | 6 + .../test_files/Easy1_nuclei_fsd_features.csv | 128 +++++++++--------- 2 files changed, 70 insertions(+), 64 deletions(-) diff --git a/histomicstk/features/compute_fsd_features.py b/histomicstk/features/compute_fsd_features.py index 241c37885..8bae11c5e 100644 --- a/histomicstk/features/compute_fsd_features.py +++ b/histomicstk/features/compute_fsd_features.py @@ -79,6 +79,12 @@ def compute_fsd_features(im_label, K=128, Fs=6, Delta=8, rprops=None): lmask = (im_label[min_row:max_row, min_col:max_col] == rprops[i].label).astype( bool, ) + # trace_object_boundaries requires that that edge rows and columns be + # false as it does no bounds checking + if not min_row or not min_col or max_row + 1 == sizex or max_col + 1 == sizey: + lmask = np.pad(lmask, ( + (1 if not min_row else 0, 1 if max_row + 1 == sizex else 0), + (1 if not min_col else 0, 1 if max_col + 1 == sizey else 0))) # find boundaries Bounds = trace_object_boundaries( lmask, diff --git a/tests/test_files/Easy1_nuclei_fsd_features.csv b/tests/test_files/Easy1_nuclei_fsd_features.csv index 691d65998..669a9eded 100644 --- a/tests/test_files/Easy1_nuclei_fsd_features.csv +++ b/tests/test_files/Easy1_nuclei_fsd_features.csv @@ -1,65 +1,65 @@ Shape.FSD1,Shape.FSD2,Shape.FSD3,Shape.FSD4,Shape.FSD5,Shape.FSD6 -0.4891539,0.0089132,0.1554578,0.0626086,0.0353268,0.0175918 -0.4731095,0.0039935,0.0488767,0.186833,0.0350807,0.0273932 -0.5050896,0.0004512,0.0018146,0.0118151,0.2037321,0.0379514 -0.5102121,0.0019393,0.0046778,0.0046577,0.0242801,0.2081795 -0.39755,0.0018404,0.0029287,0.006944,0.1603693,0.149001 -0.4729901,0.0011265,0.0020835,0.0116126,0.0183088,0.2318534 -0.5006413,0.0006804,0.0025633,0.0062283,0.0246673,0.2182963 -0.2643947,0.0037278,0.003652,0.0049216,0.1621946,0.2413176 -0.007952,0.0081591,0.0129855,0.0112418,0.0331553,0.4387846 -0.0226443,0.0015084,0.0026059,0.019095,0.0429006,0.426914 -0.47018,0.0014646,0.0017531,0.0086295,0.1716736,0.0834763 -0.432167,0.0013262,0.007473,0.0142574,0.010803,0.2531324 -0.4878616,0.0004628,0.0017043,0.0045065,0.1914827,0.0586536 -0.4285359,0.0023265,0.0016754,0.0098432,0.0182523,0.2510071 -0.3472713,0.0013524,0.0047716,0.0182858,0.0209647,0.276434 -0.0148278,0.0034321,0.007015,0.0119974,0.2740427,0.2004765 -0.4048778,0.00363,0.0105148,0.0181641,0.0107922,0.258675 -0.4546006,0.0006598,0.0028268,0.0162514,0.0187592,0.2373292 -0.4617741,0.0008288,0.0011568,0.0148107,0.0164538,0.2398697 -0.4306515,0.0017355,0.0019752,0.0040929,0.1906642,0.1126692 -0.4674034,0.0015912,0.005525,0.0107708,0.0203338,0.2312287 -0.4791433,0.0023522,0.0057084,0.0049647,0.0184099,0.2308383 -0.4652158,0.0020141,0.002435,0.0034387,0.1319902,0.1324935 -0.3218217,0.0086045,0.011854,0.0065713,0.0133767,0.3045369 -0.3959428,0.0032997,0.0043257,0.0111833,0.018435,0.2681391 -0.2878788,0.0047508,0.0105476,0.0112948,0.0101204,0.3265787 -0.4139247,0.0018935,0.004643,0.0078649,0.0266863,0.2544871 -0.0247911,0.003171,0.008533,0.0239081,0.0229295,0.4366282 -0.4752987,0.0014848,0.0059677,0.0111806,0.0163746,0.2338474 -0.4209939,0.002289,0.0026985,0.004228,0.0261459,0.2565087 -0.4669192,0.0005036,0.0062482,0.0093497,0.0182734,0.2353756 -0.4882923,0.0012962,0.003135,0.0042162,0.0423574,0.2136167 -0.4352885,0.002941,0.0051632,0.0095303,0.0182626,0.2507572 -0.0915765,0.0125391,0.0096943,0.0052394,0.0284784,0.4030475 -0.2039972,0.0032848,0.0173971,0.0076988,0.0257408,0.3508704 -0.2433066,0.0013014,0.0057658,0.0126101,0.27722,0.0926016 -0.3506346,0.0012273,0.0017817,0.0065999,0.0602029,0.2863413 -0.1803607,0.0066333,0.0051792,0.0133898,0.0252049,0.3647346 -0.5595506,0.0367644,0.1288367,0.0747094,0.0259951,0.0179504 -0.7335107,0.0793585,0.0102428,0.0038664,0.0483817,0.029203 -0.0241686,0.0007645,0.003804,0.0103647,0.0457497,0.4452028 -0.2262538,0.0020773,0.0036719,0.0079134,0.0348003,0.3467572 -0.3712532,0.0044059,0.0044657,0.0033914,0.0265898,0.2804742 -0.2494843,0.0040788,0.0079798,0.0158063,0.0250578,0.3273136 -0.41761,0.0017886,0.0043279,0.0097834,0.0171488,0.2585323 -0.4274996,0.0013974,0.0029092,0.0064115,0.0219679,0.2512213 -0.0177647,0.0010739,0.0043544,0.0075393,0.0475372,0.439455 -0.187251,0.005581,0.0099088,0.0101043,0.0242434,0.3614574 -0.4103657,0.001397,0.0030351,0.0035369,0.1350225,0.1532778 -0.490808,0.001449,0.0014562,0.1154871,0.179587,0.0444582 -0.4484811,0.0022793,0.0021265,0.0052106,0.1006256,0.222776 -0.3110756,0.0007273,0.0010228,0.0079025,0.0906356,0.3029448 -0.4374615,0.0038975,0.002022,0.0056562,0.1787587,0.0997978 -0.0538767,0.0029603,0.0057754,0.0130169,0.0270065,0.4289987 -0.0328529,0.0051265,0.0064304,0.0190787,0.0290666,0.4215883 -0.3492576,0.0015076,0.0018355,0.0048614,0.1612863,0.2333203 -0.0280372,0.0032415,0.0111103,0.0225056,0.020164,0.4266029 -0.4785612,0.0004739,0.0064963,0.0138992,0.0105294,0.2325627 -0.4331134,0.0020657,0.0043994,0.0069074,0.1012529,0.1750901 -0.1515286,0.0060049,0.0114424,0.0244221,0.0117978,0.3784139 -0.4049987,0.0031469,0.0055203,0.0162411,0.0115667,0.2642772 -0.4419875,0.0028925,0.0027545,0.009992,0.2046656,0.0674934 -0.460466,0.0872843,0.199779,0.0389229,0.0167586,0.0101383 -0.0498073,0.0127367,0.0068588,0.0084425,0.0165128,0.4367178 +0.19212,0.233578,0.031325,0.0092689,0.0257589,0.0073081 +0.1611485,0.2054287,0.036458,0.0074505,0.0181905,0.0076689 +0.0347883,0.0555416,0.0099585,0.008163,0.013438,0.009514 +0.0227593,0.0327536,0.0162952,0.008344,0.0058942,0.0117174 +0.0013337,0.002799,0.002277,0.0060365,0.0133299,0.0193284 +0.0153687,0.0338865,0.0064794,0.0069345,0.005289,0.0156699 +0.0004139,0.0137765,0.0215106,0.0178922,0.016948,0.0489505 +0.0006447,0.0006723,0.0035799,0.0029518,0.0166429,0.0188696 +0.0001984,0.0017779,0.0015981,0.0031474,0.0061188,0.0157743 +0.0001549,0.0118155,0.0271213,0.0180341,0.0252817,0.0341891 +0.0026267,0.0025403,0.0024298,0.0065071,0.0077855,0.0252567 +0.0042538,0.0120409,0.0033784,0.005309,0.0060343,0.0197209 +0.0007268,0.0029968,0.0050995,0.0035786,0.0186921,0.0160072 +0.0005953,0.0009736,0.003187,0.0047685,0.0098879,0.0153984 +8.48e-05,0.0082168,0.0099212,0.0077966,0.0058333,0.0184973 +0.0031446,0.0093073,0.0103319,0.0030517,0.006244,0.0237151 +0.0030341,0.0217211,0.0471065,0.0362332,0.0409785,0.0351039 +0.0004449,0.0015162,0.0079974,0.0058029,0.0046402,0.0140009 +0.0009251,0.0027758,0.0033625,0.0031406,0.0047711,0.0208281 +0.0014133,0.0029477,0.0058788,0.0062772,0.0176922,0.0195926 +0.0003195,0.0041234,0.0069244,0.0042021,0.0043004,0.0111029 +0.0020582,0.0025297,0.0017266,0.0047228,0.0084784,0.0199084 +0.0006677,0.0013232,0.003292,0.00341,0.0106366,0.0178228 +0.0004472,0.0012059,0.0053462,0.0053855,0.0042148,0.0148172 +0.0006846,0.0008283,0.0012636,0.0014553,0.010633,0.0163987 +0.0014384,0.0078406,0.0451055,0.0166957,0.0079479,0.0188386 +0.0006914,0.0072922,0.0098621,0.0055988,0.0047827,0.0273743 +0.0013853,0.0017544,0.0055716,0.0078752,0.0072273,0.0230085 +0.0005795,0.0006316,0.0013845,0.0041602,0.0087967,0.0143212 +0.0016723,0.0094123,0.0133147,0.0130394,0.0101203,0.0217082 +0.0078632,0.008064,0.0018935,0.0046299,0.0053258,0.0228703 +0.0429876,0.0620686,0.0250684,0.0252233,0.0074785,0.0143895 +0.0026252,0.003435,0.002247,0.0056186,0.0086833,0.0181342 +0.00014,0.0098497,0.0274621,0.0373998,0.0054133,0.0143746 +0.0315186,0.0614852,0.0237848,0.01566,0.0074855,0.0233522 +0.0053985,0.0097123,0.009803,0.0072716,0.0140821,0.0225066 +0.0011511,0.0039674,0.0068094,0.0053594,0.0144564,0.0188333 +0.0008695,0.0214853,0.045804,0.0253288,0.0300103,0.0529589 +0.0148227,0.025104,0.0182162,0.0222184,0.0306865,0.0070828 +0.0277091,0.0841111,0.0253058,0.0127922,0.0099101,0.0201563 +0.0030711,0.0310959,0.0167254,0.0051254,0.0515255,0.033492 +0.0019211,0.0047565,0.0046996,0.002505,0.0046779,0.021768 +0.0022403,0.0031664,0.0056087,0.006637,0.0054639,0.0214097 +0.0009221,0.0016725,0.0031891,0.0094666,0.006378,0.0190359 +0.0043585,0.0081732,0.0090936,0.0042295,0.0045499,0.0189779 +0.0006428,0.0030279,0.0040086,0.0055659,0.0069143,0.0215101 +0.0112823,0.0125493,0.0021646,0.0041859,0.0082394,0.0195682 +0.0077483,0.0087672,0.0022881,0.0044167,0.0047747,0.0122951 +0.0010022,0.0012647,0.0027751,0.0046631,0.0090796,0.0230701 +0.0081523,0.0119796,0.009119,0.0138459,0.0334701,0.0040488 +0.011296,0.021168,0.0036659,0.0054582,0.0040628,0.0258875 +0.008236,0.041017,0.0539887,0.0131248,0.0075129,0.0289048 +0.0002641,0.0007729,0.0033572,0.0036533,0.0111958,0.0256982 +0.0104966,0.0348152,0.1153615,0.078486,0.0090907,0.0279833 +0.0005896,0.0013217,0.0032422,0.0043629,0.0058257,0.0255147 +0.0009567,0.0020219,0.0034091,0.0047691,0.0094451,0.0232541 +0.0008867,0.001622,0.0057253,0.003808,0.0057994,0.0194829 +0.0039282,0.0061357,0.002669,0.0023808,0.0050462,0.0186952 +0.0011453,0.0072512,0.0129316,0.0073721,0.0122248,0.0220647 +0.0004415,0.0014719,0.0028931,0.0044158,0.0053188,0.0185059 +0.0017936,0.0068108,0.019181,0.0215371,0.0093771,0.0192356 +0.1018887,0.1439799,0.0194223,0.0081706,0.0066271,0.0107716 +0.2488817,0.2754812,0.0360503,0.015827,0.0143838,0.0039884 +0.0063241,0.0278006,0.0785401,0.0327287,0.0171554,0.0349528