fsleyes.plugins.controls.filetreepanel.filetreepanel

This module provides the FileTreePanel class, which can be used to browse the contents of structured directories which are described with a FileTree specification.

See also the manager module, which contains the logic for generating the file list.

fsleyes.plugins.controls.filetreepanel.filetreepanel.BUILTIN_TREE_FILTER = ['BedpostX', 'Diffusion', 'HCP_Surface', 'ProbtrackX', 'bet', 'dti', 'eddy', 'epi_reg', 'fast', 'topup', 'feat_reg', 'feat_stats']

Built-in .tree files with a name in this list are hidden from the FileTreePanel interface. These trees are not very useful for our purposes of navigating multi-subject data directories.

class fsleyes.plugins.controls.filetreepanel.filetreepanel.FileTreePanel(parent, overlayList, displayCtx, viewPanel)[source]

Bases: fsleyes.controls.controlpanel.ControlPanel

The FileTreePanel can be used to browse the contents of structured directories which are described with a filetree.

The user needs to select a data directory, and a file tree. The file tree can be selected either from the drop down list of built-in trees, or a custom tree file can be selected.

Once the user has selected a file tree and a data directory, the FileTypePanel and VariablePanel will be populated, allowing the user to choose which file types to display, and how to arrange them.

When the user has selected some file types, the FileListPanel will display a grid containing all of the matching files that exist in the directory. The user can select a row to view the relevant files.

The FileTreeManager handles the logic of working with the FileTree and of displaying overlays.

customTrees = []

Whenever the user loads a custom tree file, its path is added to this list, so that the tree file dropdown box can be populated with previously loaded tree files.

static supportedViews()[source]

The FileTreePanel is intended for use with CanvasPanel views (i.e. ortho, lightbox, 3D views).

static defaultLayout()[source]

Returns a dictionary of arguments to be passed to ViewPanel.togglePanel() when a FileTreePanel is opened.

static ignoreControl()[source]

If the file_tree library is not installed, returns True, which causes the FileTreePanel to not be added as an option in the FSLeyes interface.

__init__(parent, overlayList, displayCtx, viewPanel)[source]

Create a FileTreePanel.

Parameters
property varPanel

Return a reference to the VariablePanel.

property fileTypePanel

Return a reference to the FileTypePanel.

property fileListPanel

Return a reference to the FileListPanel.

property treeChoice

Return a reference to the file tree wx.Choice widget.

UpdateFileList()[source]

Called by the sub-panels when the user changes any settings. Re-generates the file grid.

_loadTree(treename, dirname)[source]

Called when a new tree or data directory is selected. Clears any previous file tree, and loads the new one. If either the tree or directory are None, any existing file tree is cleared.

Parameters
  • treename – File tree name or file

  • dirname – Data directory

_getTreeChoice()[source]

Returns the current selection of the built-in filetree drop down box.

_onLoadDir(ev=None)[source]

Called when the user pushes the load data directory button.

Prompts the user to select a directory, then calls the __loadTree() method.

_onTreeChoice(ev=None)[source]

Called when the user changes the built-in file tree selection. Calls the __loadTree() method.

_onCustomTree(ev=None)[source]

Called when the user pushes the load custom tree button. Prompts the user to choose a file, then calls __loadTree().

_onSave(ev=None)[source]

Called when the save button is pushed. Prompts the user for a destination, and then saves the contents of the grid.

_onNotesChoice(ev)[source]

Called when the user changes the notes column position choice. Calls FileListPanel.NotesColumn() accordingly.

__annotations__ = {}
__module__ = 'fsleyes.plugins.controls.filetreepanel.filetreepanel'
class fsleyes.plugins.controls.filetreepanel.filetreepanel.VariablePanel(parent, ftpanel)[source]

Bases: __main__.docbuilder.run.<locals>.MockClass

The VariablePanel displays a list of available variables, allowing the user to choose between:

  • Displaying each variable value on a different row (<any>, the default). These variables are referred to as varying.

  • Displaying all variable value on the same row (<all>). These variables are referred to as fixed.

  • Displaying one specific variable value. These are also included as varying variables.

__init__(parent, ftpanel)[source]

Create a VariablePanel

Parameters
SetVariables(vars)[source]

Set the variables to be displayed.

Parameters

vars – Dict of { var : [value] } mappings, containing all variables, and all of their possible values.

GetVaryings()[source]

Return a dict of { var : val } mappings containing all varying variables. The value for each variable may be one of:

  • '*', indicating that all possible values for this variable should be considered

  • None, indicating that only instances where this variable is absent should be considered.

  • A specific value, indicating that only this value should be considered.

GetFixed()[source]

Returns a list containing the names of all fixed variables.

__onVariable(ev)

Called when the user changes a variable setting. Calls the FileTreePanel.Update() method.

__annotations__ = {}
__module__ = 'fsleyes.plugins.controls.filetreepanel.filetreepanel'
class fsleyes.plugins.controls.filetreepanel.filetreepanel.FileListPanel(parent, ftpanel, notes='right')[source]

Bases: __main__.docbuilder.run.<locals>.MockClass

The FileListPanel displays a grid of filetree variable values and file types, allowing the user to step through the files in the data directory.

The user can drag varying variable columns to re-order them - this will trigger a call to FileTreeManager.reorder().

A Notes column contains text controls in each row, allowing the user to add notes. The position of this column can be set to either left or right of the fixed variable columns via the NotesColumn() method.

__init__(parent, ftpanel, notes='right')[source]

Create a FileListPanel.

Parameters
  • parentwx parent object

  • ftpanel – The FileTreePanel

  • notes

    Location of the Notes column - one of:

    • 'right' - right-most column (default)

    • 'left' - left-most column, after varying columns

The Notes column location can be changed later via the NotesColumn() method.

ResetGrid(mgr)[source]

Clear and re-populate the file tree grid.

Parameters

mgr – The FileTreeManager from which the variable and file information is retrieved.

NotesColumn(notes)[source]

Set the position of the Notes column, either 'left' or 'right' of the fixed variable columns.

GridContents()[source]

Returns the contents of the grid as a list of lists of strings.

__populateGrid()

Populates the contents of the file tree grid. The contents are retrieved from the FileTreeManager.

__notesIndex()

Returns the column index of the notes column. Assumes that a FileTreeManager has been passed to ResetGrid().

__createNotes()

Called by ResetGrid(). Creates a wx.TextCtrl for each row, and adds it to the end column.

__noteCharHook(ev)

Called on character events for any of the note controls. If the character is a tab, up, or down arrow, focus is shifted to the next or previous note.

__onSelect(ev)

Called when the user selects a row. Calls the FileTreeManager.Show() method.

__onReorder(ev)

Called when the user drags a column to change the column order. Calls the FileTreeManager.reorder() method, and updates the grid contents.

__annotations__ = {}
__module__ = 'fsleyes.plugins.controls.filetreepanel.filetreepanel'
__genColumnLabels(varcols, fixedcols)

Called by ResetGrid(). Generates a label for each column in the grid, including the Notes column if it is visible.

Parameters
  • varcols – List of varying variable names

  • fixedcols – List of (name, { var : val }) tuples, containing the file type and variable values of all fixed variable columns.

Returns

A list of labels for each column