示例#1
0
def filter_draw(self, context):
    layout = self.layout
    layout.prop(context.scene, "filter_topK", text="Top K")
    row = layout.row(align=0)
    row.prop(context.scene, "filter_from", text="From")
    row.operator(GrabFromFiltering.bl_idname, text="", icon='BORDERMOVE')
    row.prop(context.scene, "filter_to", text="To")
    row.operator(GrabToFiltering.bl_idname, text="", icon='BORDERMOVE')
    layout.prop(context.scene, "filter_curves_type", text="")
    layout.prop(context.scene, "filter_curves_func", text="")
    layout.prop(context.scene, 'mark_filter_items', text="Mark selected items")
    layout.operator(Filtering.bl_idname, text="Filter " + bpy.context.scene.filter_curves_type, icon='BORDERMOVE')
    # if bpy.types.Scene.filter_is_on:
    layout.operator(ClearFiltering.bl_idname, text="Clear Filtering", icon='PANEL_CLOSE')
    col = layout.column(align=0)
    col.operator(FindCurveClosestToCursor.bl_idname, text="closest curve to cursor", icon='SNAP_SURFACE')
    if bpy.types.Scene.closest_curve_str != '':
        col.label(text=bpy.types.Scene.closest_curve_str)
    layout.prop(context.scene, 'filter_items_one_by_one', text="Show one by one")
    if bpy.context.scene.filter_items_one_by_one:
        row = layout.row(align=0)
        row.operator(PrevFilterItem.bl_idname, text="", icon='PREV_KEYFRAME')
        row.prop(context.scene, 'filter_items', text="")
        row.operator(NextFilterItem.bl_idname, text="", icon='NEXT_KEYFRAME')
    if len(Filtering.objects_indices) > 0:
        box = layout.box()
        col = box.column()
        for ind in Filtering.objects_indices:
            mu.add_box_line(col, Filtering.filter_objects[ind], '{:.2f}'.format(Filtering.filter_values[ind]), 0.8)
    row = layout.row(align=True)
    row.prop(context.scene, "filter_fcurves", text="Filter curves")
    row.operator(ResetCurvesFilter.bl_idname, text="", icon='PANEL_CLOSE')
示例#2
0
 def draw(self, context):
     layout = self.layout
     layout.prop(context.scene, "labels_regex", text="Object name")
     row = layout.row(align=0)
     row.operator(SearchFilter.bl_idname, text="Search", icon = 'BORDERMOVE')
     row.operator(SearchMark.bl_idname, text="Mark", icon = 'GREASEPENCIL')
     layout.operator(SearchClear.bl_idname, text="Clear", icon = 'PANEL_CLOSE')
     if len(SearchPanel.marked_objects) > 0:
         box = layout.box()
         col = box.column()
         for obj_name in SearchPanel.marked_objects:
             mu.add_box_line(col, obj_name, percentage=1)
         row = layout.row(align=0)
         row.operator(SearchExport.bl_idname, text="Export list", icon = 'FORCE_LENNARDJONES')
示例#3
0
 def draw(self, context):
     layout = self.layout
     row = layout.row(align=0)
     row.prop(context.scene, "labels_regex", text="")
     # row.prop(context.scene, "search_plot_contour", text="Plot contour")
     # row = layout.row(align=0)
     layout.operator(SearchFilter.bl_idname, text="Search", icon='BORDERMOVE')
     # row.operator(SearchMark.bl_idname, text="Mark", icon = 'GREASEPENCIL')
     if len(SearchPanel.marked_objects) > 0:
         box = layout.box()
         col = box.column()
         for obj_name in SearchPanel.marked_objects:
             mu.add_box_line(col, obj_name, percentage=1)
     layout.operator(SearchClear.bl_idname, text="Clear", icon='PANEL_CLOSE')
示例#4
0
 def draw(self, context):
     layout = self.layout
     layout.prop(context.scene, "labels_regex", text="regex")
     row = layout.row(align=0)
     row.operator(SearchFilter.bl_idname, text="Search", icon='BORDERMOVE')
     row.operator(SearchMark.bl_idname, text="Mark", icon='GREASEPENCIL')
     layout.operator(SearchClear.bl_idname,
                     text="Clear",
                     icon='PANEL_CLOSE')
     if len(SearchPanel.marked_objects) > 0:
         box = layout.box()
         col = box.column()
         for obj_name in SearchPanel.marked_objects:
             mu.add_box_line(col, obj_name, percentage=1)
         row = layout.row(align=0)
         row.operator(SearchExport.bl_idname,
                      text="Export list",
                      icon='FORCE_LENNARDJONES')
示例#5
0
def reports_draw(self, context):
    layout = self.layout
    missing_files = []
    layout.prop(context.scene, "reports_files", text="")
    row = layout.row(align=0)
    row.prop(context.scene, "reports_fields", text="")
    row.prop(context.scene, "reports_field_value", text="")
    if len(ReportsPanel.files[bpy.context.scene.reports_files]) > 0:
        missing_files = [file_name for file_name in ReportsPanel.files[bpy.context.scene.reports_files] if \
                         not op.isfile(op.join(_addon().get_output_path(), file_name))]
        if len(missing_files) > 0:
            layout.label('Missing files:')
            col = layout.box().column()
            for file_name in ReportsPanel.files[
                    bpy.context.scene.reports_files]:
                if not op.isfile(op.join(_addon().get_output_path(),
                                         file_name)):
                    mu.add_box_line(col, file_name, '', 1)
    if context.scene.report_use_script:
        layout.prop(context.scene, 'report_use_script', text='Use script')
    if len(missing_files) == 0 or context.scene.report_use_script:
        layout.operator(CreateReport.bl_idname,
                        text="Create report",
                        icon='STYLUS_PRESSURE')
示例#6
0
def fMRI_draw(self, context):
    layout = self.layout
    user_fol = mu.get_user_fol()
    # clusters_labels_files = glob.glob(op.join(user_fol, 'fmri', 'clusters_labels_*.npy'))
    # if len(clusters_labels_files) > 1:
    layout.prop(context.scene, 'fmri_clusters_labels_files', text='')
    if len(fMRIPanel.clusters_labels_files) > 1:
        layout.prop(context.scene, 'fmri_clusters_labels_parcs', text='')
    row = layout.row(align=True)
    row.operator(PrevCluster.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, 'fmri_clusters', text="")
    row.operator(NextCluster.bl_idname, text="", icon='NEXT_KEYFRAME')
    layout.prop(context.scene, 'fmri_show_filtering', text='Refine clusters')
    if bpy.context.scene.fmri_show_filtering:
        row = layout.row(align=True)
        row.prop(context.scene, 'fmri_clustering_threshold', text='Threshold')
        row.operator(RefinefMRIClusters.bl_idname, text="Find clusters", icon='GROUP_VERTEX')
        layout.prop(context.scene, 'fmri_cluster_val_threshold', text='clusters t-val threshold')
        layout.prop(context.scene, 'fmri_cluster_size_threshold', text='clusters size threshold')
        layout.operator(FilterfMRIBlobs.bl_idname, text="Filter blobs", icon='FILTER')
    layout.prop(context.scene, 'plot_current_cluster', text="Plot current cluster")
    row = layout.row(align=True)
    row.prop(context.scene, 'plot_fmri_cluster_contours', text="Plot cluster contours")
    row.prop(context.scene, 'fmri_cluster_contours_color', text="")
    layout.prop(context.scene, 'plot_fmri_cluster_per_click', text="Listen to left clicks")

    # layout.prop(context.scene, 'fmri_what_to_plot', expand=True)
    row = layout.row(align=True)
    row.label(text='Sort: ')
    row.prop(context.scene, 'fmri_how_to_sort', expand=True)
    if not fMRIPanel.cluster_labels is None and len(fMRIPanel.cluster_labels) > 0 and \
            not fMRIPanel.dont_show_clusters_info:
        if 'size' not in fMRIPanel.cluster_labels:
            fMRIPanel.cluster_labels['size'] = len(fMRIPanel.cluster_labels['vertices'])
        blob_size = fMRIPanel.cluster_labels['size']
        col = layout.box().column()
        mu.add_box_line(col, 'Max val', '{:.2f}'.format(fMRIPanel.cluster_labels['max']), 0.7)
        mu.add_box_line(col, 'Size', str(blob_size), 0.7)
        col = layout.box().column()
        labels_num_to_show = min(7, len(fMRIPanel.cluster_labels['intersects']))
        for inter_labels in fMRIPanel.cluster_labels['intersects'][:labels_num_to_show]:
            mu.add_box_line(col, inter_labels['name'], '{:.0%}'.format(inter_labels['num'] / float(blob_size)), 0.8)
        if labels_num_to_show < len(fMRIPanel.cluster_labels['intersects']):
            layout.label(text='Out of {} labels'.format(len(fMRIPanel.cluster_labels['intersects'])))
    # row = layout.row(align=True)
    layout.operator(PlotAllBlobs.bl_idname, text="Plot all blobs", icon='POTATO')
    # if _addon().is_pial(): # or _addon().get_inflated_ratio() == 1:
    layout.operator(NearestCluster.bl_idname, text="Nearest cluster", icon='MOD_SKIN')
    # layout.prop(context.scene, 'search_closest_cluster_only_in_filtered', text="Seach only in filtered blobs")
    # layout.operator(LoadMEGData.bl_idname, text="Save as functional ROIs", icon='IPO')
    # layout.prop(context.scene, 'fmri_blobs_norm_by_percentile', text="Norm by percentiles")
    # if bpy.context.scene.fmri_blobs_norm_by_percentile:
    #     layout.prop(context.scene, 'fmri_blobs_percentile_min', text="Percentile min")
    #     layout.prop(context.scene, 'fmri_blobs_percentile_max', text="Percentile max")
    # layout.operator(FindfMRIFilesMinMax.bl_idname, text="Calc minmax for all files", icon='IPO')
    layout.operator(fmriClearColors.bl_idname, text="Clear", icon='PANEL_CLOSE')
