def save_electrodes_group_ct_pics(subject, voxels, group_name='', electrodes_names='', pixels_around_voxel=30): states = {} for modality in ['mri', 'ct']: states[modality] = slicer.init(None, modality=modality, subject=subject, mmvt_dir=MMVT_DIR) if electrodes_names == '': electrodes_names = [''] * len(voxels) elif group_name == '': group_name = '{}-{}'.format(electrodes_names[0], electrodes_names[-1]) if group_name == '': print("Both group_name and electrodes_names can't be empty!") return False fol = utils.make_dir( op.join(MMVT_DIR, subject, 'ct', 'figures', group_name)) ret = True for ind, (voxel, elc_name) in enumerate(zip(voxels, electrodes_names)): elc_name = voxel if elc_name == '' else elc_name fig_fname = op.join( fol, '{}_{}_{}.jpg'.format(ind, elc_name, pixels_around_voxel)) ret = ret and save_electrode_ct_pics( subject, voxel, elc_name, pixels_around_voxel, False, states, fig_fname) return ret
def save_electrode_ct_pics(subject, voxel, elc_name='', pixels_around_voxel=30, interactive=True, states=None, fig_fname=''): fol = utils.make_dir(op.join(MMVT_DIR, subject, 'ct', 'figures')) if fig_fname == '' and not interactive: fig_fname = op.join(fol, '{}_{}.jpg'.format(voxel, pixels_around_voxel)) if states is None: states = {} for modality in ['mri', 'ct']: states[modality] = slicer.init(None, modality=modality, subject=subject, mmvt_dir=MMVT_DIR) slicer.plot_slices(None, voxel, states, 'ct', interactive, pixels_around_voxel, fig_fname=fig_fname, elc_name=elc_name) if fig_fname != '': return op.isfile(fig_fname) else: return True