Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/conf.py
#	eyepy/io/__init__.py
#	eyepy/io/base.py
#	eyepy/io/he_vol.py
  • Loading branch information
Oli4 committed May 6, 2020
2 parents f539013 + 5c3c0a7 commit 95eb730
Show file tree
Hide file tree
Showing 34 changed files with 661 additions and 2,073 deletions.
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
minimum_pre_commit_version: 1.20.0
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: requirements-txt-fixer
- id: fix-encoding-pragma
- id: check-added-large-files
- id: check-docstring-first
- repo: https://github.com/asottile/blacken-docs
rev: v1.3.0
hooks:
- id: blacken-docs
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.2
hooks:
- id: python-use-type-annotations
- repo: https://github.com/myint/docformatter
rev: v1.3.1
hooks:
- id: docformatter
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8 changes: 8 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
========
Examples
========

.. toctree::
:maxdepth: 2

examples/rigid_registration
110 changes: 110 additions & 0 deletions docs/examples/rigid_registration.ipynb

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Welcome to eyepy's documentation!
readme
installation
usage
examples
modules
contributing
authors
history


Indices and tables
==================
* :ref:`genindex`
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Usage

To use eyepy in a project::

import eyepy
import eyepy as ep
4 changes: 1 addition & 3 deletions eyepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,4 @@
__email__ = "oli4morelle@gmail.com"
__version__ = "0.1.0"

from . import io
from . import preprocess
from . import register
from . import io, preprocess, register
5 changes: 2 additions & 3 deletions eyepy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
def main():
"""Console script for eyepy."""
parser = argparse.ArgumentParser()
parser.add_argument('_', nargs='*')
parser.add_argument("_", nargs="*")
args = parser.parse_args()

print("Arguments: " + str(args._))
print("Replace this message by putting your code into "
"eyepy.cli.main")
print("Replace this message by putting your code into " "eyepy.cli.main")
return 0


Expand Down
1 change: 1 addition & 0 deletions eyepy/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# -*- coding: utf-8 -*-
from .he_vol import HeyexOct, read_vol
55 changes: 29 additions & 26 deletions eyepy/io/he_xml.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,76 @@
import untangle
# -*- coding: utf-8 -*-
import numpy as np
import untangle


class SpectralisXMLReader(object):
def __init__(self, path):
self.obj = untangle.parse(path)

@property
def version(self):
self.obj.HEDX.BODY.SWVersion.Version.cdata

@property
def octs(self):
images = self.obj.HEDX.BODY.Patient.Study.Series.Image
return [i for i in images if i.ImageType.Type == 'OCT']
return [i for i in images if i.ImageType.Type == "OCT"]

@property
def oct_filenames(self):
octs = self.octs
return self.get_oct_filenames(octs)

@property
def localizer_filename(self):
return self.get_localizer_filename()

@property
def oct_width(self):
return int(self.octs[0].OphthalmicAcquisitionContext.Width.cdata)

@property
def oct_height(self):
return int(self.octs[0].OphthalmicAcquisitionContext.Height.cdata)

@property
def oct_n(self):
return int(len(self.octs))


def get_segmentations(self):

self.segmentations = {}

def get_segmentations(self):

self.segmentations = {}
seg_types = [x.Name for x in self.octs[0].Segmentation.SegLine]

for seg_type in seg_types:
self.segmentations[seg_type.cdata] = self.get_segmentation(seg_type.cdata)

self.segmentations[seg_type.cdata] *= 255
self.segmentations[seg_type.cdata] = self.segmentations[seg_type.cdata].astype(np.uint8)
self.segmentations[seg_type.cdata] = self.segmentations[
seg_type.cdata
].astype(np.uint8)
return self.segmentations



def get_segmentation(self, name):
seg = np.zeros((self.oct_n, self.oct_height, self.oct_width))
for i in range(self.oct_n):
for s in self.octs[i].Segmentation.SegLine:
if s.Name.cdata == name:
seg_data = np.array(s.Array.cdata.split(' ')).astype('float')
seg_data = np.array(s.Array.cdata.split(" ")).astype("float")
x = np.where(seg_data < 10000)
y = np.rint(seg_data[x]).astype(int)
seg[i, y, x] = 1
#seg = (seg*255).astype(np.uint8)
# seg = (seg*255).astype(np.uint8)

return seg

def get_oct_filenames(self, octs):
names = []
for o in octs:
names.append(o.ImageData.ExamURL.cdata.split('\\')[-1])
names.append(o.ImageData.ExamURL.cdata.split("\\")[-1])
return names

def get_localizer_filename(self):
images = self.obj.HEDX.BODY.Patient.Study.Series.Image
path = [i for i in images if i.ImageType.Type == 'LOCALIZER'][0]
return path.ImageData.ExamURL.cdata.split('\\')[-1]
path = [i for i in images if i.ImageType.Type == "LOCALIZER"][0]
return path.ImageData.ExamURL.cdata.split("\\")[-1]
9 changes: 9 additions & 0 deletions eyepy/preprocess/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# -*- coding: utf-8 -*-
from .loggabor import mean_phase


def center_crop(img, size):
center = img.shape[0] // 2, img.shape[1] // 2

height_range = center[0] - size[0] // 2, center[0] + size[0] // 2
width_range = center[1] - size[1] // 2, center[1] + size[1] // 2
return img[height_range[0] : height_range[1], width_range[0] : width_range[1], :]

0 comments on commit 95eb730

Please sign in to comment.