示例#7
0
def fMRI_draw(self, context):
    layout = self.layout
    user_fol = mu.get_user_fol()
    # clusters_labels_files = glob.glob(op.join(user_fol, 'fmri', 'clusters_labels_*.npy'))
    # if len(clusters_labels_files) > 1:
    layout.prop(context.scene, 'fmri_clusters_labels_files', text='')
    row = layout.row(align=True)
    row.prop(context.scene, 'fmri_clustering_threshold', text='Threshold')
    row.operator(RefinefMRIClusters.bl_idname, text="Find clusters", icon='GROUP_VERTEX')
    layout.prop(context.scene, 'fmri_cluster_val_threshold', text='clusters t-val threshold')
    layout.prop(context.scene, 'fmri_cluster_size_threshold', text='clusters size threshold')
    layout.operator(FilterfMRIBlobs.bl_idname, text="Filter blobs", icon='FILTER')
    row = layout.row(align=True)
    row.operator(PrevCluster.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, 'fmri_clusters', text="")
    row.operator(NextCluster.bl_idname, text="", icon='NEXT_KEYFRAME')
    layout.prop(context.scene, 'plot_current_cluster', text="Plot current cluster")
    # layout.prop(context.scene, 'fmri_what_to_plot', expand=True)
    row = layout.row(align=True)
    row.label(text='Sort: ')
    row.prop(context.scene, 'fmri_how_to_sort', expand=True)
    if not fMRIPanel.cluster_labels is None and len(fMRIPanel.cluster_labels) > 0:
        if 'size' not in fMRIPanel.cluster_labels:
            fMRIPanel.cluster_labels['size'] = len(fMRIPanel.cluster_labels['vertices'])
        blob_size = fMRIPanel.cluster_labels['size']
        col = layout.box().column()
        mu.add_box_line(col, 'Max val', '{:.2f}'.format(fMRIPanel.cluster_labels['max']), 0.7)
        mu.add_box_line(col, 'Size', str(blob_size), 0.7)
        col = layout.box().column()
        labels_num_to_show = min(7, len(fMRIPanel.cluster_labels['intersects']))
        for inter_labels in fMRIPanel.cluster_labels['intersects'][:labels_num_to_show]:
            mu.add_box_line(col, inter_labels['name'], '{:.0%}'.format(inter_labels['num'] / float(blob_size)), 0.8)
        if labels_num_to_show < len(fMRIPanel.cluster_labels['intersects']):
            layout.label(text='Out of {} labels'.format(len(fMRIPanel.cluster_labels['intersects'])))
    # row = layout.row(align=True)
    layout.operator(PlotAllBlobs.bl_idname, text="Plot all blobs", icon='POTATO')
    layout.operator(NearestCluster.bl_idname, text="Nearest cluster", icon='MOD_SKIN')
    layout.prop(context.scene, 'search_closest_cluster_only_in_filtered', text="Seach only in filtered blobs")
    layout.operator(LoadMEGData.bl_idname, text="Save as functional ROIs", icon='IPO')
