From 20d2e80aa182afddd6f60f925d7a2b9dcb958a3c Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:23:47 +0000 Subject: [PATCH 1/9] Update 02_0_Build_Your_Own_Systems.rst need to install visoneer before installing package --- doc/02_0_Build_Your_Own_Systems.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/02_0_Build_Your_Own_Systems.rst b/doc/02_0_Build_Your_Own_Systems.rst index b1c8fce..5a59725 100644 --- a/doc/02_0_Build_Your_Own_Systems.rst +++ b/doc/02_0_Build_Your_Own_Systems.rst @@ -35,6 +35,12 @@ You may need to add if you don't have administrative permissions. +You may also need to install `visioneer` + +:: + + pip install versioneer + **Another method to get BARD and all its dependant packages is the following** :: From 082c32e8ac885903dc25994a9105250d73bbdb35 Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 12:37:37 +0000 Subject: [PATCH 2/9] Update 02_1_Calibrate_Your_Camera.rst minor change: -s is source, and in the docs it seems like it's being used for saving -o should be the saving path so have updated it to make sense --- doc/02_1_Calibrate_Your_Camera.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/02_1_Calibrate_Your_Camera.rst b/doc/02_1_Calibrate_Your_Camera.rst index 0d2354b..667c3c0 100644 --- a/doc/02_1_Calibrate_Your_Camera.rst +++ b/doc/02_1_Calibrate_Your_Camera.rst @@ -55,7 +55,7 @@ Use the '-o' option to specify a directory to save to, the For example: :: - python bardVideoCalibration.py -c config/video_calib_chessboard.json -s tests/output -p myresults + python bardVideoCalibration.py -c config/video_calib_chessboard.json -s 0 -o tests/output -p myresults #usage: bardVideoCalibration.py [-h] -c CONFIG [-s SOURCE] [-o OUTPUT] [-p PREFIX] [-ni] [-v] Then, each time the program recalibrates, the results will be saved to the 'tests/output' folder, with the filename prefix 'myresults'. From 3bd3760a0b666f163b3cdd73af4661df4ccbd778 Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:33:23 +0000 Subject: [PATCH 3/9] Update 02_2_Tracking_With_AuRcoTags.rst The config files need updating --- doc/02_2_Tracking_With_AuRcoTags.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/02_2_Tracking_With_AuRcoTags.rst b/doc/02_2_Tracking_With_AuRcoTags.rst index dd30c63..9bea412 100644 --- a/doc/02_2_Tracking_With_AuRcoTags.rst +++ b/doc/02_2_Tracking_With_AuRcoTags.rst @@ -18,7 +18,7 @@ OpenCV. python sksurgerybard.py --config config/example_config.json -When you place the reference marker (data/reference.pdf) in front of the webcam you should +When you place the reference marker found in (data/resources.pdf) in front of the webcam you should see the tag pattern overlaid with spherical markers. Check that the webcam width and height specified in the configuration file are the same as the images you performed calibration on. From 5c9dd2662464a21516be1d2580fb9fcc1ff87f79 Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:49:24 +0000 Subject: [PATCH 4/9] Update 02_3_Make_Your_Own_Pointer.rst again config files will need updating, have edited some parameter names --- doc/02_3_Make_Your_Own_Pointer.rst | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/doc/02_3_Make_Your_Own_Pointer.rst b/doc/02_3_Make_Your_Own_Pointer.rst index c914e4c..d823a33 100644 --- a/doc/02_3_Make_Your_Own_Pointer.rst +++ b/doc/02_3_Make_Your_Own_Pointer.rst @@ -20,9 +20,7 @@ pelvis phantom. :: ls data/PelvisPhantom - CT_Fiduicial_Markers.txt - FullPelvis.vtk - PhantomCroppedJuly08.gipl.gz + >> CT_Fiduicial_Markers.txt FullPelvis.vtk PhantomCroppedJuly08.gipl.gz For now, have a look in the file "CT_Fiduicial_Markers.txt". This is an ordered list of the positions of 4 fiducial markers that we @@ -45,17 +43,25 @@ BARD is tracking the markers, so we know where they are, however we're going to tip of the pointer to locate the fiducial markers. We find the tip of the pointer using a "pivot calibration". The tip of the pointer is held stationary whilst the markers are pivoted around the tip. Pressing the "d" key whilst BARD is running will write -the pointer tracking matrix to the directory pointer_positions/bard_pointer_matrices. Do this around 100 -times whilst pivoting the pointer. Whilst doing this it is important that you do not +the pointer tracking matrix to the directory specified in the config file pointer_markers.json, under the parameter "out path" and then inside the directory bard_pointer_matrices, so for example if the full path is specified to be pointer_positions, the pointer positions will go under the folder pointer_positions/bard_pointer_matrices. +Obtain around 100 pointer positions by pressing the key "d" whilst pivoting the pointer. Whilst doing this, it is important that you do not move either the pointer tip or the tracking system (webcam). When you have a directory of pointer matrices you can run this; :: - python bardPivotCalibration.py --help python bardPivotCalibration.py --input pointer_positions/bard_pointer_matrices -The output of this should be list of 7 numbers. The first three are the x, y and z coordinates of the + +The output of this should be list of 7 numbers, something like this: + +:: + + Pointer Offset = [[-100.19828771 7.16207486 4.48010691]] + Pivot Location = [[-47.31630508 93.11369119 293.46139526]] + Residual Error = 8.382949342574744 + +The first three are the x, y and z coordinates of the pointer tip relative to the tracking markers and should be copied into a file named pointer_tip.txt. The next three numbers are the x,y, and z coordinates of the pointer pivot point relative to the webcam. These can be ignored for now. @@ -67,7 +73,7 @@ less pointer poses. Now edit config/pointer_markers.json to include the the pointer_tag_to_tip transform, within the pointerData entry: :: - "pointerData": { + "pointer": { "pointer_tag_file": "data/pointer.txt", "pointer_tag_to_tip": "data/pointer_tip.txt" }, From 8f71de52ed7e2ceaa457947a24539fa3bc33d95e Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:51:02 +0000 Subject: [PATCH 5/9] Create pointer_markers.json config for pointer was missing so added this file --- config/pointer_markers.json | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 config/pointer_markers.json diff --git a/config/pointer_markers.json b/config/pointer_markers.json new file mode 100644 index 0000000..3280b09 --- /dev/null +++ b/config/pointer_markers.json @@ -0,0 +1,28 @@ +{ + "camera": { + "source": 0, + "window size": [640, 480], + "calibration directory": "data/calibration/matts_mbp_640_x_480" + }, + "tracker": { + "type" : "sksaruco", + "rigid bodies" : [ + { + "name" : "modelreference", + "filename" : "data/reference_for_small_liver.txt", + "aruco dictionary" : "DICT_ARUCO_ORIGINAL" + }, + { + "name" : "pointerref", + "filename" : "data/pointer.txt", + "aruco dictionary" : "DICT_ARUCO_ORIGINAL" + } + ] + }, + + "interaction": { + "keyboard": true + }, + "out path" : "pointer_positions", + +} From 1206d26bc81054e907fcd28e2e8727113b683b7f Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 13:52:01 +0000 Subject: [PATCH 6/9] Update example_config.json in tutorial it says no models should be seen, so I just hid the visibility of the models in this config --- config/example_config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/example_config.json b/config/example_config.json index af5ac16..4c7c0cd 100644 --- a/config/example_config.json +++ b/config/example_config.json @@ -25,7 +25,7 @@ "models": { "models_dir": "data/models", "target_model_vertices": [-1], - "model_visibilities": [1], + "model_visibilities": [0], "model_opacities": [0.5, 1.0, 1.0], "model_representations": ["w", "s", "s"], "reference_to_model": "data/reference_to_model.txt", From ef17d6ee06b2b4e6f80dfc61b1d00c3e76203f64 Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 14:10:34 +0000 Subject: [PATCH 7/9] Update reference_with_model.json config file updated with corrections for tutorial 1 (tracking objects with aruco tags) --- config/reference_with_model.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/reference_with_model.json b/config/reference_with_model.json index b76c081..d239311 100644 --- a/config/reference_with_model.json +++ b/config/reference_with_model.json @@ -2,14 +2,18 @@ "camera": { "source": 0, "window size": [640, 480], - "calibration directory": "data/calibration/matts_mbp_640_x_480" + "calibration directory": "data/calibration/matts_mbp_640_x_480", + "roi": [0, 0, 640, 480] + }, "tracker": { "type" : "sksaruco", + "source" : 0, + "calibration directory": "data/calibration/matts_mbp_640_x_480", "rigid bodies" : [ { "name" : "modelreference", - "filename" : "data/reference_for_small_liver.txt", + "filename" : "data/reference.txt", "aruco dictionary" : "DICT_ARUCO_ORIGINAL" } ] From 155044d9912276ddf8bdd3da929545dfcd8aab4e Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:51:47 +0000 Subject: [PATCH 8/9] Update 02_4_Register_And_Ovelay.rst Added instructions on how to obtain the file world.txt --- doc/02_4_Register_And_Ovelay.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/02_4_Register_And_Ovelay.rst b/doc/02_4_Register_And_Ovelay.rst index 0852bbf..0166153 100644 --- a/doc/02_4_Register_And_Ovelay.rst +++ b/doc/02_4_Register_And_Ovelay.rst @@ -6,12 +6,23 @@ Register and Overlay Model ============================= -Create a plain text-file containing the coordinates of the prostate phantom fiducials, in the same order and format as data/PelvisPhantom/CT_Fiduicial_Markers.txt. These markers have been labeled on the phantom. You must measure the points using the tracked pointer, in the same order. You should end up with a file, of the same format as CT.txt, containing the corresponding world coordinates, lets call it world.txt. +Create a plain text-file containing the coordinates of the prostate phantom fiducials, in the same order and format as data/PelvisPhantom/CT_Fiduicial_Markers.txt. + +You can do this by running + +:: + + python sksurgerybard.py --config config/pointer_markers.json + +These markers have been labeled on the phantom. You must measure the points using the tracked pointer, in the same order. To do this, you can place the pointer tip at each fiducial and press "d" to record the position. + +This should output the files into whatever output file you specified. These points can now be copied and pasted into the world.txt file +You should end up with a file, of the same format as CT_Fiduicial_Markers.txt, containing the corresponding world coordinates, lets call it world.txt. Compute the registration of CT points in CT_Fiduicial_Markers.txt to your world points, run this; :: - python bardProcrustes.py -f world.txt -m data/PelvisPhantom/CT_Fiduicial_Markers.txt + python bardProcrustes.py -f data/PelvisPhantom/world.txt -m data/PelvisPhantom/CT_Fiduicial_Markers.txt So here -f stands for "fixed" points, also called "target" points in the literature, and -m stands for "moving" points, also called "source" points in the literature. This will output a rotation, a translation, and Fiducial Registration Error. From a0c113168390a337b37018353ef9d9dea1320f71 Mon Sep 17 00:00:00 2001 From: enkaoua <56082006+enkaoua@users.noreply.github.com> Date: Wed, 7 Feb 2024 17:54:40 +0000 Subject: [PATCH 9/9] Update pointer_markers.json reference marker was wrong one --- config/pointer_markers.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/config/pointer_markers.json b/config/pointer_markers.json index 3280b09..2d68a26 100644 --- a/config/pointer_markers.json +++ b/config/pointer_markers.json @@ -6,10 +6,13 @@ }, "tracker": { "type" : "sksaruco", + "source" : 0, + "calibration directory": "data/calibration/matts_mbp_640_x_480", + "rigid bodies" : [ { "name" : "modelreference", - "filename" : "data/reference_for_small_liver.txt", + "filename" : "data/reference.txt", "aruco dictionary" : "DICT_ARUCO_ORIGINAL" }, { @@ -24,5 +27,4 @@ "keyboard": true }, "out path" : "pointer_positions", - }