Skip to content

Commit

Permalink
WIP: Mesh saving and Rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
NicerNewerCar committed Apr 17, 2023
1 parent 8837832 commit ef21f0f
Show file tree
Hide file tree
Showing 79 changed files with 8,356 additions and 182 deletions.
325 changes: 325 additions & 0 deletions CMakeLists.txt.user

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "-DQt5_DIR=\"C:/Qt/5.15.2/msvc2019_64/lib/cmake/Qt5\" -DAutoscoper_RENDERING_BACKEND=\"OpenCL\"",
"buildCommandArgs": "",
"ctestCommandArgs": ""
}
]
}
4 changes: 4 additions & 0 deletions Documentation/_build/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 981409d9891d278a66a3db0b507032d5
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Binary file added Documentation/_build/.doctrees/index.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Documentation/_build/.doctrees/test.doctree
Binary file not shown.
100 changes: 100 additions & 0 deletions Documentation/_build/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Page not found &mdash; Autoscoper documentation</title>
<link rel="stylesheet" href="/en/latest/_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="/en/latest/_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="/en/latest/_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="/en/latest/_static/jquery.js"></script>
<script src="/en/latest/_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="#" id="documentation_options" src="/en/latest/_static/documentation_options.js"></script>
<script src="/en/latest/_static/doctools.js"></script>
<script src="/en/latest/_static/sphinx_highlight.js"></script>
<script src="/en/latest/_static/js/theme.js"></script>
<link rel="index" title="Index" href="/en/latest/genindex.html" />
<link rel="search" title="Search" href="/en/latest/search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="/en/latest/index.html" class="icon icon-home">
Autoscoper
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="/en/latest/search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="/en/latest/socket-control-libraries/index.html">Autoscoper Socket Control Libraries</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="/en/latest/index.html">Autoscoper</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="/en/latest/index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Page not found</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Page not found</h1>

Unfortunately we couldn't find the content you were looking for.

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2023, Brown University and Kitware, Inc.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
25 changes: 25 additions & 0 deletions Documentation/_build/_sources/index.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--- Autoscoper documentation master file, created by
sphinx-quickstart on Mon Apr 10 14:29:37 2023.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive. -->

# Welcome to Autoscoper's documentation!

Autoscoper enables the 3D tracking of structures within multiple imaging modalities including single, bi-, and multi-plane videoradiography, sequential CT volume images, 4DCT image volumes sets, and MRI volume sets.

Autoscoper has been used for tracking the shoulder, spine, wrist, hip, knee, and ankle joints.

```{toctree}
:maxdepth: 2
:caption: Contents:

socket-control-libraries/index.md
```



# Indices and tables

* {ref}`genindex`
* {ref}`modindex`
* {ref}`search`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Autoscoper Socket Control Libraries

```{toctree}
:maxdepth: 2
pyautoscoper.md
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# PyAutoscoper

## Overview

PyAutoscoper is a Python library for controlling Autoscoper via a TCP socket connection. It provides a simple interface for sending commands and receiving responses from Autoscoper.

## Installation

Install the latest version of PyAutoscoper from PyPI using pip:

```bash
$ pip install pyautoscoper
```

## Usage

### Connecting to Autoscoper

The AutoscoperConnection class can be created with two optional arguments:
* `address`: The IP address of the Autoscoper server. Default is `127.0.0.1` (localhost).
* `verbose`: If True, the methods will print out information about the connection. Default is False.

Ensure that Autoscoper is running, the class will attempt to connect to Autoscoper upon instantiation. If the connection is successful, the is_connected method will return True.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Connecting to Autoscoper
:start-after: "[Example 1 - Start]"
:end-before: "[Example 1 - End]"
```

### Loading a trial

This example will load the trial configuration file `trial_config.cfg` and the filter settings file `filter_settings.vie` for both cameras.

The loadTrial method takes one argument:
* `trial_config`: The path to the trial configuration file.

The loadFilter method takes two arguments:
* `camera`: The camera number (0-indexed).
* `f`ilter_file`: The path to the filter settings file.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Loading a trial
:start-after: "[Example 2 - Start]"
:end-before: "[Example 2 - End]"
```

### Loading and Saving Tracking Data

This example will load the tracking data file `tracking_data.tra` and save it as `tracking_data_out.tra`.

NOTE: A trial must be loaded before loading tracking data.

The loadTrackingData method takes at least two arguments:
* `volume`: The volume index (0-indexed).
* `tracking_data`: The path to the tracking data file.
* `is_matrix`: If True, the tracking data will be loaded as a 4 by 4 matrix. If False, the tracking data will be loaded in xyz roll pitch yaw format. Defaults to True.
* `is_rows`: If True, the tracking data will be loaded as rows. If False, the tracking data will be loaded as columns. Defaults to True.
* `is_with_commas`: If True, the tracking data will be loaded with commas. If False, the tracking data will be loaded with spaces. Defaults to True.
* `is_cm`: If True, the tracking data will be loaded in cm. If False, the tracking data will be loaded in mm. Defaults to False.
* `is_rad`: If True, the tracking data will be loaded in radians. If False, the tracking data will be loaded in degrees. Defaults to False.
* `interpolate`: If True, the tracking data will be interpolated with the spline method. If False, the tracking data will not be interpolated (NaN values). Defaults to False.