示例#8
0
def elecs_draw(self, context):
    layout = self.layout
    box = layout.box()
    if ElecsPanel.electrodes_labeling_file_exist and len(ElecsPanel.labling_files) > 1:
        box.prop(context.scene, "electrodes_labeling_files", text="")
    if ElecsPanel.electrodes_labeling_file_exist and len(ElecsPanel.labling_files) > 0:
        box.label(text='Model: {}'.format(context.scene.electrodes_labeling_files.split('_')[1]))
    row = box.row(align=True)
    row.operator(PrevLead.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "leads", text="")
    row.operator(NextLead.bl_idname, text="", icon='NEXT_KEYFRAME')
    row = box.row(align=True)
    row.operator(PrevElectrode.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "electrodes", text="")
    row.operator(NextElectrode.bl_idname, text="", icon='NEXT_KEYFRAME')

    if len(ElecsPanel.subcortical_rois) > 0 or len(ElecsPanel.cortical_rois) > 0:
        # box = layout.box()
        col = box.column()
        for subcortical_name, subcortical_prob in zip(ElecsPanel.subcortical_rois, ElecsPanel.subcortical_probs):
            mu.add_box_line(col, subcortical_name, '{:.3f}'.format(subcortical_prob), 0.8)
        for cortical_name, cortical_prob in zip(ElecsPanel.cortical_rois, ElecsPanel.cortical_probs):
            if cortical_prob >= 0.001:
                mu.add_box_line(col, cortical_name, '{:.3f}'.format(cortical_prob), 0.8)

        # box = layout.box()
        # box.prop(context.scene, "electrodes_hemis", text="")
        # box.prop(context.scene, "electrodes_hemi_labels", text="")

    if bpy.context.scene.electrodes_more_settings:
        layout.prop(context.scene, 'show_electrodes_labels', text="Show labels")
        layout.prop(context.scene, 'show_only_lead', text="Show only the current lead")
        # row = layout.row(align=True)
        if ElecsPanel.electrodes_labeling_file_exist:
            layout.prop(context.scene, 'color_lables', text="Color probabilities")
            # row.prop(context.scene, 'electrodes_label_contours', text="Color contours")
        # layout.label(text='What to color: ')
        # if bpy.context.scene.color_lables:
        #     layout.prop(context.scene, 'electrodes_what_to_color', text='What to color', expand=True)
        if ElecsPanel.groups_hemi:
            row = layout.row(align=True)
            row.prop(context.scene, "show_lh_electrodes", text="Left hemi")
            row.prop(context.scene, "show_rh_electrodes", text="Right hemi")
        if ElecsPanel.electrodes_labeling_file_exist:
            layout.prop(context.scene, "electrode_rotate", text="Rotate view on click")

        row = layout.row(align=True)
        row.prop(context.scene, "show_electrodes_groups_leads", text="Show leads")
        leads_obj = bpy.data.objects.get('leads', None)
        if leads_obj is None or len(leads_obj.children) == 0:
            row.prop(context.scene, "electrodes_create_curved_leads", text="Curved")
        # row.prop(context.scene, "electrodes_leads_color", text='')

        if ElecsPanel.ela_code_exist and ElecsPanel.atlases_exist:
            layout.prop(context.scene, "show_ela", text="Show ELA options")
            if bpy.context.scene.show_ela:
                col = layout.box().column()
                col.prop(context.scene, "ela_bipolar", text="Bipolar")
                col.prop(context.scene, "ela_atlas", text='')
                col.operator(RunELA.bl_idname, text="Calc electrodes probs", icon='TEXTURE')

        row = layout.row(align=True)
        if not bpy.context.scene.listen_to_keyboard:
            layout.operator(KeyboardListener.bl_idname, text="Listen to keyboard", icon='COLOR_GREEN')
        else:
            layout.operator(KeyboardListener.bl_idname, text="Stop listen to keyboard", icon='COLOR_RED')
            box = layout.box()
            col = box.column()
            mu.add_box_line(col, 'Left', 'Previous electrodes')
            mu.add_box_line(col, 'Right', 'Next electrodes')
            mu.add_box_line(col, 'Down', 'Previous lead')
            mu.add_box_line(col, 'Up', 'Next lead')
        row.operator(ColorElectrodes.bl_idname, text="Color electrodes")
        row.prop(context.scene, "electrodes_color_only_selected", text='Only selected')
        row.prop(context.scene, 'electrodes_color', text='')
        layout.operator(ExportElectrodes.bl_idname, text="Export", icon='EXPORT')
        layout.prop(context.scene, "elc_size", text="size")
        layout.operator(DeleteElectrodes.bl_idname, text="Delete electrodes", icon='CANCEL')

    layout.operator(ClearElectrodes.bl_idname, text="Clear", icon='PANEL_CLOSE')
    layout.prop(context.scene, 'electrodes_more_settings', text='More settings')
