Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
mcraig-ibme committed Jun 20, 2017
2 parents 66d87c3 + 7104cc2 commit 8f22999
Showing 1 changed file with 84 additions and 65 deletions.
149 changes: 84 additions & 65 deletions asl.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,20 @@ def get_run_sequence(self):
cmd.add("--sliceband %i" % self.input.slices_per_band())

# Distortion correction
if self.analysis.distcorr():
if self.analysis.distcorr_type() == 0:
if self.distcorr.distcorr():
if self.distcorr.distcorr_type() == 0:
# Fieldmap
self.check_exists("Fieldmap image", self.analysis.fmap())
cmd.add('--fmap="%s"' % self.analysis.fmap())
self.check_exists("Fieldmap magnitude image", self.analysis.fmap_mag())
if self.analysis.fmap_be():
cmd.add('--fmapmagbrain="%s"' % self.analysis.fmap_mag())
self.check_exists("Fieldmap image", self.distcorr.fmap())
cmd.add('--fmap="%s"' % self.distcorr.fmap())
self.check_exists("Fieldmap magnitude image", self.distcorr.fmap_mag())
if self.distcorr.fmap_be():
cmd.add('--fmapmagbrain="%s"' % self.distcorr.fmap_mag())
else:
cmd.add('--fmapmag="%s"' % self.analysis.fmap_mag())
cmd.add('--fmapmag="%s"' % self.distcorr.fmap_mag())
else:
if self.analysis.cblip(): cmd.add("--cblip")
cmd.add("--echospacing=%.5f" % self.analysis.echosp())
cmd.add("--pedir=%s" % self.analysis.pedir())
if self.distcorr.cblip(): cmd.add("--cblip")
cmd.add("--echospacing=%.5f" % self.distcorr.echosp())
cmd.add("--pedir=%s" % self.distcorr.pedir())

# Calibration - do this via oxford_asl rather than calling asl_calib separately
if self.calibration.calib():
Expand Down Expand Up @@ -641,7 +641,7 @@ def ref_tissue_type_changed(self, event):
self.update()

def calib_changed(self, event):
self.analysis.calib_changed(self.calib())
self.distcorr.calib_changed(self.calib())
self.update()

def wp_changed(self, wp):
Expand All @@ -667,6 +667,76 @@ def update(self, event=None):
self.ref_t2_num.Enable(enable and self.calib_mode() == 0)
TabPage.update(self)

class AslDistCorr(TabPage):
"""
Tab page containing distortion correction options
"""

def __init__(self, parent):
TabPage.__init__(self, parent, "Distortion Correction", "distcorr")

self.distcorr_choices = ["Fieldmap", "Calibration image"]

self.section("Distortion Correction")

self.distcorr_cb = wx.CheckBox(self, label="Apply distortion correction")
self.distcorr_cb.Bind(wx.EVT_CHECKBOX, self.update)
self.distcorr_ch = wx.Choice(self, choices=self.distcorr_choices[:1])
self.distcorr_ch.SetSelection(0)
self.distcorr_ch.Bind(wx.EVT_CHOICE, self.update)
self.pack("", self.distcorr_cb, self.distcorr_ch, enable=False)

self.echosp_num = self.number("Effective EPI echo spacing", min=0, max=10)
self.pedir_ch = self.choice("Phase encoding direction", choices=["x", "y", "z", "-x", "-y", "-z"])

# Fieldmap options
self.fmap_picker = self.file_picker("Fieldmap image (in rad/s)")
self.fmap_mag_picker = self.file_picker("Fieldmap magnitude image")
self.fmap_mag_be_cb = self.checkbox("Magnitude image is brain extracted")

# Calibration image options
self.cblip_cb = self.checkbox("Phase-encode-reversed calibration image")

self.sizer.AddGrowableCol(1, 1)
#sizer.AddGrowableRow(5, 1)
self.SetSizer(self.sizer)

def distcorr(self): return self.distcorr_cb.IsChecked()
def distcorr_type(self): return self.distcorr_ch.GetSelection()
def fmap(self): return self.fmap_picker.GetPath()
def fmap_mag(self): return self.fmap_mag_picker.GetPath()
def fmap_mag_be(self): return self.fmap_mag_be_cb.IsChecked()
def echosp(self): return self.echosp_num.GetValue()
def pedir(self): return self.pedir_ch.GetStringSelection()
def cblip(self): return self.cblip_cb.IsChecked()

def update(self, event=None):
self.distcorr_ch.Enable(self.distcorr())
self.pedir_ch.Enable(self.distcorr())
self.echosp_num.Enable(self.distcorr())
fmap = self.distcorr() and self.distcorr_type() == 0
cal = self.distcorr() and self.distcorr_type() == 1
self.fmap_picker.Enable(fmap)
self.fmap_mag_picker.Enable(fmap)
self.fmap_mag_be_cb.Enable(fmap)
self.cblip_cb.Enable(cal)
TabPage.update(self)

def calib_changed(self, enabled):
""" If calibration enabled, add the calibration image option for distortion correction"""
sel = self.distcorr_ch.GetSelection()
if enabled:
choices = self.distcorr_choices
sel = 1
else:
choices = self.distcorr_choices[:1]
sel = 0
self.distcorr_ch.Enable(False)
self.distcorr_ch.Clear()
self.distcorr_ch.AppendItems(choices)
self.distcorr_ch.SetSelection(sel)
self.update()

