コード例 #1
0
ファイル: labels_panel.py プロジェクト: waffle-iron/mmvt
def _load_labels_data(labels_data_fname):
    labels_data_type = mu.file_type(labels_data_fname)
    if labels_data_type == 'npz':
        d = mu.load_npz_to_bag(labels_data_fname)
    elif labels_data_type == 'mat':
        d = mu.load_mat_to_bag(labels_data_fname)
        d.names = mu.matlab_cell_str_to_list(d.names)
        d.atlas = d.atlas[0] if not isinstance(d.atlas, str) else d.atlas
        #d.cmap = d.cmap[0] if not isinstance(d.cmap, str) else d.cmap
    else:
        print('Currently we support only mat and npz files')
        return False
    labels, data = d.names, d.data
    if 'atlas' not in d:
        atlas = mu.check_atlas_by_labels_names(labels)
        if atlas == '':
            print('The labeling file must contains an atlas field!')
            return False
    else:
        atlas = str(d.atlas)
    LabelsPanel.labels_data_atlas = atlas
    labels = [l.replace('.label', '') for l in labels]
    cb_title = str(d.get('title', ''))
    labels_min = d.get('data_min', np.min(data))
    labels_max = d.get('data_max', np.max(data))
    cmap = str(d.get('cmap', None))
    return d, labels, data, atlas, cb_title, labels_max, labels_min, cmap
コード例 #2
0
ファイル: labels_panel.py プロジェクト: alexrockhill/mmvt
def _load_labels_data(labels_data_fname):
    labels_data_type = mu.file_type(labels_data_fname)
    if labels_data_type == 'npz':
        d = mu.load_npz_to_bag(labels_data_fname)
    elif labels_data_type == 'mat':
        d = mu.load_mat_to_bag(labels_data_fname)
        d.names = mu.matlab_cell_str_to_list(d.names)
        d.atlas = d.atlas[0] if not isinstance(d.atlas, str) else d.atlas
        #d.cmap = d.cmap[0] if not isinstance(d.cmap, str) else d.cmap
    else:
        print('Currently we support only mat and npz files')
        return False
    labels, data = d.names, d.data
    if len(labels) == 0:
        return False
    if isinstance(labels[0], mne.Label):
        labels = [l.name for l in labels]
    if data.ndim == 2:
        if data.shape[0] == len(labels):
            data = data[:, bpy.context.scene.frame_current]
        elif data.shape[1] == len(labels):
            data = data[bpy.context.scene.frame_current]
        else:
            data = data.mean(
                axis=1) if data.shape[0] == len(labels) else data.mean(axis=0)
    if 'atlas' not in d:
        atlas = mu.check_atlas_by_labels_names(labels)
        if atlas == '':
            print('The labeling file must contains an atlas field!')
            return False
    else:
        atlas = str(d.atlas)
    LabelsPanel.atlas_in_annot_files = atlas in _addon(
    ).where_am_i.get_annot_files()
    LabelsPanel.labels_data_atlas = atlas
    labels = [l.replace('.label', '') for l in labels]
    cb_title = str(d.get('title', ''))
    labels_min = d.get('data_min', np.min(data))
    labels_max = d.get('data_max', np.max(data))
    cmap = str(d.get('cmap', None))
    return d, labels, data, atlas, cb_title, labels_max, labels_min, cmap