Skip to content

Commit

Permalink
wip: experimenting with a command to upload the images
Browse files Browse the repository at this point in the history
  • Loading branch information
william-silversmith committed Aug 13, 2021
1 parent b6448a7 commit f79f827
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
click
numpy
cloud-volume
tinybrain
Pillow
28 changes: 28 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[metadata]
name = tem2ng
url = https://github.com/seung-lab/tem2ng/
summary = Convert raw microscope images into a neuroglancer volume.
description-content-type = text/markdown
description-file = README.md
author = William Silversmith
author-email = [email protected]
home-page = https://github.com/seung-lab/tem2ng/
license = License :: OSI Approved :: BSD License
classifier =
Intended Audience :: Developers
Development Status :: 4 - Beta
License :: OSI Approved :: BSD License
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Libraries :: Python Modules

[global]
setup-hooks = pbr.hooks.setup_hook

[files]
packages =
tem2ng

[extras]
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os
import setuptools
import sys

setuptools.setup(
setup_requires=['pbr'],
python_requires="~=3.7", # >= 3.7 < 4.0
include_package_data=True,
entry_points={
"console_scripts": [
"tem2ng=tem2ng:main"
],
},
pbr=True
)

53 changes: 53 additions & 0 deletions tem2ng/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import re
import os

import click

from cloudvolume import CloudVolume
import numpy as np
import tinybrain

from PIL import Image

TILE_REGEXP = re.compile(r'tile_(\d+)_(\d+)\.bmp')

def get_ng(tilename, z=0):
x_map = {4:0,5:1,6:2,3:0,0:1,7:2,2:0,1:1,8:2}
get_x = lambda t1,t2: 6000 * ((t1%25)*3 + x_map[t2])
y_map = {4:0,3:1,2:2,5:0,0:1,1:2,6:0,7:1,8:2}
get_y = lambda t1,t2: 6000 * ((t1//25)*3 + y_map[t2])

t1, t2 = re.match(TILE_REGEXP, tilename).groups()

x0 = get_x(t1, t2)
xf = x0 + 6000
y0 = get_y(t1,t2)
yf = y0 + 6000

return f"{x0}-{xf}_{y0}-{yf}_{z}-{z+1}"

@click.command()
@click.argument("source")
def main(source):
cv = CloudVolume("matrix://pni-tem1/test/")

for filename in os.scandir(source):
ext = os.path.splitext(filename)[1]
if ext != ".bmp":
continue

img = Image.open(filename)


img = Image.open("tile_99_0.bmp")
img.show()










0 comments on commit f79f827

Please sign in to comment.