示例#9
0
def elecs_draw(self, context):
    layout = self.layout
    if ElecsPanel.electrodes_labeling_file_exist:
        layout.prop(context.scene, "electrodes_labeling_files", text="")
    row = layout.row(align=True)
    row.operator(PrevLead.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "leads", text="")
    row.operator(NextLead.bl_idname, text="", icon='NEXT_KEYFRAME')
    row = layout.row(align=True)
    row.operator(PrevElectrode.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "electrodes", text="")
    row.operator(NextElectrode.bl_idname, text="", icon='NEXT_KEYFRAME')
    layout.prop(context.scene,
                'show_only_lead',
                text="Show only the current lead")
    row = layout.row(align=True)
    if ElecsPanel.electrodes_labeling_file_exist:
        row.prop(context.scene, 'color_lables', text="Color lables")
        row.prop(context.scene,
                 'electrodes_label_contours',
                 text="Color contours")
    # layout.label(text='What to color: ')
    # if bpy.context.scene.color_lables:
    #     layout.prop(context.scene, 'electrodes_what_to_color', text='What to color', expand=True)
    row = layout.row(align=True)
    row.prop(context.scene, "show_lh_electrodes", text="Left hemi")
    row.prop(context.scene, "show_rh_electrodes", text="Right hemi")
    row = layout.row(align=True)
    row.operator(ColorElectrodes.bl_idname, text="Color electrodes")
    row.prop(context.scene, 'electrodes_color', text='')

    if not bpy.context.scene.listen_to_keyboard:
        layout.operator(KeyboardListener.bl_idname,
                        text="Listen to keyboard",
                        icon='COLOR_GREEN')
    else:
        layout.operator(KeyboardListener.bl_idname,
                        text="Stop listen to keyboard",
                        icon='COLOR_RED')
        box = layout.box()
        col = box.column()
        mu.add_box_line(col, 'Left', 'Previous electrodes')
        mu.add_box_line(col, 'Right', 'Next electrodes')
        mu.add_box_line(col, 'Down', 'Previous lead')
        mu.add_box_line(col, 'Up', 'Next lead')
    if len(ElecsPanel.subcortical_rois) > 0 or len(
            ElecsPanel.cortical_rois) > 0:
        box = layout.box()
        col = box.column()
        for subcortical_name, subcortical_prob in zip(
                ElecsPanel.subcortical_rois, ElecsPanel.subcortical_probs):
            mu.add_box_line(col, subcortical_name,
                            '{:.2f}'.format(subcortical_prob), 0.8)
        for cortical_name, cortical_prob in zip(ElecsPanel.cortical_rois,
                                                ElecsPanel.cortical_probs):
            mu.add_box_line(col, cortical_name, '{:.2f}'.format(cortical_prob),
                            0.8)
    layout.prop(context.scene, "elc_size", text="")
    layout.operator(ClearElectrodes.bl_idname,
                    text="Clear",
                    icon='PANEL_CLOSE')
    layout.operator(ExportElectrodes.bl_idname, text="Export", icon='EXPORT')
    row = layout.row(align=True)
    row.prop(context.scene, "show_electrodes_groups_leads", text="Show leads")
    row.prop(context.scene, "electrodes_leads_color")
示例#10
0
def elecs_draw(self, context):
    layout = self.layout
    layout.prop(context.scene, "electrodes_labeling_files", text="")
    row = layout.row(align=True)
    row.operator(PrevLead.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "leads", text="")
    row.operator(NextLead.bl_idname, text="", icon='NEXT_KEYFRAME')
    row = layout.row(align=True)
    row.operator(PrevElectrode.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, "electrodes", text="")
    row.operator(NextElectrode.bl_idname, text="", icon='NEXT_KEYFRAME')
    layout.prop(context.scene, 'show_only_lead', text="Show only the current lead")
    layout.prop(context.scene, 'color_lables', text="Color the relevant lables")
    # layout.label(text='What to color: ')
    if bpy.context.scene.color_lables:
        layout.prop(context.scene, 'electrodes_what_to_color', text='What to color', expand=True)
    row = layout.row(align=True)
    row.prop(context.scene, "show_lh_electrodes", text="Left hemi")
    row.prop(context.scene, "show_rh_electrodes", text="Right hemi")

    if not bpy.context.scene.listen_to_keyboard:
        layout.operator(KeyboardListener.bl_idname, text="Listen to keyboard", icon='COLOR_GREEN')
    else:
        layout.operator(KeyboardListener.bl_idname, text="Stop listen to keyboard", icon='COLOR_RED')
        box = layout.box()
        col = box.column()
        mu.add_box_line(col, 'Left', 'Previous electrodes')
        mu.add_box_line(col, 'Right', 'Next electrodes')
        mu.add_box_line(col, 'Down', 'Previous lead')
        mu.add_box_line(col, 'Up', 'Next lead')
    if len(ElecsPanel.subcortical_rois) > 0 or len(ElecsPanel.cortical_rois) > 0:
        box = layout.box()
        col = box.column()
        for subcortical_name, subcortical_prob in zip(ElecsPanel.subcortical_rois, ElecsPanel.subcortical_probs):
            mu.add_box_line(col, subcortical_name, '{:.2f}'.format(subcortical_prob), 0.8)
        for cortical_name, cortical_prob in zip(ElecsPanel.cortical_rois, ElecsPanel.cortical_probs):
            mu.add_box_line(col, cortical_name, '{:.2f}'.format(cortical_prob), 0.8)
    layout.operator(ClearElectrodes.bl_idname, text="Clear", icon='PANEL_CLOSE')
