Skip to content

Commit

Permalink
Merge branch '29-systematic-error'
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson318 committed Dec 9, 2020
2 parents 38eeb7b + 58f9560 commit 046caa3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
20 changes: 12 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,19 @@ def placefiducial():
and intra-operative images. FLE is added to each
marker location.
"""
jsonstring = json.dumps(request.json)
position = [json.loads(jsonstring)[0],
json.loads(jsonstring)[1], 0.0]
x_pos = request.json.get("x_pos")
y_pos = request.json.get("y_pos")
position = [x_pos, y_pos, 0.0]
if _is_valid_fiducial(position):
moving_fle = json.loads(jsonstring)[2]
fixed_fle = json.loads(jsonstring)[3]

fixed_fle = FLE(independent_fle = fixed_fle)
moving_fle = FLE(independent_fle = moving_fle)
moving_ind_fle = request.json.get("pre_op_ind_fle", [0., 0., 0.])
fixed_ind_fle = request.json.get("intra_op_ind_fle", [0., 0., 0.])
moving_sys_fle = request.json.get("pre_op_sys_fle", [0., 0., 0.])
fixed_sys_fle = request.json.get("intra_op_sys_fle", [0., 0., 0.])

fixed_fle = FLE(independent_fle = fixed_ind_fle,
systematic_fle = fixed_sys_fle)
moving_fle = FLE(independent_fle = moving_ind_fle,
systematic_fle = moving_sys_fle)

fixed_fid = fixed_fle.perturb_fiducial(position)
moving_fid = moving_fle.perturb_fiducial(position)
Expand Down
16 changes: 15 additions & 1 deletion static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ var intraOpFLEStdDev = [];
var preOpFLEEAV = 0;
var intraOpFLEEAV = 0;

//we can have a systematic error too
var preOpSysError = [];
var intraOpSysError = [];

//page elements for convenience
var preOpImage = document.getElementById("pre-operative-image");
var preOpCanvas = document.getElementById("pre-operative-canvas");
Expand Down Expand Up @@ -290,7 +294,13 @@ function placeFiducial(x, y) {
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify([x, y, preOpFLEStdDev, intraOpFLEStdDev])
body: JSON.stringify({
"x_pos": x,
"y_pos": y,
"pre_op_ind_fle": preOpFLEStdDev,
"intra_op_ind_fle": intraOpFLEStdDev,
"pre_op_sys_fle": preOpSysError,
"intra_op_sys_fle": intraOpSysError})
})
.then(resp => {
if (resp.ok)
Expand Down Expand Up @@ -435,6 +445,10 @@ function init_fles() {
intraOpFLEStdDev = data.fixed_fle_sd;
preOpFLEEAV = data.moving_fle_eav;
intraOpFLEEAV = data.fixed_fle_eav;

preOpSysError = [0.0, 0.0, 0.0];
intraOpSysError = [0.0, 0.0, 0.0];

console.log(data);
});
})
Expand Down
34 changes: 34 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

"""Fiducial Registration Educational Demonstration tests"""
from html.parser import HTMLParser
import json
import pytest
import main as sksfmain # pylint: disable=unused-import

Expand Down Expand Up @@ -84,6 +85,39 @@ def testserve_placefiducial(client):
parser.feed(str(fid.data))
assert parser.title_ok

#normal usage
x_pos = 0.0
y_pos = 0.0
pre_op_ind_fle = [0.0, 0.0, 0.0]
intra_op_ind_fle = [2.0, 2.0, 2.0]
postdata = dict(
x_pos=x_pos,
y_pos=y_pos,
pre_op_ind_fle=pre_op_ind_fle,
intra_op_ind_fle=intra_op_ind_fle)
fid = client.post('/placefiducial', data = json.dumps(postdata),
content_type='application/json')
assert json.loads(fid.data.decode()).get("valid_fid")

#we should be able to apply a systematic error
x_pos = 100.0
y_pos = 250.0
pre_op_sys_fle = [0.0, 0.0, 0.0]
intra_op_sys_fle = [2.0, 2.0, -2.0]
postdata = dict(
x_pos=x_pos,
y_pos=y_pos,
pre_op_sys_fle=pre_op_sys_fle,
intra_op_sys_fle=intra_op_sys_fle)
fid = client.post('/placefiducial', data = json.dumps(postdata),
content_type='application/json')

intra_op_fid = json.loads(fid.data.decode()).get("fixed_fid")
pre_op_fid = json.loads(fid.data.decode()).get("moving_fid")
assert intra_op_fid == [102.0, 252.0, -2.0]
assert pre_op_fid == [100.0, 250.0, 0.0]


def testserve_register(client):
"""Serve register"""
#get should not be allowed
Expand Down

0 comments on commit 046caa3

Please sign in to comment.