Skip to content
Snippets Groups Projects
Commit e79f04bb authored by Andrey Aristov's avatar Andrey Aristov
Browse files

rotate in the thread

parent 453a8881
No related branches found
No related tags found
No related merge requests found
...@@ -16,13 +16,21 @@ from scipy.ndimage import laplace, rotate ...@@ -16,13 +16,21 @@ from scipy.ndimage import laplace, rotate
import json import json
def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_path, labels_path, table_path, fit_poisson, nmax=10): def align_multichip(
BF_TRITC_2D_path,
out_path,
concentrations_path,
template_path,
labels_path,
table_path,
fit_poisson,
nmax=10):
with open(concentrations_path, 'r') as f: with open(concentrations_path, 'r') as f:
concentrations_dct = (yaml.safe_load(f)) concentrations_dct = (yaml.safe_load(f))
concentrations = concentrations_dct['concentrations'] concentrations = concentrations_dct['concentrations']
if "rotation_template_deg" in concentrations_dct: if "rotation_data_deg" in concentrations_dct:
rotate_template_deg = int(concentrations_dct["rotation_template_deg"]) rotation_data_deg = int(concentrations_dct["rotation_data_deg"])
print(f'Rotation: {rotate_template_deg}') print(f'Rotation: {rotation_data_deg}')
else: else:
rotate_template_deg = 0 rotate_template_deg = 0
print('concentrations: ', concentrations) print('concentrations: ', concentrations)
...@@ -32,9 +40,6 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa ...@@ -32,9 +40,6 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
data = read_dask(BF_TRITC_2D_path) data = read_dask(BF_TRITC_2D_path)
template16 = tf.imread(template_path) template16 = tf.imread(template_path)
if rotate_template_deg != 0:
data = da.from_array(rotate(data, rotate_template_deg))
print(f'Rotated data {rotate_template_deg} deg')
big_labels = tf.imread(labels_path) big_labels = tf.imread(labels_path)
fun = partial( fun = partial(
...@@ -43,7 +48,8 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa ...@@ -43,7 +48,8 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
big_labels=big_labels, big_labels=big_labels,
unit=unit, unit=unit,
fit_poisson=fit_poisson, fit_poisson=fit_poisson,
nmax=nmax ) nmax=nmax,
rotation_data_deg=rotation_data_deg )
try: try:
p=Pool(data.shape[0]) p=Pool(data.shape[0])
...@@ -89,7 +95,16 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa ...@@ -89,7 +95,16 @@ def align_multichip(BF_TRITC_2D_path, out_path, concentrations_path, template_pa
def align_parallel(args, **kwargs): def align_parallel(args, **kwargs):
return align2D(*args, **kwargs) return align2D(*args, **kwargs)
def align2D(stack_dask, path_tif, ab, template16=None, big_labels=None, unit='μg_mL', fit_poisson=True, nmax=20): def align2D(
stack_dask,
path_tif,
ab,
template16=None,
big_labels=None,
unit='μg_mL',
fit_poisson=True,
nmax=20,
rotation_data_deg=0):
print(ab, unit) print(ab, unit)
try: try:
aligned = tf.imread(path_tif) aligned = tf.imread(path_tif)
...@@ -102,6 +117,10 @@ def align2D(stack_dask, path_tif, ab, template16=None, big_labels=None, unit='μ ...@@ -102,6 +117,10 @@ def align2D(stack_dask, path_tif, ab, template16=None, big_labels=None, unit='μ
print('Processing...') print('Processing...')
data = stack_dask.compute() data = stack_dask.compute()
if rotation_data_deg != 0:
data = rotate(data, rotation_data_deg)
print(f'Rotated data {rotation_data_deg} deg')
aligned, tvec = register.align_stack( aligned, tvec = register.align_stack(
data, data,
path_to_save=None, path_to_save=None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment