Skip to content
Snippets Groups Projects
Commit 9a9eff58 authored by ojs1g14's avatar ojs1g14
Browse files

Resolved documentation errors up to registration.py

parent 8e935e85
No related branches found
No related tags found
No related merge requests found
...@@ -9,8 +9,16 @@ import numpy as np ...@@ -9,8 +9,16 @@ import numpy as np
from numpy.linalg import solve from numpy.linalg import solve
class feMixin(object): class feMixin(object):
"""
Finite element docstring.
"""
def addFE(self, files): def addFE(self, files):
"""
Numpy style docstring
"""
if len(files) == 1: if len(files) == 1:
data = np.load(files[0], encoding='bytes').item() data = np.load(files[0], encoding='bytes').item()
for k in list(data.keys()): for k in list(data.keys()):
...@@ -26,6 +34,10 @@ class feMixin(object): ...@@ -26,6 +34,10 @@ class feMixin(object):
def getSurf(self): def getSurf(self):
"""
Numpy style docstring
"""
# Find verts with a pressure value for external surface # Find verts with a pressure value for external surface
valInd = self.values[:, 0].astype(int) valInd = self.values[:, 0].astype(int)
# Find faces in array # Find faces in array
...@@ -46,16 +58,22 @@ class feMixin(object): ...@@ -46,16 +58,22 @@ class feMixin(object):
def calcPPI(self): def calcPPI(self):
""" """
Function to calculate the peak pressure indicies Function to calculate the peak pressure indicies
""" """
self.values self.values
def calcGradients(self): def calcGradients(self):
""" """
Function to calculate the gradients in values along z and theta Function to calculate the gradients in values along z and theta
""" """
np.gradient(self.values) np.gradient(self.values)
def addSurrogate(self, dat, theta=True): def addSurrogate(self, dat, theta=True):
"""
Numpy style docstring
"""
if isinstance(dat, str): if isinstance(dat, str):
self.surrogate = np.load(dat).item() self.surrogate = np.load(dat).item()
else: else:
...@@ -65,6 +83,10 @@ class feMixin(object): ...@@ -65,6 +83,10 @@ class feMixin(object):
self.surrogate['sm_theta'] = 10 ** self.surrogate['sm_theta'] self.surrogate['sm_theta'] = 10 ** self.surrogate['sm_theta']
def surrPred(self, x, norm = True): def surrPred(self, x, norm = True):
"""
Numpy style docstring
"""
surr = self.surrogate surr = self.surrogate
sh = surr['sm_U'].shape sh = surr['sm_U'].shape
one = np.ones(sh[0]) one = np.ones(sh[0])
...@@ -85,4 +107,8 @@ class feMixin(object): ...@@ -85,4 +107,8 @@ class feMixin(object):
@staticmethod @staticmethod
def comp(a, b): def comp(a, b):
"""
Numpy style docstring
"""
return solve(np.dot(a.T, a), np.dot(a.T, b)) return solve(np.dot(a.T, a), np.dot(a.T, b))
\ No newline at end of file
...@@ -12,16 +12,33 @@ from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor ...@@ -12,16 +12,33 @@ from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class pressSense(object): class pressSense(object):
"""
Numpy style docstring
"""
def __init__(self): def __init__(self):
self.actors = {} self.actors = {}
self.antS = {} self.antS = {}
def importVert(self, fname, pos='ant'): def importVert(self, fname, pos='ant'):
"""
Numpy style docstring
Parameters
----------
fname : file
self-explanatory
"""
self.antS['vert'] = np.loadtxt(fname, delimiter=',') self.antS['vert'] = np.loadtxt(fname, delimiter=',')
self.antS['vert'][:, 1] += -1.0 self.antS['vert'][:, 1] += -1.0
def importPress(self, fname): def importPress(self, fname):
"""
Numpy style docstring
"""
sF = self.antS['sF'] sF = self.antS['sF']
val = np.loadtxt(fname, delimiter=',').flatten() val = np.loadtxt(fname, delimiter=',').flatten()
self.antS['values'] = np.zeros(len(self.antS['faces'])) self.antS['values'] = np.zeros(len(self.antS['faces']))
...@@ -40,7 +57,8 @@ class pressSense(object): ...@@ -40,7 +57,8 @@ class pressSense(object):
socket socket
sensePos: str sensePos: str
Aspect of socket the sensor was positioned Aspect of socket the sensor was positioned
limbSide: limbSide: str
Either L or R
""" """
vert = mesh['vert'] vert = mesh['vert']
faces = mesh['faces'] faces = mesh['faces']
...@@ -81,6 +99,7 @@ class pressSense(object): ...@@ -81,6 +99,7 @@ class pressSense(object):
Function to compute face array for pressure sensor Function to compute face array for pressure sensor
FIX SO USE QUAD FACES FIX SO USE QUAD FACES
""" """
# define no of rows and columns in sensors # define no of rows and columns in sensors
rows, cols = [15*d, 3*d] rows, cols = [15*d, 3*d]
...@@ -111,6 +130,7 @@ class pressSense(object): ...@@ -111,6 +130,7 @@ class pressSense(object):
Function to compute face array for pressure sensor Function to compute face array for pressure sensor
FIX SO USE QUAD FACES FIX SO USE QUAD FACES
""" """
# define no of rows and columns in sensors # define no of rows and columns in sensors
rows, cols = [15*d, 3*d] rows, cols = [15*d, 3*d]
...@@ -138,6 +158,7 @@ class pressSense(object): ...@@ -138,6 +158,7 @@ class pressSense(object):
def intersectLineMesh(line, v, f): def intersectLineMesh(line, v, f):
""" """
Function to calculate intersection between line and mesh Function to calculate intersection between line and mesh
""" """
def addActor(self, pos ='antS', CMap=None, connect=3): def addActor(self, pos ='antS', CMap=None, connect=3):
...@@ -155,6 +176,7 @@ class pressSense(object): ...@@ -155,6 +176,7 @@ class pressSense(object):
from numpy arrays from numpy arrays
Add functions to add vert, add faces, cmap and make LUT Add functions to add vert, add faces, cmap and make LUT
""" """
def __init__(self, data, CMap=None, bands=None, connect=3): def __init__(self, data, CMap=None, bands=None, connect=3):
...@@ -206,6 +228,10 @@ class pressSense(object): ...@@ -206,6 +228,10 @@ class pressSense(object):
def func1(): def func1():
"""
Docstring for method outside of Classes
"""
path = r'J:\Shared Resources\AmpScan IfLS Team\101 ImpAmp\Upgrade' path = r'J:\Shared Resources\AmpScan IfLS Team\101 ImpAmp\Upgrade'
sockets = ['B_PTB.stl', 'B_TSB.stl', 'B_KBM.stl'] sockets = ['B_PTB.stl', 'B_TSB.stl', 'B_KBM.stl']
pressure = ['161108_Sub02_T001', '161108_Sub02_T002', '161108_Sub02_T006'] pressure = ['161108_Sub02_T001', '161108_Sub02_T002', '161108_Sub02_T006']
......
...@@ -9,51 +9,51 @@ import pandas as pd ...@@ -9,51 +9,51 @@ import pandas as pd
import copy import copy
from scipy import spatial from scipy import spatial
from .core import AmpObject from .core import AmpObject
"""
import os
path = ('J:\\Shared Resources\\AmpScan IfLS Team\\'
'100 PYTHON\\STLReader')
filename = '01_PhantomShell_ICEM_3mm.stl'
filename2 = '01_PhantomShell_ICEM_3mm_write.stl'
baseline = 'B_PTB.stl'
target = 'B_NormalLiner.stl'
os.chdir(path)
ampObj = AmpObject(filename)
regObj = regObject(ampObj)
ampObj.vert.loc[0,:]
regObj.vert.loc[0,:]
ampObj.icp()
regObj.icp()
regObj.registration()
ampObj.registration()
Data = AmpObject(target)
Data.getBaseline(baseline)
Reg = regObject(Data)
Reg.reg_fast()
#"""
#import os
#path = ('J:\\Shared Resources\\AmpScan IfLS Team\\'
# '100 PYTHON\\STLReader')
#filename = '01_PhantomShell_ICEM_3mm.stl'
#filename2 = '01_PhantomShell_ICEM_3mm_write.stl'
#baseline = 'B_PTB.stl'
#target = 'B_NormalLiner.stl'
#os.chdir(path)
#ampObj = AmpObject(filename)
#regObj = regObject(ampObj)
#ampObj.vert.loc[0,:]
#regObj.vert.loc[0,:]
#ampObj.icp()
#regObj.icp()
#regObj.registration()
#ampObj.registration()
Use mesh object as parent class with standard function #Data = AmpObject(target)
and then inherit for all other classes ie socket, residuum, registered #Data.getBaseline(baseline)
Either create from filename, object or fv #Reg = regObject(Data)
#Reg.reg_fast()
Standard functions: #
Rotation #
Translation #Use mesh object as parent class with standard function
Read #and then inherit for all other classes ie socket, residuum, registered
Write #Either create from filename, object or fv
Normals #
Slice analyse #Standard functions:
Child classes: # Rotation
Residuum # Translation
Socket # Read
Registration (Target) # Write
Soft tissue mesh (Bones, Liner) # Normals
FE mesh # Slice analyse
""" #Child classes:
# Residuum
# Socket
# Registration (Target)
# Soft tissue mesh (Bones, Liner)
# FE mesh
#"""
def registration(baseline, target, method='default', steps=5, direct=True): def registration(baseline, target, method='default', steps=5, direct=True):
""" """
Function to register the regObject to the baseline mesh Function to register the regObject to the baseline mesh
...@@ -88,6 +88,10 @@ def registration(baseline, target, method='default', steps=5, direct=True): ...@@ -88,6 +88,10 @@ def registration(baseline, target, method='default', steps=5, direct=True):
regObj = AmpObject(bData, stype='reg') regObj = AmpObject(bData, stype='reg')
def calcError(baseline, regObj, direct=True): def calcError(baseline, regObj, direct=True):
"""
A function within a function will not be documented
"""
if direct is True: if direct is True:
values = np.linalg.norm(regObj.vert - baseline.vert, axis=1) values = np.linalg.norm(regObj.vert - baseline.vert, axis=1)
# Calculate the unit vector normal between corresponding vertices # Calculate the unit vector normal between corresponding vertices
......
...@@ -230,4 +230,16 @@ Solution: ...@@ -230,4 +230,16 @@ Solution:
Napoleon (sphinx support for numpy or google docstrings) only recognises a specific subset of headings of which "Bug" is not one. Allowed headings are outlined here; \url{http://www.sphinx-doc.org/en/stable/ext/napoleon.html}. I changed the offending section to "Note" which rendered fine. Napoleon (sphinx support for numpy or google docstrings) only recognises a specific subset of headings of which "Bug" is not one. Allowed headings are outlined here; \url{http://www.sphinx-doc.org/en/stable/ext/napoleon.html}. I changed the offending section to "Note" which rendered fine.
Traceback 6:
\begin{lstlisting}[language=Python]
WARNING: autodoc: failed to import module 'AmpScan.cython_ext'; the following exception was raised:
No module named 'AmpScan.cython_ext'
\end{lstlisting}
Solution:
This warning occured despite cython\_ext not being included. This occurred due to human error - I removed the 'x' from the '.pyx' when calling the exclude path in apidocs. Adding this solved the issue.
\end{document} \end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment