Skip to content

Commit

Permalink
v0.93
Browse files Browse the repository at this point in the history
  • Loading branch information
macronucleus committed Jul 24, 2023
1 parent 91fb2ac commit 0401d23
Show file tree
Hide file tree
Showing 37 changed files with 265 additions and 130 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ directory structures.
when `python-bioformats` or `javabridge` are not installed.
16. (v0.92 20230207) Multiple image series in a file is supported but
only the first one is used. Also imgio has been a lot changed;
`tifffile` version had been upgraded and ome.tif is written out by tifffile.
`tifffile` version had been upgraded and ome.tif is written out
by tifffile. Furthermore, with the `nd2` package, nd2 files are
directly read without installing bioformats.
17. (v0.93 20230707) Writing ome.tif is compatible for
`tifffile` 2021.7.2.
18. (v0.93 20230709) Bug fix for DeltaVision deconvolved files.

v0.8(May. 2019)
----
Expand Down
49 changes: 40 additions & 9 deletions Chromagnon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,34 @@ if sys.platform.startswith('win'):
code=os.path.abspath(os.path.join('Z:', 'py'))
src = os.path.abspath(os.path.join('Z:', 'src', 'Chromagnon', 'Chromagnon'))


binaries = [(os.path.join(libbin, 'mkl_avx.dll'), '.'), (os.path.join(libbin, 'mkl_avx2.dll'), '.')]
# if os.path.isfile(os.path.join(libbin, 'mkl_avx.dll')):
# binaries = [(os.path.join(libbin, 'mkl_avx.dll'), '.')]#, (os.path.join(libbin, 'mkl_avx2.dll'), '.')]
# elif os.path.isfile(os.path.join(libbin, 'mkl_avx.2.dll')):
# binaries = [(os.path.join(libbin, 'mkl_avx.2.dll'), '.')]
if not PLUGIN:
if pyversion == 3:
glut = 'glut64.dll'
elif pyversion == 2:
if os.path.isfile(os.path.join(libbin, 'freeglut.dll')):
glut = os.path.join(libbin, 'freeglut.dll')
else:
glut = 'glut64.dll'
#if pyversion == 3:
# glut = 'glut64.dll'
#elif pyversion == 2:
# glut = os.path.join(libbin, 'freeglut.dll')
binaries += [(os.path.join(home, conda, glut), '.')]
pylib = 'pyd'
jvm = 'jvm.dll'
suffix = 'Win' + ex_suffix

else: # mac + linux
code=os.path.join(home, 'codes', 'py')
src = os.path.join(home, 'codes', 'src', 'Chromagnon', 'Chromagnon')
if os.path.isdir(os.path.expanduser('~/codes/py')):
CODE='codes'
elif os.path.isdir(os.path.expanduser('~/local/py')):
CODE='local'
else:
raise ValueError('directory for codes not found')

code=os.path.join(home, CODE, 'py')
src = os.path.join(home, CODE, 'src', 'Chromagnon', 'Chromagnon')

site=os.path.join(conda, 'lib', 'python%i.%i' % (pyversion, sys.version_info.minor), 'site-packages')
print('site is', site)
Expand Down Expand Up @@ -104,13 +117,31 @@ else:
cversion = ''
# ------- pyinstaller

datas = [(os.path.join(code, 'Priithon', '*.py'), 'Priithon'), (os.path.join(code, 'Priithon', 'plt', '*.py'), os.path.join('Priithon', 'plt')), (os.path.join(code, 'PriCommon', '*.py'), 'PriCommon'), (os.path.join(code, 'common', '*.py'), 'common'), (os.path.join(site, 'tifffile', '*.%s' % pylib), 'tifffile')]
datas = [(os.path.join(code, 'Priithon', '*.py'), 'Priithon'), (os.path.join(code, 'Priithon', 'plt', '*.py'), os.path.join('Priithon', 'plt')), (os.path.join(code, 'PriCommon', '*.py'), 'PriCommon'), (os.path.join(code, 'common', '*.py'), 'common')]#, (os.path.join(site, 'tifffile', '*.%s' % pylib), 'tifffile')]
if 0:#sys.platform.startswith('linux'):
datas += [(os.path.join(pylibpath, 'libglut.*'), 'lib')]

