Commit 97801aec authored by Virginie Uhlmann's avatar Virginie Uhlmann
Browse files

Merge branch 'update/repo' into 'master'

Sort repository and add an installation setup

See merge request uhlmann-group/python-spline-fitting-toolbox!1
parents 524e9b71 e21b5e69
Pipeline #139009 failed with stage
in 5 minutes and 35 seconds
[flake8]
ignore = E203, E266, E501, W503, F403, F401
max-line-length = 79
max-complexity = 18
select = B,C,E,F,W,T4,B9
.idea
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
image: continuumio/miniconda3:latest
before_script:
# Setup of the conda virtual environment
- export PIP_CACHE_DIR="/opt/cache/pip"
- conda env create -f environment.yml
- source activate sft
tests :
stage: test
script:
- pip install -e .
- pip install pytest pytest-cov
- pytest --cov=sft/ tests/
- coverage xml
artifacts:
reports:
cobertura: coverage.xml
This diff is collapsed.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import splineToolbox as st\n",
"import matplotlib.pyplot as plt\n",
"import imp\n",
"import tifffile\n",
"from skimage import measure\n",
"import time\n",
"import cv2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<module 'splineToolbox' from '/Users/uhlmann/git/python-spline-fitting-toolbox/splineToolbox.py'>"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"imp.reload(st)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"img=tifffile.imread('data/catMask.tif')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"M=30\n",
"splineCurve=st.SplineCurve(M,st.B3(),True)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"splineCurve.getCoefsFromBinaryMask(img)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQEAAAD8CAYAAAB3lxGOAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYX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
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"samplingRate=1000\n",
"splineContour=splineCurve.sampleParallel(samplingRate)\n",
"\n",
"fig, ax = plt.subplots()\n",
"ax.imshow(img, cmap=plt.cm.gray)\n",
"ax.scatter(splineContour[:,1],splineContour[:,0],s=1)\n",
"#plt.scatter(splineCurve.coefs[:,1],splineCurve.coefs[:,0])\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"t0=0\n",
"tf=M"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"387.52339202920655\n",
"0.16715598106384277\n"
]
}
],
"source": [
"startTime=time.time()\n",
"samples, step = np.linspace(t0,tf,1000,endpoint=False,retstep=True)\n",
"print(sum([((splineCurve.parameterToWorldDerivative(i)[0]**2+splineCurve.parameterToWorldDerivative(i)[1]**2)**(1/2))*step for i in samples]))\n",
"print(str(time.time()-startTime))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"387.5234010126442\n",
"0.0008037090301513672\n"
]
}
],
"source": [
"startTime=time.time()\n",
"print(cv2.arcLength(np.float32(splineContour), True))\n",
"print(str(time.time()-startTime))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"387.52338843966817\n",
"0.17393994331359863\n"
]
}
],
"source": [
"startTime=time.time()\n",
"print(splineCurve.arcLength(t0,tf))\n",
"print(str(time.time()-startTime))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import splineToolbox as st\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"import math"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"numAnchors=8"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"II = np.repeat(np.arange(numAnchors)[:,None],numAnchors,axis = 1)\n",
"JJ = np.repeat(np.arange(numAnchors)[None,:],numAnchors,axis = 0)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[ 0, -1, -2, -3, -4, -5, -6, -7],\n",
" [ 1, 0, -1, -2, -3, -4, -5, -6],\n",
" [ 2, 1, 0, -1, -2, -3, -4, -5],\n",
" [ 3, 2, 1, 0, -1, -2, -3, -4],\n",
" [ 4, 3, 2, 1, 0, -1, -2, -3],\n",
" [ 5, 4, 3, 2, 1, 0, -1, -2],\n",
" [ 6, 5, 4, 3, 2, 1, 0, -1],\n",
" [ 7, 6, 5, 4, 3, 2, 1, 0]])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"II-JJ"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"M=numAnchors\n",
"I=II-JJ"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.])"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi11 = np.zeros(I.shape)\n",
"Phi11[A == 0] = 26.0/(35*M)\n",
"Phi11[A == 1] = 9.0/(70*M)\n",
"Phi11[A == M-1] = 9.0/(70*M)\n",
"Phi11ref=Phi11\n",
"\n",
"Phi11comp=np.array([[st.H3().h31PeriodicAutocorrelation(el,M) for el in row] for row in I])\n",
"\n",
"np.unique(Phi11ref-Phi11comp)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-3.46944695e-18, 0.00000000e+00])"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi11 = np.zeros(I.shape)\n",
"Phi11[A == 0] = 26.0/(35*M)\n",
"Phi11[A == 1] = 9.0/(70*M)\n",
"Phi11[A == M-1] = 9.0/(70*M)\n",
"Phi11 = M/(M-1)*Phi11\n",
"Phi11[0,0] = .5*Phi11[0,0]\n",
"Phi11[-1,-1] = .5*Phi11[-1,-1]\n",
"Phi11[-1,0] = 0\n",
"Phi11[0,-1] = 0\n",
"Phi11ref=Phi11\n",
"\n",
"Phi11comp=np.array([[st.H3().h31Autocorrelation(II[j,i],JJ[j,i],M) for i in range(0,len(II[j]))] for j in range(0,len(II))])\n",
"\n",
"np.unique(Phi11ref-Phi11comp)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.])"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi22 = np.zeros(I.shape)\n",
"Phi22[A == 0] = 2.0/(105*M)\n",
"Phi22[A == 1] = -1.0/(140*M)\n",
"Phi22[A == M-1] = -1.0/(140*M)\n",
"Phi22ref=Phi22\n",
"\n",
"Phi22comp=np.array([[st.H3().h32PeriodicAutocorrelation(el,M) for el in row] for row in I])\n",
"\n",
"np.unique(Phi22ref-Phi22comp)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.00000000e+00, 2.16840434e-19, 4.33680869e-19])"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi22 = np.zeros(I.shape)\n",
"Phi22[A == 0] = 2.0/(105*M)\n",
"Phi22[A == 1] = -1.0/(140*M)\n",
"Phi22[A == M-1] = -1.0/(140*M)\n",
"Phi22 = M/(M-1)*Phi22\n",
"Phi22[0,0] = .5*Phi22[0,0]\n",
"Phi22[-1,-1] = .5*Phi22[-1,-1]\n",
"Phi22[-1,0] = 0\n",
"Phi22[0,-1] = 0\n",
"Phi22ref=Phi22\n",
"\n",
"Phi22comp=np.array([[st.H3().h32Autocorrelation(II[j,i],JJ[j,i],M) for i in range(0,len(II[j]))] for j in range(0,len(II))])\n",
"\n",
"np.unique(Phi22ref-Phi22comp)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([0.])"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi12 = np.zeros(I.shape)\n",
"Phi12[A == 1] = 13./(420*M)\n",
"Phi12[A == M-1] = -13./(420*M)\n",
"Phi12ref=Phi12\n",
"\n",
"Phi12comp=np.array([[st.H3().h3PeriodicCrosscorrelation(el,M) for el in row] for row in I])\n",
"\n",
"np.unique(Phi12ref-Phi12comp)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([-8.67361738e-19, 0.00000000e+00, 8.67361738e-19])"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"A = np.mod(I,M)\n",
"Phi12 = np.zeros(I.shape)\n",
"Phi12[A == 1] = 13./(420*M)\n",
"Phi12[A == M-1] = -13./(420*M)\n",
"Phi12 = M/(M-1)*Phi12\n",
"Phi12[0,0] = 11./(210*(M-1))\n",
"Phi12[-1,-1] = -11./(210*(M-1))\n",
"Phi12[0,-1] = 0\n",
"Phi12[-1,0] = 0\n",
"Phi12ref=Phi12\n",
"\n",
"Phi12comp=np.array([[st.H3().h3Crosscorrelation(II[j,i],JJ[j,i],M) for i in range(0,len(II[j]))] for j in range(0,len(II))])\n",
"\n",
"np.unique(Phi12ref-Phi12comp)"
]
},
{
"cell_type": "code",
"execution_count": null,