def test_smoothing_volume(self): """Tests that smoothing affects the volume within given acceptable range""" # TODO check this is actually working properly poly1 = analyse.create_slices(self.amp, [0.01, 0.99], 0.005, typ='norm_intervals', axis=2) vol1 = analyse.est_volume(poly1) print(vol1) self.amp2.lp_smooth(20) poly2 = analyse.create_slices(self.amp2, [0.01, 0.99], 0.005, typ='norm_intervals', axis=2) vol2 = analyse.est_volume(poly2) print(vol2) # self.assertAlmostEqual(analyse.est_volume(poly1), analyse.est_volume(poly2), delta=TestSmoothing.DELTA) self.amp3.hc_smooth(n=20) poly3 = analyse.create_slices(self.amp3, [0.01, 0.99], 0.005, typ='norm_intervals', axis=2) vol3 = analyse.est_volume(poly3) print(vol3) # self.assertAlmostEqual(analyse.est_volume(poly1), analyse.est_volume(poly3), delta=TestSmoothing.DELTA) self.assertLess(vol1 - vol3, vol1 - vol2)
def test_smoothing_volume(self): """Tests that smoothing affects the volume within given acceptable range""" # TODO check this is actually working properly poly1 = analyse.create_slices(self.amp, [0.001, 0.999], 0.001, typ='norm_intervals', axis=2) print(analyse.est_volume(poly1)) self.amp.lp_smooth(1) poly2 = analyse.create_slices(self.amp, [0.001, 0.999], 0.001, typ='norm_intervals', axis=2) print(analyse.est_volume(poly2)) self.assertAlmostEqual(analyse.est_volume(poly1), analyse.est_volume(poly2), delta=TestSmoothing.DELTA)
def summary_view(request): """Data table view""" axis = 2 if request.method == "POST": amp = get_session(request).get_obj(request.POST.get("objID")) slWidth = float(request.POST["sliceWidth"]) # Find the brim edges ind = np.where(amp.faceEdges[:, 1] == -99999)[0] # Define max Z from lowest point on brim maxZ = amp.vert[amp.edges[ind, :], 2].min() # Create slices slices = np.arange(amp.vert[:, 2].min() + slWidth, maxZ, slWidth) polys = analyse.create_slices(amp, slices, axis) volume = analyse.est_volume(polys) * 0.001 # Convert to mm^3 -> ml return JsonResponse({"volume": volume})
def test_registration_spheres(self): """Test that registration runs on two spheres correctly by checking volume of resultant registered AmpObject. Note that this is reliant on an accurate analyse module.""" reg = registration(self.amp1, self.amp2).reg poly = analyse.create_slices(reg, [0.001, 0.999], 0.001, typ='norm_intervals', axis=2) # Check the volume is correct # Object is a sphere, so area is (4/3)*math.pi*(R**3) # In this case R = 1.2 self.assertAlmostEqual(analyse.est_volume(poly), (4 / 3) * math.pi * (1.2**3), delta=TestRegistration.DELTA) # Test the diameter is correct diameter = reg.vert[:, 2].max() - reg.vert[:, 2].min() self.assertAlmostEqual(diameter, 1.2 * 2, delta=TestRegistration.DELTA)
def widths_sag_view(request): axis = 2 if request.method == "POST": amp = get_session(request).get_obj(request.POST.get("objID")) slWidth = float(request.POST["sliceWidth"]) # Find the brim edges ind = np.where(amp.faceEdges[:, 1] == -99999)[0] # Define max Z from lowest point on brim maxZ = amp.vert[amp.edges[ind, :], 2].min() # Create slices slices = np.arange(amp.vert[:, 2].min() + slWidth, maxZ, slWidth) polys = analyse.create_slices(amp, slices, axis) cor, sag = analyse.calc_widths(polys) return JsonResponse({ "xData": [i / len(sag) * 100 for i in range(len(sag))], "yData": sag.tolist() })