示例#11
0
def meg_draw(self, context):
    layout = self.layout
    layout.prop(context.scene, 'meg_clusters_labels_files', text='')
    if MNE_EXIST:
        layout.operator(PlotMEGClusters.bl_idname,
                        text='Plot STC',
                        icon='POTATO')
    row = layout.row(align=True)
    row.operator(PrevMEGCluster.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, 'meg_clusters', text='')
    row.operator(NextMEGCluster.bl_idname, text="", icon='NEXT_KEYFRAME')
    row = layout.row(align=True)
    row.label(text='Sort: ')
    row.prop(context.scene, 'meg_how_to_sort', expand=True)
    layout.prop(context.scene, 'meg_show_filtering', text='Refine clusters')
    if bpy.context.scene.meg_show_filtering:
        layout.prop(context.scene,
                    'meg_clusters_val_threshold',
                    text='Val threshold')
        layout.prop(context.scene,
                    'meg_clusters_size_threshold',
                    text='Size threshold')
        layout.prop(context.scene, 'meg_clusters_label', text='Label filter')
        layout.operator(FilterMEGClusters.bl_idname,
                        text="Filter clusters",
                        icon='FILTER')
    layout.prop(context.scene,
                'plot_current_meg_cluster',
                text="Plot current cluster's contour")
    layout.prop(context.scene,
                'cumulate_meg_cluster',
                text="Cumulate contours")
    if not MEGPanel.current_cluster is None and len(
            MEGPanel.current_cluster
    ) > 0:  # and not MEGPanel.dont_show_clusters_info:
        cluster_size = MEGPanel.current_cluster['size']
        col = layout.box().column()
        mu.add_box_line(col, 'Max val',
                        '{:.2f}'.format(MEGPanel.current_cluster['max']), 0.7)
        mu.add_box_line(col, 'Size', str(cluster_size), 0.7)
        col = layout.box().column()
        labels_num_to_show = min(7,
                                 len(MEGPanel.current_cluster['intersects']))
        for inter_labels in MEGPanel.current_cluster[
                'intersects'][:labels_num_to_show]:
            mu.add_box_line(
                col, inter_labels['name'],
                '{:.0%}'.format(inter_labels['num'] / float(cluster_size)),
                0.8)
        if labels_num_to_show < len(MEGPanel.current_cluster['intersects']):
            layout.label(text='Out of {} labels'.format(
                len(MEGPanel.current_cluster['intersects'])))
    layout.operator(SelectAllClusters.bl_idname,
                    text="Select all",
                    icon='BORDER_RECT')
    text = 'Flip time series' if not MEGPanel.data_is_flipped else 'Unflip time series'
    layout.operator(FlipMEGClustersTS.bl_idname,
                    text=text,
                    icon='FORCE_MAGNETIC')
    layout.operator(DeselecAllClusters.bl_idname,
                    text="Deselect all",
                    icon='PANEL_CLOSE')
    layout.operator(ClearClusters.bl_idname,
                    text="Clear all clusters",
                    icon='PANEL_CLOSE')
    layout.operator(_addon().ClearColors.bl_idname,
                    text="Clear activity",
                    icon='PANEL_CLOSE')
    layout.prop(context.scene,
                'calc_meg_dipole_fit',
                text='Show dipole fit info')
    if bpy.context.scene.calc_meg_dipole_fit:
        col = layout.box().column()
        col.prop(context.scene, 'meg_evoked_fname', text='evoked')
        col.prop(context.scene, 'meg_noise_cov_fname', text='noise cov')
        col.prop(context.scene,
                 'head_to_mri_trans_mat_fname',
                 text='trans mat')
        row = col.row(align=True)
        row.prop(context.scene, 'meg_dipole_fit_tmin', text='from t(s)')
        row.prop(context.scene, 'meg_dipole_fit_tmax', text='to t(s)')
        row = col.row(align=True)
        row.prop(context.scene, 'meg_dipole_fit_use_meg', text='use MEG')
        row.prop(context.scene, 'meg_dipole_fit_use_eeg', text='use EEG')
        col.operator(DipoleFit.bl_idname, text='Dipole fit', icon='OOPS')