The saveTrackingData method takes at least two arguments:
* `volume`: The volume index (0-indexed).
* `tracking_data`: The path to the tracking data file.
* `save_as_matrix`: If True, the tracking data will be saved as a 4 by 4 matrix. If False, the tracking data will be saved in xyz roll pitch yaw format. Defaults to True.
* `save_as_rows`: If True, the tracking data will be saved as rows. If False, the tracking data will be saved as columns. Defaults to True.
* `save_with_commas`: If True, the tracking data will be saved with commas. If False, the tracking data will be saved with spaces. Defaults to True.
* `convert_to_cm`: If True, the tracking data will be saved in cm. If False, the tracking data will be saved in mm. Defaults to False.
* `convert_to_rad`: If True, the tracking data will be saved in radians. If False, the tracking data will be saved in degrees. Defaults to False.
* `interpolate`: If True, the tracking data will be interpolated with the spline method. If False, the tracking data will not be interpolated (NaN values). Defaults to False.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Loading and Saving Tracking Data
:start-after: "[Example 3 - Start]"
:end-before: "[Example 3 - End]"
```

### Changing the Current Frame and Pose

This example will change the pose on multiple frames.

NOTE: A trial must be loaded before changing the current frame and pose.

The setPose method takes three arguments:
* `volume`: The volume index (0-indexed).
* `frame`: The frame index (0-indexed).
* `pose`: The pose of the volume in the form of an array of 6 floats. Array order is [x, y, z, roll, pitch, yaw].

The getPose method takes two arguments:
* `volume`: The volume index (0-indexed).
* `frame`: The frame index (0-indexed).

The setFrame method takes one argument:
* `frame`: The frame index (0-indexed).

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Changing the Current Frame and Pose
:start-after: "[Example 4 - Start]"
:end-before: "[Example 4 - End]"
```

### Optimizations

There are two methods for optimizing the tracking data:
* `optimizeFrame`: Optimizes the tracking data for a single frame.
* `trackingDialog`: Automatically optimizes the tracking data for all given frames.

The optimizeFrame method takes ten arguments:
* `volume`: The volume index (0-indexed).
* `frame`: The frame index (0-indexed).
* `repeats`: The number of times to repeat the optimization.
* `max_itr`: The maximum number of iterations to run the optimization.
* `min_lim`: The minimum limit for the PSO movement.
* `max_lim`: The maximum limit for the PSO movement.
* `max_stall_itr`: The maximum number of iterations to stall the optimization.
* `dframe`: The amount of frames to skip backwards for the intial guess.
* `opt_method`: The optimization method to use, 0 for Particle Swarm, 1 for Downhill Simplex.
* `cf_model`: The cost function to use, 0 for NCC (Bone Models), 1 for Sum of Absolute Differences (Implant Models)

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Optimizing a single frame
:start-after: "[Example 5 - Start]"
:end-before: "[Example 5 - End]"
```

The trackingDialog method takes at least three arguments:
* `volume`: The volume index (0-indexed).
* `start_frame`: The starting frame index (0-indexed).
* `end_frame`: The ending frame index (0-indexed).
* `frame_skip`: The number of frames to skip between each optimization. Defaults to 1.
* `repeats`: The number of times to repeat the optimization. Defaults to 1.
* `max_itr`: The maximum number of iterations to run the optimization. Defaults to 1000.
* `min_lim`: The minimum limit for the PSO movement. Defaults to -3.0.
* `max_lim`: The maximum limit for the PSO movement. Defaults to 3.0.
* `max_stall_itr`: The maximum number of iterations to stall the optimization. Defaults to 25.
* `opt_method`: The optimization method to use, 0 for Particle Swarm, 1 for Downhill Simplex. Defaults to 0.
* `cf_model`: The cost function to use, 0 for NCC (Bone Models), 1 for Sum of Absolute Differences (Implant Models). Defaults to 0.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Optimizing multiple frames
:start-after: "[Example 5.1 - Start]"
:end-before: "[Example 5.1 - End]"
```

### Putting it all together

We can put all of the above examples together to create a script that will load a trial, load tracking data, optimize the tracking data, and save the tracking data.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Putting it all together
:start-after: "[Example 6 - Start]"
:end-before: "[Example 6 - End]"
```

### Launching Autoscoper from Python

It may be useful to launch Autoscoper from Python. This can be done by using the subprocess module.

```{literalinclude} ../../scripts/python/examples/pyautoscoper-examples.py
:language: python
:caption: Launching Autoscoper from Python
:start-after: "[Example 7 - Start]"
:end-before: "[Example 7 - End]"
```

## Class Reference

```{eval-rst}
.. automodule:: PyAutoscoper.connect
:members:
:undoc-members:
:show-inheritance:
```

1 change: 1 addition & 0 deletions Documentation/_build/_sources/test.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This is a test of Markdown with Sphinx
Loading

0 comments on commit ef21f0f

Please sign in to comment.