Commit 600968dd authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

add flirt functionality

parent b53da43e
......@@ -202,9 +202,12 @@ class FlirtGui(BaseGui):
widget = event.GetEventObject()
idx = widget.GetSelection()
choice_str = widget.GetString(idx)
if 'lowres' in choice_str:
if 'low res' in choice_str:
self.view.input_lowres.set_label("Low res image*")
self.view.input_lowres.Show()
self.view.input_img.set_label("High res image*")
self._layout_from(self.view.input_lowres)
else:
self.view.input_img.set_label("Input image*")
self.view.input_lowres.Hide()
self._layout_from(self.view.input_lowres)
\ No newline at end of file
......@@ -274,8 +274,47 @@ class Bet(object):
class Flirt(object):
flirt_type_choices = [
"highres to standard",
"lowres to highres to standard"
"input to reference",
"low res to high res to reference"
]
def __init__(self, in_highres=""):
search_img_choices = [
"not aligned but same orientation",
"already virtually aligned (no search)",
"not aligned and different orientation"
]
cost_func_choices = [
"corratio",
"mutualinfo",
"normcorr",
"normmi",
"leastsq",
"labeldiff",
"bbr"
]
interp_choices = [
"trilinear",
"nearestneighbour",
"sinc",
"spline"
]
def __init__(self,
in_img="",
ref_img="",
in_lowres="",
dof_in_to_ref=12,
dof_lowres_to_highres=12,
ref_weight_img="",
in_weight_img="",
in_lowres_weight_img="",
secondary_img_list=[],
cost="",
bins=256,
interp="trilinear",
search_xmin=-90,
search_xmax=90,
search_ymin=-90,
search_ymax=90,
search_zmin=-90,
search_zmax=90
):
pass
\ No newline at end of file
......@@ -166,18 +166,25 @@ class FlirtView(wx.Panel):
sizer.Add(mode_panel, proportion=0, flag=wx.ALL, border=5)
# low res input panel (hidden when mode is highres to standard)
self.input_lowres = fslwidgets.Input(self).set_label("Lowres image*")
self.input_lowres = fslwidgets.Input(self).set_label("Low res image*")
sizer.Add(self.input_lowres, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
self.input_lowres.Hide()
# high res input panel
self.input_highres = fslwidgets.Input(self).set_label("Highres image*")
sizer.Add(self.input_highres, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
self.input_img = fslwidgets.Input(self).set_label("Input image*")
sizer.Add(self.input_img, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
# reference image picker panel
self.input_reference = fslwidgets.ReferencePicker(self).set_label("Reference image*")
sizer.Add(self.input_reference, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
# secondary image panel
#TODO enable this later
# self.secondary_image_panel = fslwidgets.SecondaryImageInput(self, "")
# sizer.Add(self.secondary_image_panel, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
# lastly set the sizer with all widgets added
self.SetSizer(sizer)
......
......@@ -109,21 +109,26 @@ class FileDropTextCtrl(wx.FileDropTarget):
return True
class Input(wx.Panel):
def __init__(self, parent, **kwargs):
def __init__(self, parent, label="", show_remove=False):
wx.Panel.__init__(self, parent)
self.file_path = ""
#sizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, "Input image*")
self.box = wx.StaticBox(self, label="")
self.box = wx.StaticBox(self, label=label)
sizer = wx.StaticBoxSizer(self.box)
self.remove_button = wx.Button(self.box, label="Remove")
self.button = wx.Button(self.box, label="Choose")
if not show_remove:
self.remove_button.Hide()
self.file_ctrl = wx.TextCtrl(self.box, value="")
drop_target = FileDropTextCtrl(self.file_ctrl)
self.file_ctrl.SetDropTarget(drop_target)
sizer.Add(self.remove_button, proportion=0, flag=wx.ALL, border=5)
sizer.Add(self.file_ctrl, 1, wx.EXPAND | wx.ALL, 5)
sizer.Add(self.button, 0, wx.ALL, 5)
self.SetSizer(sizer)
self.button.Bind(wx.EVT_LEFT_UP, self._on_choose)
self.button.Bind(wx.EVT_BUTTON, self._on_choose)
self.remove_button.Bind(wx.EVT_BUTTON, self._on_remove)
def set_label(self, text):
self.box.SetLabel(text)
......@@ -144,6 +149,41 @@ class Input(wx.Panel):
self.file_path = os.path.abspath(fd.GetPath())
self.set_text(self.file_path)
def _on_remove(self, event):
self.Hide()
self.GetGrandParent().Layout()
self.Destroy()
class SecondaryImageInput(wx.Panel):
def __init__(self, parent, label=""):
wx.Panel.__init__(self, parent)
self.image_list = []
#sizer = wx.StaticBoxSizer(wx.HORIZONTAL, self, "Input image*")
self.box = wx.StaticBox(self, label=label)
sizer = wx.StaticBoxSizer(self.box, orient=wx.VERTICAL)
text_and_btn_panel = wx.Panel(self)
text_and_btn_sizer = wx.BoxSizer(wx.HORIZONTAL)
st = wx.StaticText(text_and_btn_panel, label="Apply transform to secondary images")
st.SetToolTip("Secondary images MUST be in the same space as the first input image (or the low res image)")
add_btn = wx.Button(text_and_btn_panel, label="Add image")
text_and_btn_sizer.Add(st, proportion=0, flag=wx.ALL, border=5)
text_and_btn_sizer.Add(add_btn, proportion=0, flag=wx.ALL, border=5)
text_and_btn_panel.SetSizer(text_and_btn_sizer)
sizer.Add(text_and_btn_panel, proportion=0, flag=wx.ALL, border=5)
self.SetSizer(sizer)
add_btn.Bind(wx.EVT_BUTTON, self._on_add)
def _on_add(self, event):
self.image_list.clear()
#TODO add input panels to a list to get input files from
new_input = Input(self, show_remove=True)
self.image_list.append(new_input)
self.GetSizer().Add(new_input, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
self.GetParent().Layout()
class ReferencePicker(wx.Panel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
......
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