Commit c67dd499 authored by Martin Schorb's avatar Martin Schorb

icy integration

parent 93e54464
......@@ -11,8 +11,8 @@ import xml.etree.ElementTree as ET
import sys
import os
import glob
import numpy as np
......@@ -122,6 +122,108 @@ for regpt in em_regpts:
pts2xml(mm_fm['mapfile'], fm_px)
pts2xml(mm_em['mergefile'], em_px)
## ICY runs here
print('----------------------------------------------------------------')
print(' Starting Icy..................................')
print('----------------------------------------------------------------')
print(' Please run ec-CLEM and when done click SHOW ROIs ON ORIGINAL SOURCE IMAGE\n')
workdir = os.getcwd()
os.chdir('C:\Software\icy')
icycmd = 'java -jar icy.jar -x plugins.tprovoost.scripteditor.main.ScriptEditorPlugin C:\Software\opener.js'
os.system(icycmd +' '+ mm_fm['mapfile'] +' '+ mm_em['mergefile'] + os.path.splitext(mm_em['mapfile'])[1])
os.chdir(workdir)
#%%
# import icy XMLs
x_emf = mm_em['mergefile']+ os.path.splitext( mm_em['mapfile'])[1] + '_ROIsavedwhenshowonoriginaldata' + '.xml'
x_trafo = mm_fm['mapfile'] + '_transfo' + '.xml'
if not all([os.path.exists(x_emf),os.path.exists(x_trafo)]): raise ValueError('Could not find the results of Icy registration. Please re-run.')
root_em = ET.parse(x_emf)
root_trafo = ET.parse(x_trafo)
# extract transformation matrices
mat = []
if root_trafo.find('MatrixTransformation') == None:
root_trafo = ET.parse(glob.glob(mm_fm['mapfile'] + '_transfo' + '*back-up.xml')[-1])
for child in root_trafo.iter():
if child.tag == 'MatrixTransformation':
mat.append(child.attrib)
M = np.eye(4)
M_list = list()
for matrix in mat:
thismat = np.eye(4)
thismat[0,0] = matrix['m00']
thismat[0,1] = matrix['m01']
thismat[0,2] = matrix['m02']
thismat[0,3] = matrix['m03']
thismat[1,0] = matrix['m10']
thismat[1,1] = matrix['m11']
thismat[1,2] = matrix['m12']
thismat[1,3] = matrix['m13']
thismat[2,0] = matrix['m20']
thismat[2,1] = matrix['m21']
thismat[2,2] = matrix['m22']
thismat[2,3] = matrix['m23']
thismat[3,0] = matrix['m30']
thismat[3,1] = matrix['m31']
thismat[3,2] = matrix['m32']
thismat[3,3] = matrix['m33']
M_list.append(thismat)
M = np.dot(M.T,thismat)
# extract registration point positions
p_idx = list()
pts = list()
for child in root_em.iter():
pt = np.zeros(2)
if child.tag == 'position':
for coords in child.getiterator():
if coords.tag == 'pos_x':
pt[0] = float(coords.text)
elif coords.tag == 'pos_y':
pt[1] = float(coords.text)
#elif coords.tag == 'pos_z':
# pt[2] = float(coords.text)
pts.append(pt)
elif child.tag == 'name':
p_idx.append(int(child.text[child.text.rfind(' '):]))
### TODO ##
# create new file by copying the header of the input file
newnavf = navfile[:-4] + '_icy.nav'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment