Commit acee8809 authored by Taylor Hanayik's avatar Taylor Hanayik
Browse files

add FSLeyes image widget

parent 4e53b71a
......@@ -22,7 +22,7 @@ allowedContainerWidgets = (
allowedWidgets = (
*allowedContainerWidgets,
'filepath', 'checkbox', 'choice',
'number', 'button',
'number', 'button', 'FsleyesImage'
)
allowedConfigKeys = (
......
......@@ -6,14 +6,15 @@ windowSize:
height: 500
layout:
- notebook:
- page_Setup:
- page_Inputs:
- group_Files:
- column:
- filepath: {label: Input file, propName: inputFile}
- filepath: {label: Output file, propName: outputFile}
- row:
- number: {label: F value, propName: fval, showLimits: 0}
- column:
- FsleyesImage: {name: FsleyesImage}
- page_Options:
- column:
- choice: {label: BET run type, propName: betRunType}
\ No newline at end of file
- page_Viewer:
\ No newline at end of file
......@@ -555,3 +555,107 @@ class OrthoView(wx.CollapsiblePane):
self.overlayList.append(img, cmap='red', alpha=30)
class FsleyesImage(wx.Panel):
def __init__(self, parent, propobj, **kwargs):
super().__init__(parent, **kwargs)
self.overlayList, masterDisplayCtx, _ = _embed(None, make_fsleyesframe=False)
self.displayCtx = fsldc.DisplayContext(self.overlayList, parent=masterDisplayCtx)
sizer = wx.BoxSizer(wx.VERTICAL)
self.op = orthopanel.OrthoPanel(
self,
self.overlayList,
self.displayCtx,
None)
self.op.SetMinSize((-1, 300))
self.op.Show()
self.btn_fsleyes = wx.Button(self, label="Open in FSLeyes")
sizer.Add(self.btn_fsleyes, proportion=0, flag=wx.ALL, border=5)
sizer.Add(self.op, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
self.SetSizer(sizer)
# bind events
self.btn_fsleyes.Bind(wx.EVT_BUTTON, self.launch_fsleyes)
propobj.addListener('inputFile', 'inputFileListener', self.add_image)
def _run_fsleyes(self):
imgs = [img.dataSource for img in self.overlayList]
# print([img.dataSource for img in self.overlayList])
cmd = [
os.path.join(fslplatform.fsldir, 'bin', 'fsleyes'),
" ".join(imgs)
]
subprocess.run(
" ".join(cmd),
shell=True,
check=True
)
def launch_fsleyes(self, event):
thread_id = idle.run(self._run_fsleyes)
def reset(self):
self.overlayList.clear()
def add_image(self, new_img, valid, context, name):
img = fslimage.Image(new_img)
self.overlayList.append(img)
def add_mask(self, new_img):
img = fslimage.Image(new_img)
self.overlayList.append(img, cmap='red', alpha=30)
# def fsleyesImage(parent, propobj, **kwargs):
# overlayList, masterDisplayCtx, _ = _embed(None, make_fsleyesframe=False)
# displayCtx = fsldc.DisplayContext(overlayList, parent=masterDisplayCtx)
# panel = wx.Panel(parent)
# sizer = wx.BoxSizer(wx.VERTICAL)
# op = orthopanel.OrthoPanel(
# panel,
# overlayList,
# displayCtx,
# None)
# op.SetMinSize((-1, 300))
# op.Show()
# btn_fsleyes = wx.Button(panel, label="Open in FSLeyes")
# sizer.Add(btn_fsleyes, proportion=0, flag=wx.ALL, border=5)
# sizer.Add(op, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
# panel.SetSizer(sizer)
# def _run_fsleyes():
# imgs = [img.dataSource for img in overlayList]
# cmd = [
# os.path.join(fslplatform.fsldir, 'bin', 'fsleyes'),
# " ".join(imgs)
# ]
# subprocess.run(
# " ".join(cmd),
# shell=True,
# check=True
# )
# def _launch_fsleyes(event):
# thread_id = idle.run(_run_fsleyes)
# def _reset():
# overlayList.clear()
# def _add_image(new_img, valid, context, name):
# img = fslimage.Image(new_img)
# overlayList.append(img)
# def _add_mask(new_img):
# img = fslimage.Image(new_img)
# overlayList.append(img, cmap='red', alpha=30)
# # bind events
# btn_fsleyes.Bind(wx.EVT_BUTTON, _launch_fsleyes)
# return panel
\ No newline at end of file
Supports Markdown
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