class AslAnalysis(TabPage):
"""
Tab page containing data analysis options
Expand Down Expand Up @@ -713,26 +783,6 @@ def __init__(self, parent):
self.pv_cb = self.checkbox("Partial Volume Correction")
self.mc_cb = self.checkbox("Motion Correction (MCFLIRT)")

self.section("Distortion Correction")

self.distcorr_cb = wx.CheckBox(self, label="Apply distortion correction")
self.distcorr_cb.Bind(wx.EVT_CHECKBOX, self.update)
self.distcorr_ch = wx.Choice(self, choices=self.distcorr_choices[:1])
self.distcorr_ch.SetSelection(0)
self.distcorr_ch.Bind(wx.EVT_CHOICE, self.update)
self.pack("", self.distcorr_cb, self.distcorr_ch, enable=False)

self.echosp_num = self.number("Effective EPI echo spacing", min=0, max=10)
self.pedir_ch = self.choice("Phase encoding direction", choices=["x", "y", "z", "-x", "-y", "-z"])

# Fieldmap options
self.fmap_picker = self.file_picker("Fieldmap image (in rad/s)")
self.fmap_mag_picker = self.file_picker("Fieldmap magnitude image")
self.fmap_mag_be_cb = self.checkbox("Magnitude image is brain extracted")

# Calibration image options
self.cblip_cb = self.checkbox("Phase-encode-reversed calibration image")

self.sizer.AddGrowableCol(1, 1)
#sizer.AddGrowableRow(5, 1)
self.SetSizer(self.sizer)
Expand All @@ -755,30 +805,13 @@ def macro(self): return self.macro_cb.IsChecked()
def fixbolus(self): return self.fixbolus_cb.IsChecked()
def pv(self): return self.pv_cb.IsChecked()
def mc(self): return self.mc_cb.IsChecked()
def distcorr(self): return self.distcorr_cb.IsChecked()
def distcorr_type(self): return self.distcorr_ch.GetSelection()
def fmap(self): return self.fmap_picker.GetPath()
def fmap_mag(self): return self.fmap_mag_picker.GetPath()
def fmap_mag_be(self): return self.fmap_mag_be_cb.IsChecked()
def echosp(self): return self.echosp_num.GetValue()
def pedir(self): return self.pedir_ch.GetStringSelection()
def cblip(self): return self.cblip_cb.IsChecked()

def update(self, event=None):
self.transform_ch.Enable(self.transform())
self.transform_picker.Enable(self.transform() and self.transform_type() != 2)
self.mask_picker.Enable(self.mask_picker.checkbox.IsChecked())
self.t1_num.Enable(not self.wp())
self.bat_num.Enable(not self.wp())
self.distcorr_ch.Enable(self.distcorr())
self.pedir_ch.Enable(self.distcorr())
self.echosp_num.Enable(self.distcorr())
fmap = self.distcorr() and self.distcorr_type() == 0
cal = self.distcorr() and self.distcorr_type() == 1
self.fmap_picker.Enable(fmap)
self.fmap_mag_picker.Enable(fmap)
self.fmap_mag_be_cb.Enable(fmap)
self.cblip_cb.Enable(cal)
TabPage.update(self)

def wp_changed(self, event):
Expand All @@ -798,21 +831,6 @@ def labelling_changed(self, pasl):
else:
self.bat_num.SetValue(1.3)
self.ie_num.SetValue(0.85)

def calib_changed(self, enabled):
""" If calibration enabled, add the calibration image option for distortion correction"""
sel = self.distcorr_ch.GetSelection()
if enabled:
choices = self.distcorr_choices
sel = 1
else:
choices = self.distcorr_choices[:1]
sel = 0
self.distcorr_ch.Enable(False)
self.distcorr_ch.Clear()
self.distcorr_ch.AppendItems(choices)
self.distcorr_ch.SetSelection(sel)
self.update()

def fsl_anat_changed(self, enabled):
""" If FSL_ANAT is selected, use it by default, otherwise do not allow it """
Expand Down Expand Up @@ -1254,7 +1272,7 @@ class AslGui(wx.Frame):
"""

def __init__(self):
wx.Frame.__init__(self, None, title="Basil", size=(1200, 950), style=wx.DEFAULT_FRAME_STYLE)
wx.Frame.__init__(self, None, title="Basil", size=(1200, 750), style=wx.DEFAULT_FRAME_STYLE)
#wx.Frame.__init__(self, None, title="Basil", size=(1200, 700), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)
main_panel = wx.Panel(self)
main_vsizer = wx.BoxSizer(wx.VERTICAL)
Expand Down Expand Up @@ -1290,6 +1308,7 @@ def __init__(self):
setattr(self.run, "preview", self.preview)
tabs = [AslInputOptions(notebook),
AslAnalysis(notebook),
AslDistCorr(notebook),
AslCalibration(notebook)]

for tab in tabs:
Expand Down

0 comments on commit 8f22999

Please sign in to comment.