示例#12
0
def fMRI_draw(self, context):
    layout = self.layout
    user_fol = mu.get_user_fol()
    # clusters_labels_files = glob.glob(op.join(user_fol, 'fmri', 'clusters_labels_*.npy'))
    # if len(clusters_labels_files) > 1:
    if not fMRIPanel.fMRI_clusters_files_exist and _addon(
    ).coloring.fMRI_constrasts_exist() > 0:
        row = layout.row(align=True)
        row.prop(context.scene, 'fmri_clustering_threshold', text='Threshold')
        layout.operator(CalcClusters.bl_idname,
                        text="Find clusters",
                        icon='GROUP_VERTEX')
        return
    layout.prop(context.scene, 'fmri_clusters_labels_files', text='')
    if len(fMRIPanel.clusters_labels_files) > 1:
        layout.prop(context.scene, 'fmri_clusters_labels_parcs', text='')
    row = layout.row(align=True)
    row.operator(PrevCluster.bl_idname, text="", icon='PREV_KEYFRAME')
    row.prop(context.scene, 'fmri_clusters', text="")
    row.operator(NextCluster.bl_idname, text="", icon='NEXT_KEYFRAME')
    row = layout.row(align=True)
    row.label(text='Sort: ')
    row.prop(context.scene, 'fmri_how_to_sort', expand=True)

    if not fMRIPanel.cluster_labels is None and len(fMRIPanel.cluster_labels) > 0 and \
            not fMRIPanel.dont_show_clusters_info:
        if 'size' not in fMRIPanel.cluster_labels:
            fMRIPanel.cluster_labels['size'] = len(
                fMRIPanel.cluster_labels['vertices'])
        blob_size = fMRIPanel.cluster_labels['size']
        col = layout.box().column()
        mu.add_box_line(col, 'Max val',
                        '{:.2f}'.format(fMRIPanel.cluster_labels['max']), 0.7)
        mu.add_box_line(col, 'Size', str(blob_size), 0.7)
        col = layout.box().column()
        labels_num_to_show = min(7,
                                 len(fMRIPanel.cluster_labels['intersects']))
        for inter_labels in fMRIPanel.cluster_labels[
                'intersects'][:labels_num_to_show]:
            mu.add_box_line(
                col, inter_labels['name'],
                '{:.0%}'.format(inter_labels['num'] / float(blob_size)), 0.8)
        if labels_num_to_show < len(fMRIPanel.cluster_labels['intersects']):
            col.label(text='Out of {} labels'.format(
                len(fMRIPanel.cluster_labels['intersects'])))

        if len(fMRIPanel.electrodes_in_cluster) > 0:
            box = layout.box()
            box.label(text='Electrodes close to cluster:')
            col = box.box().column()
            for dist, elec_name, elc_rois, elec_prob in fMRIPanel.electrodes_in_cluster:
                # if elec_prob >= 0.01:
                mu.add_box_line(
                    col, elec_name, '{:.2f}'.format(dist), 0.8
                )  #_# '{:.2f}'.format(elec_prob), 0.8) ','.join(elc_rois)
            box.prop(context.scene,
                     'show_only_electrodes_near_cluster',
                     text='Show only those electrdes')

    # row.prop(context.scene, 'fmri_clustering_threshold', text='Threshold')
    # row.operator(CalcClusters.bl_idname, text="Recalculate clusters", icon='GROUP_VERTEX')
    layout.prop(context.scene, 'fmri_show_filtering', text='Refine clusters')
    if bpy.context.scene.fmri_show_filtering:
        # row.operator(RefinefMRIClusters.bl_idname, text="Find clusters", icon='GROUP_VERTEX')
        col = layout.box().column()
        col.prop(context.scene,
                 'fmri_cluster_val_threshold',
                 text='clusters t-val threshold')
        col.prop(context.scene,
                 'fmri_cluster_size_threshold',
                 text='clusters size threshold')
        col.prop(context.scene, 'fmri_clustering_filter', text='starts with')
        row = col.row(align=True)
        row.prop(context.scene,
                 'fmri_clustering_filter_lh',
                 text='Left hemisphere')
        row.prop(context.scene,
                 'fmri_clustering_filter_rh',
                 text='Right hemisphere')
        # if len(fMRIPanel.electrodes_in_cluster) > 0:
        col.prop(context.scene,
                 'fmri_only_clusters_with_electrodes',
                 text='Only with electrodes')
        # layout.operator(FilterfMRIBlobs.bl_idname, text="Filter blobs", icon='FILTER')
    # layout.prop(context.scene, 'plot_current_cluster', text="Plot current cluster")
    if bpy.context.scene.fmri_more_settings:
        row = layout.row(align=True)
        row.prop(context.scene,
                 'plot_fmri_cluster_contours',
                 text="Plot cluster contours")
        row.prop(context.scene, 'fmri_cluster_contours_color', text="")
        layout.prop(context.scene,
                    'plot_fmri_cluster_per_click',
                    text="Listen to left clicks")

    # layout.prop(context.scene, 'fmri_what_to_plot', expand=True)
    # row = layout.row(align=True)
    layout.operator(PlotAllBlobs.bl_idname,
                    text="Plot all blobs",
                    icon='POTATO')
    # if _addon().is_pial(): # or _addon().get_inflated_ratio() == 1:
    layout.operator(NearestCluster.bl_idname,
                    text="Nearest cluster",
                    icon='MOD_SKIN')
    # layout.prop(context.scene, 'search_closest_cluster_only_in_filtered', text="Seach only in filtered blobs")
    # layout.operator(LoadMEGData.bl_idname, text="Save as functional ROIs", icon='IPO')
    # layout.prop(context.scene, 'fmri_blobs_norm_by_percentile', text="Norm by percentiles")
    # if bpy.context.scene.fmri_blobs_norm_by_percentile:
    #     layout.prop(context.scene, 'fmri_blobs_percentile_min', text="Percentile min")
    #     layout.prop(context.scene, 'fmri_blobs_percentile_max', text="Percentile max")
    # layout.operator(FindfMRIFilesMinMax.bl_idname, text="Calc minmax for all files", icon='IPO')
    if mu.is_freesurfer_exist and bpy.context.scene.fmri_more_settings:
        layout.operator(LoadVolumefMRIFile.bl_idname, text="Load volume fMRI file", icon='LOAD_FACTORY').filepath = \
            op.join(mu.get_user_fol(), 'fmri', '*.*')
    layout.operator(fmriClearColors.bl_idname,
                    text="Clear",
                    icon='PANEL_CLOSE')
    layout.prop(context.scene, 'fmri_more_settings', text='More settings')