if not PLUGIN:
#datas += [(os.path.join(site, 'javabridge', '*.%s' % pylib), 'javabridge'), (os.path.join(site, 'javabridge', 'jars', '*'), os.path.join('javabridge', 'jars')), (os.path.join(site, 'bioformats', 'jars', '*'), os.path.join('bioformats', 'jars'))]
datas += [(os.path.join(site, 'javabridge', 'jars', '*'), os.path.join('javabridge', 'jars')), (os.path.join(site, 'bioformats', 'jars', '*'), os.path.join('bioformats', 'jars'))]#, (os.path.join(os.path.dirname(site), 'lib-dynload', '_posixsubprocess.cpython-37m-x86_64-linux-gnu.so'), os.path.join('lib', 'python3.7', 'lib-dynload'))]
try:
import javabridge, bioformats
jv = os.path.dirname(javabridge.__file__)
bf = os.path.dirname(os.path.dirname(bioformats.__file__))
datas += [(os.path.join(jv, 'jars', '*'), os.path.join('javabridge', 'jars')), (os.path.join(bf, 'bioformats', 'jars', '*'), os.path.join('bioformats', 'jars'))]
except ImportError:
pass
try:
import nd2
nd2 = os.path.dirname(nd2.__file__)
datas += [(os.path.join(nd2, '*.typed'), 'nd2')]
except ImportError:
pass

#if 1:#sys.platform.startswith('win'): # v=0.7.1
# datas += [(os.path.join(nd2, '*.typed'), 'nd2')]
#else:
# datas += [(os.path.join(nd2, '_sdk', '*'), os.path.join('nd2', '_sdk'))]
#datas += [(os.path.join(site, 'javabridge', 'jars', '*'), os.path.join('javabridge', 'jars')), (os.path.join(site, 'bioformats', 'jars', '*'), os.path.join('bioformats', 'jars'))]

