-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ dependencies: | |
- openpyxl | ||
- pandas | ||
- pydicom | ||
- pystackreg | ||
- pypubsub | ||
- read-roi | ||
- scikit-image | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from imagepy.core.engine import Filter, Simple | ||
from imagepy import IPy | ||
from pystackreg import StackReg | ||
import numpy as np | ||
import pandas as pd | ||
from skimage import transform as tf | ||
from imagepy.core.manager import TableManager | ||
|
||
class Register(Simple): | ||
title = 'Stack Register' | ||
note = ['8-bit', '16-bit', 'int', 'float', 'stack'] | ||
|
||
para = {'trans':'RIGID_BODY', 'ref':'previous', 'tab':False, 'new':'Inplace'} | ||
view = [(list, 'trans', ['TRANSLATION', 'RIGID_BODY', 'SCALED_ROTATION', 'AFFINE', 'BILINEAR'], str, 'transform', ''), | ||
(list, 'ref', ['previous', 'first', 'mean'], str, 'image', ''), | ||
(list, 'new', ['Inplace', 'New', 'None'], str, 'reference', ''), | ||
(bool, 'tab', 'show table')] | ||
|
||
def run(self, ips, imgs, para = None): | ||
news = np.array(imgs) | ||
sr = StackReg(eval('StackReg.%s'%para['trans'])) | ||
sr.register_stack(news, reference=para['ref']) | ||
mats = sr._tmats.reshape((sr._tmats.shape[0],-1)) | ||
if para['tab']: IPy.show_table(pd.DataFrame( | ||
mats, columns=['A%d'%(i+1) for i in range(mats.shape[1])]), title='%s-Tmats'%ips.title) | ||
if para['new'] == 'None': return | ||
for i in range(sr._tmats.shape[0]): | ||
tform = tf.ProjectiveTransform(matrix=sr._tmats[i]) | ||
if para['new'] == 'Inplace': | ||
imgs[i] = tf.warp(imgs[i], tform)*imgs[i].max() | ||
if para['new'] == 'New': | ||
news[i] = tf.warp(imgs[i], tform)*imgs[i].max() | ||
if para['new'] == 'New': IPy.show_img(news, '%s-reg'%ips.title) | ||
|
||
class Transform(Simple): | ||
title = 'Register By Mats' | ||
note = ['all'] | ||
|
||
para = {'mat':None, 'new':True} | ||
view = [('tab', 'mat', 'transfrom', 'matrix'), | ||
(bool, 'new', 'new image')] | ||
|
||
def run(self, ips, imgs, para = None): | ||
mats = TableManager.get(para['mat']).data.values | ||
if len(imgs) != len(mats): | ||
IPy.alert('image stack must has the same length as transfrom mats!') | ||
return | ||
newimgs = [] | ||
for i in range(len(mats)): | ||
tform = tf.ProjectiveTransform(matrix=mats[i].reshape((3,3))) | ||
img = tf.warp(imgs[i], tform) | ||
img -= imgs[i].min(); img *= imgs[i].max() - imgs[i].min() | ||
if para['new']: newimgs.append(img) | ||
else: imgs[i] = img | ||
if para['new']: IPy.show_img(newimgs, '%s-trans'%ips.title) | ||
|
||
plgs = [Register, Transform] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
catlog = ['New', 'Macros', 'Manager', '-', 'Install', 'Contribute', 'update_plg', '-', 'screencap_plg', 'Games'] | ||
catlog = ['New', 'Macros', 'Manager', '-', 'Install', 'Contribute', 'update_plg', '-', 'StackReg', 'Games', 'screencap_plg'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ def get_data_files(): | |
'read_roi', | ||
'numpy-stl', | ||
'pydicom', | ||
'pystackreg', | ||
'pandas', | ||
'xlrd', | ||
'xlwt', | ||
|