fsleyes.controls.filetreepanel

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

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

fsleyes.controls.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.controls.filetreepanel.FileTreePanel(parent, overlayList, displayCtx, frame)

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.

__init__(parent, overlayList, displayCtx, frame)

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()

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

_loadTree(treename, dirname)

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()

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

_onLoadDir(ev=None)

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)

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

_onCustomTree(ev=None)

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

_onSave(ev=None)

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

__module__ = 'fsleyes.controls.filetreepanel'
class fsleyes.controls.filetreepanel.VariablePanel(parent, ftpanel)

Bases: __main__.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)

Create a VariablePanel

Parameters
SetVariables(vars)

Set the variables to be displayed.

Parameters

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

GetVaryings()

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()

Returns a list containing the names of all fixed variables.

_VariablePanel__onVariable(ev)

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

__module__ = 'fsleyes.controls.filetreepanel'
class fsleyes.controls.filetreepanel.FileListPanel(parent, ftpanel)

Bases: __main__.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 text control is added at the end of each row, allowing the user to add notes.

__init__(parent, ftpanel)

Create a FileListPanel.

Parameters
ResetGrid(mgr)

Clear and re-populate the file tree grid.

Parameters

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

GridContents()

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

_FileListPanel__createNotes()

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

_FileListPanel__genColumnLabels(varcols, fixedcols)

Called by ResetGrid(). Generates a label for each column in the grid.

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

_FileListPanel__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.

_FileListPanel__onReorder(ev)

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

_FileListPanel__onSelect(ev)

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

_FileListPanel__populateGrid()

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

__module__ = 'fsleyes.controls.filetreepanel'