a = Analysis([prog],
pathex=[code],
Expand Down
22 changes: 13 additions & 9 deletions Chromagnon/PriCommon/flatConv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
try:
import wx
import time
from common import guiFuncs as G
from . import guiFuncs as G
_wx = True
except ImportError:
_wx = False
Expand Down Expand Up @@ -263,7 +263,7 @@ def view(self, target):
"""
view with viewer
"""
import ndviewer
from PriCommon import ndviewer
import sys
# prepare viewer
if not self.aui:
Expand All @@ -290,8 +290,8 @@ def view(self, target):

usage = r"""%prog imgFiles [options]"""
p = optparse.OptionParser(usage=usage)
p.add_option('--suffix', '-S', default=SUF,
help='suffix for the output file names (default inputfile + %s)' % SUF)
p.add_option('--out', '-O',
help='output file name (default inputfile + %s)' % EXT)
p.add_option('--flatFile', '-F',
help='flatFielding file required for flatfielding')
p.add_option('--make', '-m', action='store_true',
Expand All @@ -306,21 +306,25 @@ def view(self, target):
else:
make = options.make
del options.make
#fns = arguments#[0]
#args = arguments[1:]

fns = []
for fn in arguments:
fns += glob.glob(os.path.expandvars(os.path.expanduser(fn)))

if make:
outs = [makeFlatConv(fn, suffix=EXT) for fn in fns]
outs = [makeFlatConv(fn) for fn in fns]
if len(outs) > 1:
out = os.path.commonprefix(outs) + EXT
out = imgio.merge(outs, out, along='w')
if options.out:
out = options.out
else:
out = os.path.commonprefix(outs) + EXT
out = O.copyImgs.merge(outs, out, mergeAlong='w')
[os.remove(out) for out in outs]
else:
out = outs[0]
print(out, ' saved')
else:
for fn in fns:
out = flatConv(fn, **options.__dict__)
print(out, ' done')
print(flatConv(fn, **options.__dict__), ' done')
7 changes: 3 additions & 4 deletions Chromagnon/PriCommon/imgFilters.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env python
from __future__ import print_function

try:
from Priithon.all import N, U, Y, F
from ..Priithon.all import N, U, Y, F, Mrc
except (ValueError, ImportError):
from ..Priithon.all import N, U, Y, F
from Priithon.all import N, U, Y, F, Mrc
from scipy import optimize
try:
from . import imgFit
Expand Down Expand Up @@ -955,7 +954,7 @@ def findMaxWithGFitAll(img, thre=0, sigma_peak=0.5, npts=100, win=11, mask_npxls
else:
v = ret[1]
zyx = ret[2:2+ndim]
if N.any(N.abs(zyx - vzyx[-ndim:]) > win/2.):#zyx < 0 or zyx > img.shape or ):
if N.any(N.abs(zyx - vzyx[1:]) > win/2.):#zyx < 0 or zyx > img.shape or ):
mask_value(img, vzyx[-ndim:], r=mask_npxls, value=img.min())
poses.append(list(vzyx)[0:1] + [vzyx[-ndim:]] + [sigma_peak])
else:
Expand Down
4 changes: 2 additions & 2 deletions Chromagnon/PriCommon/imgFit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### Here all kinds of fitting
from __future__ import print_function
try:
from Priithon.all import N, U
except (ValueError, ImportError):
from ..Priithon.all import N, U
except (ValueError, ImportError):
from Priithon.all import N, U
try:
from . import imgFilters, imgGeo
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion Chromagnon/PriCommon/imgGeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def affine(a, r, mag, tyx=(0,0), center=(0,0)):

def affine_index(indexarray, r, mag, tyx=(0,0), center=None):
if center is None:
center = N.array(indexarray.shape[-2:], N.float) / 2.
center = N.array(indexarray.shape[-2:], float) / 2.

rotRadian = N.pi / 180. * r
cosTheta = N.cos(rotRadian)
Expand Down
13 changes: 6 additions & 7 deletions Chromagnon/PriCommon/imgResample.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
try:
from Priithon.all import U, N
from common import ppro26 as ppro
except (ValueError, ImportError):
from ..Priithon.all import U, N
from ..common import ppro26 as ppro
except (ValueError, ImportError):
from Priithon.all import U, N

from . import ppro26 as ppro
NCPU = ppro.NCPU

import scipy.ndimage.interpolation as ndii
Expand Down Expand Up @@ -113,7 +112,7 @@ def trans3D_affine(arr, tzyx=(0,0,0), r=0, mag=1, dzyx=(0,0,0), rzy=0, ncpu=NCPU

arr = canvas

if dtype in (N.int, N.uint8, N.uint16, N.uint32):
if dtype in (int, N.uint8, N.uint16, N.uint32):
arr = N.where(arr < 0, 0, arr)

return arr.astype(dtype)
Expand Down Expand Up @@ -146,8 +145,8 @@ def getOffset(shape, invmat, ty, tx, start=0):

def affine_transform(arr, invmat, offset=0.0, order=ORDER):
return U.nd.affine_transform(arr, invmat, offset,
output=N.float32, cval=arr.min(), order=order)
#output=N.float32, cval=0, order=order)
#output=N.float32, cval=arr.min(), order=order)
output=N.float32, cval=0, order=order)


#
Expand Down
2 changes: 0 additions & 2 deletions Chromagnon/PriCommon/xcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ def Xcorr(a, b, phaseContrast=PHASE, nyquist=NYQUIST, gFit=True, win=11, ret=Non
afa = af
bfa = bf
fact = N.std(a) * N.std(b) * a.size
if not fact:
fact = 1
del a, b, af, bf

targetShape = shape #+ (npad * 2)
Expand Down
20 changes: 12 additions & 8 deletions Chromagnon/Priithon/plt/plot_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ def draw_point_list(start,stop,pen,dc):
start and stop are 2xN arrays of x,y point coordinates. N lines
are drawn, one between each of the start,stop pairs using the
specified pen. The lines are drawn on the given device context, dc.
"""
"""
#print('draw_point_list')
dc.SetPen(pen)
for i in range(len(start)):
pt1 = start[i]
pt2 = stop[i]
dc.DrawLine(pt1[0],pt1[1],pt2[0],pt2[1])
dc.DrawLine(int(pt1[0]),int(pt1[1]),int(pt2[0]),int(pt2[1]))
dc.SetPen(wx.NullPen)

#-----------------------------------------------------------------------#
Expand Down Expand Up @@ -752,6 +753,7 @@ def draw_fast(self,dc):
color = get_color(self.color)
pen = wx.Pen(color, self.weight, style)
dc.SetPen(pen)
#print('draw_fast')
dc.DrawLines(self.single_line)
dc.SetPen(wx.NullPen)

Expand Down Expand Up @@ -785,8 +787,10 @@ def draw(self, dc):
style = line_style_map[self.style]
dc.SetPen(wx.Pen(color, self.weight,style))
try:
#print('draw')
dc.DrawLines(self.scaled)
except:
#print('draw except')
dc.DrawLines(list(map(tuple,self.scaled)))
dc.SetPen(wx.NullPen)

Expand Down Expand Up @@ -848,12 +852,12 @@ def _down_triangle(self, dc, xc, yc, size=1):
(0.0,0.577350*size*6)],xc,yc)

def _cross(self, dc, xc, yc, size=1):
dc.DrawLine(xc-3*size,yc-3*size,xc+3*size,yc+3*size)
dc.DrawLine(xc-3*size,yc+3*size,xc+3*size,yc-3*size)
dc.DrawLine(int(xc-3*size),int(yc-3*size),int(xc+3*size),int(yc+3*size))
dc.DrawLine(int(xc-3*size),int(yc+3*size),int(xc+3*size),int(yc-3*size))

def _plus(self, dc, xc, yc, size=1):
dc.DrawLine(xc-3*size,yc,xc+3*size,yc)
dc.DrawLine(xc,yc-3*size,xc,yc+3*size)
dc.DrawLine(int(xc-3*size),int(yc),int(xc+3*size),int(yc))
dc.DrawLine(int(xc),int(yc-3*size),int(xc),int(yc+3*size))

class line_object(poly_points):
""" Combines poly_line and poly_marker into a single
Expand Down Expand Up @@ -964,8 +968,8 @@ def bounding_box(self):
return bb

def scale_and_shift(self, scale=1, shift=0,upperleft=None,size=None):
if scale is 1: scale = array((1,1))
if shift is 0: shift = array((0,0))
if scale == 1: scale = array((1,1))
if shift == 0: shift = array((0,0))
graph_pixels_per_axis_unit = scale
self.scale = graph_pixels_per_axis_unit/self.image_pixels_per_axis_unit
self.origin = shift
Expand Down
2 changes: 1 addition & 1 deletion Chromagnon/Priithon/splitND2.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def __init__(self, data, colorAxis=-3, title='', size=None,
if not isinstance(data, F.mockNDarray):
data = N.asanyarray(data) # 20060720 - numpy arrays don't have ndim attribute
# 20180308
if data.dtype.type in [N.bool, N.uint32, N.uint64]:
if data.dtype.type in [bool, N.uint32, N.uint64]:
data = data.astype(N.uint16)
elif data.dtype.type in [N.int32, N.int64, ]:
data = data.astype(N.int16)
Expand Down
10 changes: 7 additions & 3 deletions Chromagnon/Priithon/viewerCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,13 @@ def OnMouse(self, ev):

self.SetCurrent(self.context)
#x,y = ev.m_x, self.m_h-ev.m_y
x, y = ev.GetPosition() # 20141127
y = self.m_h - y
xEff_float, yEff_float= gluUnProject(x,y,0)[:2]
# x, y = ev.GetPosition() # 20141127
# y = self.m_h - y
#xEff_float, yEff_float= gluUnProject(x,y,0)[:2] # does not work on M2 Mac 20230225
x = ev.GetX()
y = self.m_h-ev.GetY()
x0, y0, scale, aspR = self.m_x0, self.m_y0, self.m_scale, self.m_aspectRatio
xEff_float, yEff_float = int( (x-x0)/scale ) , int( (y-y0)/(scale*aspR) )

# 20080701: in new coord system, integer pixel coord go through the center of pixel

Expand Down
Empty file modified Chromagnon/__init__.py
100755 → 100644
Empty file.
Loading

0 comments on commit 0401d23

Please sign in to comment.