示例#13
0
def skull_draw(self, context):
    layout = self.layout
    source_str = 'from_inner' if bpy.context.scene.cast_ray_source == 'inner' else 'from_outer'
    dists_exist = op.isfile(
        op.join(mu.get_user_fol(), 'skull',
                'ray_casts_{}.npy'.format(source_str)))
    skull_exist = bpy.data.objects.get('inner_skull', None) is not None and \
                  bpy.data.objects.get('outer_skull', None) is not None
    plane = bpy.data.objects.get('skull_plane', None)
    plane_exist = plane is not None

    if not skull_exist:
        layout.operator(ImportSkull.bl_idname,
                        text="Import skull",
                        icon='MATERIAL_DATA')
    # layout.operator(CalcThickness.bl_idname, text="calc thickness", icon='MESH_ICOSPHERE')
    debug = True
    if not dists_exist or debug:
        layout.operator(CalcThickness.bl_idname,
                        text="Calc thickness",
                        icon='MESH_ICOSPHERE')
        layout.prop(context.scene,
                    'create_thickness_arrows',
                    text='Create thickness arrows')
    layout.operator(PlotThickness.bl_idname,
                    text="Plot thickness",
                    icon='GROUP_VCOL')
    text = 'Import plane' if not plane_exist else 'Place plane over the head'
    layout.operator(ImportPlane.bl_idname, text=text, icon='TEXTURE')
    if plane_exist:
        layout.operator(AlignPlane.bl_idname,
                        text="Align plane",
                        icon='LATTICE_DATA')
        layout.operator(CalcPlaneStat.bl_idname,
                        text="Calc plane stat",
                        icon='PARTICLE_DATA')
        if SkullPanel.plane_dir_vec is not None:
            row = layout.row(align=True)
            row.operator(RotateSkullPlaneNeg.bl_idname,
                         text="",
                         icon='PREV_KEYFRAME')
            row.prop(context.scene, 'skull_plane_angle', text='Angle delta')
            row.operator(RotateSkullPlanePos.bl_idname,
                         text="",
                         icon='NEXT_KEYFRAME')
        layout.prop(context.scene,
                    'align_plane_to_cursor',
                    text='Align to cursor')
        layout.prop(context.scene, 'hide_skull_plane', text='Hide plane')
    if SkullPanel.plane_thickness is not None:
        box = layout.box()
        col = box.column()
        mu.add_box_line(col, 'Min thickness',
                        '{:.2f}mm'.format(SkullPanel.plane_thickness[0]), 0.8)
        mu.add_box_line(col, 'Max thickness',
                        '{:.2f}mm'.format(SkullPanel.plane_thickness[1]), 0.8)
        mu.add_box_line(col, 'Mean thickness',
                        '{:.2f}mm'.format(SkullPanel.plane_thickness[2]), 0.8)

    layout.prop(context.scene, 'cast_ray_source', expand=True)
    # layout.operator(FindPointThickness.bl_idname, text="Calc point thickness", icon='MESH_DATA')
    if SkullPanel.vertex_skull_thickness > 0:
        layout.label(
            text='Thickness: {:.3f}'.format(SkullPanel.vertex_skull_thickness))

    from_string = 'from_{}'.format(
        'inner' if bpy.context.scene.cast_ray_source else 'outer')
    arrows_empty_name = 'thickness_arrows_{}'.format(from_string)
    if bpy.data.objects.get(arrows_empty_name):
        layout.prop(context.scene,
                    'show_point_arrow',
                    text='Show point thickness vector')
        layout.prop(context.scene, 'thickness_arrows', text='Thickness arrows')