Skip to content

Commit effe1bf

Browse files
committed
Better error reporting if Xvfb is not installed.
1 parent ff1fc79 commit effe1bf

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

examples/smri_cbs_skullstripping.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
wf = pe.Workflow("skullstripping")
1212

1313
mask = pe.Node(JistIntensityMp2rageMasking(), name="masking")
14-
mask.inputs.inSecond = "/scr/adenauer1/7T_TRT/pilot/data/OK2T140312_093516.SEPT/nifti/S4_MP2RAGE_5_3_TR5000_iPAT=2_INV2.nii"
15-
mask.inputs.inQuantitative = "/scr/adenauer1/7T_TRT/pilot/data/OK2T140312_093516.SEPT/nifti/S7_MP2RAGE_5_3_TR5000_iPAT=2_UNI_Images.nii"
16-
mask.inputs.inT1weighted = "/scr/adenauer1/7T_TRT/pilot/data/OK2T140312_093516.SEPT/nifti/S6_MP2RAGE_5_3_TR5000_iPAT=2_T1_Images.nii"
14+
mask.inputs.inSecond = "/Users/filo/7t_trt/niftis/sub001/session_1/MP2RAGE_INV2.nii.gz"
15+
mask.inputs.inQuantitative = "/Users/filo/7t_trt/niftis/sub001/session_1/MP2RAGE_UNI.nii.gz"
16+
mask.inputs.inT1weighted = "/Users/filo/7t_trt/niftis/sub001/session_1/MP2RAGE_T1.nii.gz"
1717
mask.inputs.outMasked = True
1818
mask.inputs.outMasked2 = True
1919
mask.inputs.outSignal = True
2020
mask.inputs.outSignal2 = True
2121

2222
skullstrip = pe.Node(MedicAlgorithmSPECTRE2010(), name="skullstrip")
2323
skullstrip.inputs.outStripped = True
24-
skullstrip.inputs.maxMemoryUsage = 6000
24+
skullstrip.inputs.xDefaultMem = 6000
2525

2626
wf.connect(mask, 'outMasked', skullstrip, 'inInput')
2727
wf.run()

nipype/interfaces/base.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -978,16 +978,22 @@ def run(self, **inputs):
978978
version=self.version)
979979
try:
980980
if self._redirect_x:
981-
vdisplay_num = _search_for_free_display()
982-
xvfb_cmd = ['Xvfb', ':%d' % vdisplay_num]
983-
xvfb_proc = subprocess.Popen(xvfb_cmd,
984-
stdout=open(os.devnull),
985-
stderr=open(os.devnull))
986-
time.sleep(0.2) # give Xvfb time to start
987-
if xvfb_proc.poll() is not None:
988-
raise Exception('Error: Xvfb did not start')
989-
old_displaynum = os.environ['DISPLAY']
990-
runtime.environ['DISPLAY'] = ':%s' % vdisplay_num
981+
exist_val, _ = self._exists_in_path('Xvfb',
982+
runtime.environ)
983+
if not exist_val:
984+
raise IOError("Xvfb could not be found on host %s" %
985+
(runtime.hostname))
986+
else:
987+
vdisplay_num = _search_for_free_display()
988+
xvfb_cmd = ['Xvfb', ':%d' % vdisplay_num]
989+
xvfb_proc = subprocess.Popen(xvfb_cmd,
990+
stdout=open(os.devnull),
991+
stderr=open(os.devnull))
992+
time.sleep(0.2) # give Xvfb time to start
993+
if xvfb_proc.poll() is not None:
994+
raise Exception('Error: Xvfb did not start')
995+
old_displaynum = os.environ['DISPLAY']
996+
runtime.environ['DISPLAY'] = ':%s' % vdisplay_num
991997

992998
runtime = self._run_interface(runtime)
993999

0 commit comments

Comments
 (0)