def display_viewer_syntax(files, colormaps=[], minmax=[], opacities=[], mode='', verbose=1): """ Print the syntax to open a viewer and display images for QC. To use default values, enter empty string: '' Parameters ---------- files [list:string]: list of NIFTI file names colormaps [list:string]: list of colormaps associated with each file. Available colour maps: see dict_fsleyes minmax [list:string]: list of min,max brightness scale associated with each file. Separate with comma. opacities [list:string]: list of opacity associated with each file. Between 0 and 1. Returns ------- None Example ------- sct.display_viewer_syntax([file1, file2, file3]) sct.display_viewer_syntax([file1, file2], colormaps=['gray', 'red'], minmax=['', '0,1'], opacities=['', '0.7']) """ list_viewer = ['fsleyes', 'fslview_deprecated', 'fslview'] # list of known viewers. Can add more. dict_fslview = { 'gray': 'Greyscale', 'red-yellow': 'Red-Yellow', 'blue-lightblue': 'Blue-Lightblue', 'red': 'Red', 'green': 'Green', 'random': 'Random-Rainbow', 'hsv': 'hsv', 'subcortical': 'MGH-Subcortical' } dict_fsleyes = { 'gray': 'greyscale', 'red-yellow': 'red-yellow', 'blue-lightblue': 'blue-lightblue', 'red': 'red', 'green': 'green', 'random': 'random', 'hsv': 'hsv', 'subcortical': 'subcortical' } selected_viewer = None # find viewer exe_viewers = [viewer for viewer in list_viewer if check_exe(viewer)] if exe_viewers: selected_viewer = exe_viewers[0] else: return # loop across files and build syntax cmd = selected_viewer # add mode (only supported by fslview for the moment) if mode and selected_viewer in ['fslview', 'fslview_deprecated']: cmd += ' -m ' + mode for i in range(len(files)): # add viewer-specific options if selected_viewer in ['fslview', 'fslview_deprecated']: cmd += ' ' + files[i] if colormaps: if colormaps[i]: cmd += ' -l ' + dict_fslview[colormaps[i]] if minmax: if minmax[i]: cmd += ' -b ' + minmax[i] # a,b if opacities: if opacities[i]: cmd += ' -t ' + opacities[i] if selected_viewer in ['fsleyes']: cmd += ' ' + files[i] if colormaps: if colormaps[i]: cmd += ' -cm ' + dict_fsleyes[colormaps[i]] if minmax: if minmax[i]: cmd += ' -dr ' + ' '.join(minmax[i].split(',')) # a b if opacities: if opacities[i]: cmd += ' -a ' + str( float(opacities[i]) * 100) # in percentage cmd += ' &' # display if verbose: printv('\nDone! To view results, type:') printv(cmd + '\n', verbose=1, type='info')
def display_viewer_syntax(files, colormaps=[], minmax=[], opacities=[], mode='', verbose=1): """ Print the syntax to open a viewer and display images for QC. To use default values, enter empty string: '' Parameters ---------- files [list:string]: list of NIFTI file names colormaps [list:string]: list of colormaps associated with each file. Available colour maps: see dict_fsleyes minmax [list:string]: list of min,max brightness scale associated with each file. Separate with comma. opacities [list:string]: list of opacity associated with each file. Between 0 and 1. Returns ------- None Example ------- sct.display_viewer_syntax([file1, file2, file3]) sct.display_viewer_syntax([file1, file2], colormaps=['gray', 'red'], minmax=['', '0,1'], opacities=['', '0.7']) """ list_viewer = ['fsleyes', 'fslview_deprecated', 'fslview'] # list of known viewers. Can add more. dict_fslview = {'gray': 'Greyscale', 'red-yellow': 'Red-Yellow', 'blue-lightblue': 'Blue-Lightblue', 'red': 'Red', 'green': 'Green', 'random': 'Random-Rainbow', 'hsv': 'hsv', 'subcortical': 'MGH-Subcortical'} dict_fsleyes = {'gray': 'greyscale', 'red-yellow': 'red-yellow', 'blue-lightblue': 'blue-lightblue', 'red': 'red', 'green': 'green', 'random': 'random', 'hsv': 'hsv', 'subcortical': 'subcortical'} selected_viewer = None # find viewer exe_viewers = [viewer for viewer in list_viewer if check_exe(viewer)] if exe_viewers: selected_viewer = exe_viewers[0] else: return # loop across files and build syntax cmd = selected_viewer # add mode (only supported by fslview for the moment) if mode and selected_viewer in ['fslview', 'fslview_deprecated']: cmd += ' -m ' + mode for i in range(len(files)): # add viewer-specific options if selected_viewer in ['fslview', 'fslview_deprecated']: cmd += ' ' + files[i] if colormaps: if colormaps[i]: cmd += ' -l ' + dict_fslview[colormaps[i]] if minmax: if minmax[i]: cmd += ' -b ' + minmax[i] # a,b if opacities: if opacities[i]: cmd += ' -t ' + opacities[i] if selected_viewer in ['fsleyes']: cmd += ' ' + files[i] if colormaps: if colormaps[i]: cmd += ' -cm ' + dict_fsleyes[colormaps[i]] if minmax: if minmax[i]: cmd += ' -dr ' + ' '.join(minmax[i].split(',')) # a b if opacities: if opacities[i]: cmd += ' -a ' + str(float(opacities[i]) * 100) # in percentage cmd += ' &' # display if verbose: printv('\nDone! To view results, type:') printv(cmd + '\n', verbose=1, type='info')