From 1ee3f135c396c6e41f30a857108f9e79eb93ede3 Mon Sep 17 00:00:00 2001 From: Lucrezia <83493021+Lucrezia-Cester@users.noreply.github.com> Date: Wed, 22 Dec 2021 08:50:59 +0000 Subject: [PATCH 1/3] updated lsf fun --- hazenlib/spatial_resolution.py | 51 +++------------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) diff --git a/hazenlib/spatial_resolution.py b/hazenlib/spatial_resolution.py index b8645db8..72d075d4 100644 --- a/hazenlib/spatial_resolution.py +++ b/hazenlib/spatial_resolution.py @@ -22,52 +22,9 @@ import hazenlib - -def maivis_deriv(x, a, h=1, n=1, axis=-1): - """ - Performs differentiation the same way as done with MAIVIS to find the line spread function (LSF). This function has been re-implemented from IDL code written by Ioannis. - - ;differentiate the ESF the same way as done with MAIVIS to find the line spread function (LSF) - max_deriv=FIX(n_elements(ESF)/4) - - lsf=FLTARR(4*max_deriv) - - for lsf_element=0, 4*max_deriv-4 do begin - - aa=ESF(lsf_element)+ESF(lsf_element+1) - bb=ESF(lsf_element+2)+ESF(lsf_element+3) - lsf(lsf_element)=(bb-aa)/2 - - end - - ;pad the last 3 elements of the lsf - for lsf_element=4*max_deriv-3, 4*max_deriv-1 do begin - lsf(lsf_element)=lsf(4*max_deriv-4) - end - - Parameters - ---------- - a : array_like - Input array - n : int, optional - The number of times values are differenced. - axis : int, optional - The axis along which the difference is taken, default is the last axis. - Returns - ------- - diff : ndarray - The `n` order differences. The shape of the output is the same as `a` - except along `axis` where the dimension is smaller by `n`. - See Also - -------- - idl_deriv - numpy.diff - - """ - max_deriv = len(a) // 4 - b = [(a[i + 2] + a[i + 3] - a[i] - a[i + 1]) / 2 for i in range(4 * max_deriv - 3)] - # pad last 3 elements of b - b.extend([b[-1]] * 3) +def deri(a): + # This function calculated the LSF by taking the derivative of the ESF. Reference: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3643984/ + b = np.gradient(a) return b @@ -440,7 +397,7 @@ def calculate_mtf_for_edge(dicom, edge, report_path=False): angle, intercept = get_edge_angle_and_intercept(x_edge, y_edge) x, y = get_edge_profile_coords(angle, intercept, spacing) u, esf = get_esf(edge_arr, y) - lsf = maivis_deriv(u, esf) + lsf = deri(esf) lsf = np.array(lsf) n=lsf.size mtf = abs(np.fft.fft(lsf)) From 6dd2ac30a3aaf3aa8e415da7cfd0eebb0ca13986 Mon Sep 17 00:00:00 2001 From: Lucrezia <83493021+Lucrezia-Cester@users.noreply.github.com> Date: Wed, 22 Dec 2021 09:44:52 +0000 Subject: [PATCH 2/3] updated spat_res tests to work with new lsf fun --- tests/test_spatial_resolution.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/test_spatial_resolution.py b/tests/test_spatial_resolution.py index d75ce493..7e919b93 100644 --- a/tests/test_spatial_resolution.py +++ b/tests/test_spatial_resolution.py @@ -28,8 +28,8 @@ class TestSpatialResolution(unittest.TestCase): x = [0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375, 0.0, 0.48828125, 0.9765625, 1.46484375, 1.953125, 2.44140625, 2.9296875, 3.41796875, 3.90625, 4.39453125, 4.8828125, 5.37109375, 5.859375, 6.34765625, 6.8359375, 7.32421875, 7.8125, 8.30078125, 8.7890625, 9.27734375] u = [-7.9830403532988505, -7.899048277900987, -7.815056202503124, -7.7310641271052605, -7.647072051707397, -7.563079976309535, -7.47908790091167, -7.395095825513808, -7.311103750115945, -7.227111674718081, -7.143119599320218, -7.0591275239223545, -6.975135448524491, -6.891143373126628, -6.8071512977287645, -6.723159222330901, -6.639167146933039, -6.555175071535174, -6.471182996137312, -6.387190920739449, -6.303198845341585, -6.219206769943722, -6.1352146945458585, -6.051222619147995, -5.967230543750132, -5.883238468352269, -5.799246392954405, -5.715254317556543, -5.631262242158678, -5.547270166760816, -5.463278091362953, -5.379286015965089, -5.295293940567226, -5.211301865169363, -5.127309789771499, -5.043317714373636, -4.959325638975773, -4.875333563577909, -4.791341488180047, -4.707349412782182, -4.62335733738432, -4.539365261986457, -4.455373186588593, -4.37138111119073, -4.287389035792867, -4.203396960395003, -4.11940488499714, -4.035412809599277, -3.951420734201413, -3.8674286588035507, -3.7834365834056873, -3.699444508007824, -3.6154524326099606, -3.5314603572120973, -3.447468281814234, -3.3634762064163706, -3.279484131018507, -3.195492055620644, -3.1114999802227805, -3.027507904824918, -2.9435158294270547, -2.8595237540291913, -2.775531678631328, -2.6915396032334646, -2.6075475278356013, -2.523555452437738, -2.4395633770398746, -2.3555713016420112, -2.271579226244148, -2.1875871508462845, -2.103595075448422, -2.0196030000505587, -1.9356109246526954, -1.851618849254832, -1.7676267738569686, -1.6836346984591053, -1.599642623061242, -1.5156505476633786, -1.4316584722655152, -1.3476663968676519, -1.2636743214697894, -1.179682246071926, -1.0956901706740627, -1.0116980952761994, -0.927706019878336, -0.8437139444804727, -0.7597218690826093, -0.675729793684746, -0.5917377182868826, -0.5077456428890192, -0.4237535674911559, -0.3397614920932934, -0.2557694166954301, -0.17177734129756672, -0.08778526589970337, -0.003793190501840016, 0.08019888489602423, 0.1641909602938867, 0.24818303569174915, 0.3321751110896134, 0.41616718648747586, 0.5001592618853401, 0.5841513372832026, 0.6681434126810668, 0.7521354880789293, 0.8361275634767935, 0.920119638874656, 1.0041117142725184, 1.0881037896703827, 1.1720958650682451, 1.2560879404661094, 1.3400800158639719, 1.424072091261836, 1.5080641666596986, 1.5920562420575628, 1.6760483174554253, 1.7600403928532895, 1.844032468251152, 1.9280245436490144, 2.0120166190468787, 2.096008694444741, 2.1800007698426054, 2.263992845240468, 2.347984920638332, 2.4319769960361945, 2.515969071434059, 2.5999611468319213, 2.6839532222297855] esf = [3.0, 7.756621331424564, 20.567644953471717, 15.702934860415121, 10.729420186113131, 15.37866857551899, 13.831646044244446, 13.881889763779487, 20.6479190101237, 13.23359580052492, 9.925759280089995, 13.72553430821147, 5.1598425196850375, 3.6728346456692993, 22.05511811023625, 16.33385826771654, 11.80944881889758, 10.910629921259854, 9.125984251968525, 10.081889763779568, 14.574803149605513, 17.748031496061508, 2.4629921259842305, 6.354330708661438, 8.267716535433175, 15.0, 12.474015748031546, 16.830708661417283, 4.458267716535482, 14.362204724409413, 11.600787401574776, 8.056692913385866, 2.552362204724411, 17.223622047244085, 10.287401574803207, 14.14960629921259, 8.598425196850481, 17.00393700787394, 14.590551181102386, 5.570472440944814, 3.242519685039449, 19.984251968503845, 12.874015748031276, 18.0251968503937, 21.81653543307095, 18.62283464566926, 16.858267716535437, 4.746850393700706, 4.7464566929133865, 6.816929133858163, 11.117322834645638, 10.84055118110241, 13.393700787401558, 7.502362204724395, 20.638582677165378, 5.0, 19.566929133858284, 12.340157480314941, 0.42519685039370203, 19.149606299212355, 16.266141732283486, 11.220866141732316, 14.943307086614134, 15.283464566929366, 15.98425196850041, 43.67401574803155, 23.588976377952743, 1.0645669291338524, 6.962598425196851, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 39.803149606297666, 219.13858267716503, 416.2090551181101, 622.7724409448819, 835.0433070866143, 1044.1653543307077, 1209.1889763779523, 1295.259842519685, 1329.0, 1321.9712598425197, 1302.8866141732283, 1266.2700787401575, 1216.354330708662, 1173.020472440945, 1132.4074803149608, 1119.6850393700788, 1127.2346456692915, 1137.0141732283464, 1160.5669291338584, 1178.1736220472442, 1180.47244094488, 1187.1181102362218, 1168.9590551181102, 1157.653543307087, 1128.6594488188978, 1114.2976377952755, 1115.1255905511812, 1119.1259842519685, 1118.6728346456694, 1110.0929133858267, 1136.6467941507312, 1151.2958380202474, 1138.3805774278214, 1150.973378327709, 1140.025871766029, 1117.7626546681665, 1135.4871152469577, 1129.5941302791696, 1131.1893342877595, 1131.108088761632, 1138.5676449534717, 1141.0] - lsf = [12.756979241231138, -0.9459556191840157, -5.081245526127359, 1.3889797866175924, 0.8027235231959065, 2.6597470770698743, 3.083989501312347, -5.685226846644136, -5.115110611173579, -2.136989126359204, -7.409308211473564, 3.42128796400452, 14.778149606299227, 1.207677165354287, -7.834448818897679, -4.0533464566928705, -1.756102362204671, 2.31003937007835, 6.557480314959465, -2.222834645669672, -11.752755905510675, -2.7944881889755626, 7.225196850393753, 6.425984251968468, 3.0185039370078286, -3.092519685039391, -5.242125984251968, 2.3370078740157108, 0.41850393700787514, -7.676968503936956, 0.059251968503926555, 8.450984251968507, 2.3305118110236513, -2.3814960629921105, 0.5826771653543128, 4.423228346456629, -2.720669291338611, -11.390748031496031, 1.5328740157480478, 12.022637795275433, 3.836220472440841, 3.4917322834647653, 4.770078740157617, -2.1803149606299783, -9.417125984252035, -12.993897637795303, -5.020866141732297, 4.220472440944855, 5.197244094488248, 3.150000000000084, -0.5309055118110457, 1.9533464566929029, 2.371259842519712, -1.7870078740157442, 3.134251968503923, -5.900787401574821, -6.166141732283584, 11.325196850393596, 3.956102362204872, -4.625787401574696, 1.3698818897638496, 2.551771653541664, 14.715748031494229, 17.99763779527726, -17.50236220472268, -29.617913385826796, -8.845472440944873, -4.013582677165352, -3.4812992125984255, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 19.901574803148833, 129.47086614173134, 297.7722440944887, 390.01988188976463, 411.2340551181106, 420.11358267716497, 397.769291338582, 312.62007874015774, 185.4527559055124, 73.2612204724411, 0.2990157480315929, -40.90728346456683, -71.11673228346433, -89.89094488188937, -88.59822834645695, -68.64114173228381, -29.254133858267892, 6.078149606299007, 25.330708661417134, 37.245866141732336, 30.53248031495957, 14.4249999999995, -1.2844488188960668, -20.488976377952326, -34.88208661417366, -41.82775590551205, -28.44488188976402, -4.352755905511799, 4.187795275590588, -2.742913385826796, 4.470444319460057, 29.588442069741404, 21.468353955755447, 0.7056617922759187, 0.6614173228344953, -15.782714660667352, -18.874740089306783, 3.6463595459659928, 3.766847325902404, -1.3919112383679249, 4.446134574087409, 8.635110952040122, 8.635110952040122, 8.635110952040122, 8.635110952040122] - mtf = [2280.986578382247, 2273.349556122044, 2358.3371290526616, 2524.675620490152, 2526.773901540074, 2395.970121330148, 2303.2937031907154, 2268.493058466593, 2206.774991658302, 2148.526498512961, 1982.5872955518219, 1389.7403777062864, 803.5648103695357, 572.0433075882893, 633.1075287271233, 477.5839804146547, 461.83206781306245, 340.77112944249274, 166.6328687459061, 207.5683917031538, 153.9794223389846, 160.43298931265903, 222.62315984254982, 157.91050516066727, 161.71154978968423, 195.5350299678824, 253.2908981803807, 241.96808999045473, 237.06672230093005, 164.81914128689965, 181.65509269069943, 126.30990534859613, 121.53259581614614, 203.6850571645522, 46.47133816620777, 115.37416865407872, 142.26535195997397, 51.56223826653803, 51.61132067397406, 49.851400638570766, 155.36639592254934, 43.411188185504415, 70.7826426189057, 81.88185792203933, 56.483105793764885, 90.0553536170443, 22.018531666012382, 84.25551453627588, 8.573798688137723, 29.906052999970143, 15.045245353216382, 26.199845808955274, 18.746071525474147, 18.140207247012146, 12.127000641485916, 8.928902436282074, 8.075911198291083, 8.753309474846246, 0.7122468322667382, 7.934394967787194, 4.070086738688874, 5.855775567753348, 5.8952438559446465, 5.125252750522969, 5.09466714387986, 5.125252750522855, 5.895243855944457, 5.8557755677538035, 4.070086738689031, 7.934394967787109, 0.7122468322668986, 8.753309474846292, 8.075911198291125, 8.928902436282076, 12.127000641485854, 18.14020724701192, 18.746071525474093, 26.199845808955242, 15.045245353216501, 29.906052999970015, 8.573798688137764, 84.25551453627571, 22.018531666012553, 90.05535361704435, 56.48310579376483, 81.88185792203953, 70.78264261890563, 43.411188185504365, 155.3663959225494, 49.85140063857053, 51.61132067397409, 51.56223826653788, 142.2653519599741, 115.37416865407901, 46.47133816620742, 203.68505716455218, 121.53259581614614, 126.30990534859616, 181.65509269069943, 164.81914128689934, 237.06672230093002, 241.96808999045467, 253.29089818038076, 195.53502996788248, 161.71154978968428, 157.91050516066716, 222.62315984254997, 160.43298931265872, 153.9794223389845, 207.5683917031536, 166.6328687459064, 340.77112944249257, 461.8320678130625, 477.5839804146546, 633.1075287271235, 572.0433075882894, 803.5648103695357, 1389.7403777062864, 1982.5872955518219, 2148.526498512961, 2206.774991658302, 2268.4930584665926, 2303.293703190716, 2395.9701213301482, 2526.7739015400743, 2524.675620490152, 2358.337129052662, 2273.349556122044] + lsf = [4.757, 8.784, 3.973, -4.919, -0.162, 1.551, -0.748, 3.408, -0.324, -5.361, 0.246, -2.383, -5.026, 8.448, 6.331, -5.123, -2.712, -1.342, -0.414, 2.724, 3.833, -6.056, -5.697, 2.902, 4.323, 2.103, 0.915, -4.008, -1.234, 3.571, -3.153, -4.524, 4.583, 3.868, -1.537, -0.844, 1.427, 2.996, -5.717, -5.674, 7.207, 4.816, -0.98, 4.471, 0.299, -2.479, -6.938, -6.056, 1.035, 3.185, 2.012, 1.138, -1.669, 3.622, -1.251, -0.536, 3.67, -9.571, 3.405, 7.92, -3.964, -0.661, 2.031, 0.52, 14.195, 3.802, -21.305, -8.313, -0.532, -3.481, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 19.902, 109.569, 188.203, 201.817, 209.417, 210.696, 187.073, 125.547, 59.906, 13.356, -13.057, -27.851, -43.266, -46.625, -41.973, -26.668, -2.586, 8.665, 16.666, 20.58, 9.953, 4.472, -5.757, -14.732, -20.15, -21.678, -6.767, 2.414, 1.774, -4.517, 8.987, 20.601, 0.867, -0.161, 0.823, -16.605, -2.269, 5.916, -2.149, 0.757, 3.689, 4.946, 2.432] + mtf = [1141.594, 1136.4924428613838, 1179.979352441388, 1266.9373022925492, 1269.1512490975674, 1206.0892867861755, 1165.4815695865339, 1151.3676578296447, 1123.503822245613, 1101.931029737585, 1023.136453018728, 719.4303261024895, 419.196561473857, 303.2702212488808, 334.1971549533646, 255.9167430126146, 252.1408943418832, 184.01891470832695, 91.0687639338029, 118.9864985497962, 86.89114120992375, 94.77483845707731, 132.3085602422052, 91.5343978780574, 100.66368648716988, 117.62920780023744, 154.18205644015796, 154.39484776702884, 155.67478027041167, 105.96270597342654, 124.07229161672967, 90.37454926389259, 84.78681277179842, 147.03291212064235, 35.146081313863405, 83.46071214744545, 113.10630249528431, 46.42621876754548, 47.03825037645255, 48.50368248667547, 145.53402145319086, 36.95855833657911, 73.45043549400162, 77.11895999279793, 56.21923464501214, 93.53050178488499, 31.989087248904745, 96.56689803081329, 14.454553900943878, 39.44818695681396, 15.11006169862066, 48.22936726434023, 42.00159812444878, 31.610996990560157, 17.88561904509028, 19.349782814410478, 7.0351163439708015, 12.108715431778306, 19.925230064092695, 18.027988833913653, 5.670306194789955, 7.482701219712112, 9.0815252442289, 1.9862265244667747, 1.1620000000001482, 1.9862265244667474, 9.081525244228798, 7.482701219712181, 5.670306194789841, 18.027988833913625, 19.92523006409281, 12.108715431778288, 7.0351163439708015, 19.349782814410446, 17.88561904509034, 31.61099699056014, 42.00159812444882, 48.22936726434018, 15.11006169862059, 39.44818695681402, 14.454553900943878, 96.56689803081335, 31.989087248904735, 93.53050178488493, 56.21923464501217, 77.11895999279797, 73.45043549400162, 36.95855833657904, 145.53402145319086, 48.50368248667542, 47.03825037645251, 46.42621876754542, 113.1063024952843, 83.46071214744549, 35.146081313863526, 147.03291212064244, 84.78681277179842, 90.37454926389255, 124.07229161672964, 105.96270597342658, 155.6747802704117, 154.3948477670289, 154.182056440158, 117.6292078002374, 100.66368648716988, 91.53439787805746, 132.30856024220526, 94.7748384570773, 86.89114120992375, 118.98649854979622, 91.06876393380291, 184.018914708327, 252.1408943418832, 255.91674301261452, 334.1971549533646, 303.2702212488808, 419.1965614738571, 719.4303261024895, 1023.1364530187282, 1101.9310297375853, 1123.503822245613, 1151.3676578296447, 1165.4815695865339, 1206.0892867861755, 1269.1512490975672, 1266.937302292549, 1179.979352441388, 1136.4924428613838] VOID_MEAN = 12.3975 SIGNAL_MEAN = 1643.535 EDGE_MEAN = 511.6325 @@ -127,8 +127,10 @@ def test_get_edge_profile_coords(self): def test_get_esf(self): assert self.u, self.esf == hazen_spatial_resolution.get_esf(self.rotated_edge_roi, self.y) - def test_maivis_deriv(self): - assert self.lsf == hazen_spatial_resolution.maivis_deriv(self.u, self.esf) + def test_deri(self): + a = [round(num, 3) for num in self.lsf] + b = [round(num, 3) for num in hazen_spatial_resolution.deri(self.esf)] + assert a == b def test_mtf(self): assert self.mtf[0] == abs(np.fft.fft(self.lsf))[0] @@ -139,6 +141,7 @@ def test_calculate_mtf(self): assert res['phase_encoding_direction'] == self.MTF_PE + class TestPhilipsResolution(TestSpatialResolution): RESOLUTION_DATA = pathlib.Path(TEST_DATA_DIR / 'resolution') dicom = pydicom.read_file(str(RESOLUTION_DATA / 'philips' / "IM-0004-0002.dcm")) @@ -150,9 +153,10 @@ class TestPhilipsResolution(TestSpatialResolution): EDGE_MEAN = 133.57 TOP_EDGE_MEAN = 205.28 SIGNAL_MEAN = 348.5525 - MTF_FE = 0.4923415061063675 + MTF_FE = 0.6017507296855603 MTF_PE = 0.4923415061063675 bisecting_normal = (281, 245, 319, 239) + print('this is phil',hazen_spatial_resolution.calculate_mtf(dicom)) class TestEastKentResolution(TestSpatialResolution): @@ -170,3 +174,4 @@ class TestEastKentResolution(TestSpatialResolution): MTF_FE = 0.9924200730536655 MTF_PE = 0.9924200730536658 bisecting_normal = (137, 126, 155, 122) + print('this is east',hazen_spatial_resolution.calculate_mtf(dicom)) From 223d760b0010a9fbfccec374d242e06a40f5fc24 Mon Sep 17 00:00:00 2001 From: Lucrezia <83493021+Lucrezia-Cester@users.noreply.github.com> Date: Wed, 22 Dec 2021 10:00:02 +0000 Subject: [PATCH 3/3] removed superflous print statements --- tests/test_spatial_resolution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_spatial_resolution.py b/tests/test_spatial_resolution.py index 7e919b93..2426cd3a 100644 --- a/tests/test_spatial_resolution.py +++ b/tests/test_spatial_resolution.py @@ -156,7 +156,7 @@ class TestPhilipsResolution(TestSpatialResolution): MTF_FE = 0.6017507296855603 MTF_PE = 0.4923415061063675 bisecting_normal = (281, 245, 319, 239) - print('this is phil',hazen_spatial_resolution.calculate_mtf(dicom)) + class TestEastKentResolution(TestSpatialResolution): @@ -174,4 +174,4 @@ class TestEastKentResolution(TestSpatialResolution): MTF_FE = 0.9924200730536655 MTF_PE = 0.9924200730536658 bisecting_normal = (137, 126, 155, 122) - print('this is east',hazen_spatial_resolution.calculate_mtf(dicom)) +