Path manager

class dendrotweaks.path_manager.PathManager(path_to_model: str)[source]

Bases: object

A manager class for handling file and directory paths related to models data.

Parameters:

path_to_model (str) – The path to the model directory.

path_to_model

The path to the model directory.

Type:

str

paths

A dictionary of paths for different file types.

Type:

Dict[str, str]

property path_to_data

The path to the data directory, which is always the parent directory of path_to_model.

copy_default_mod_files()[source]

Copy default mod files to the data directory.

copy_template_files()[source]

Copy template files to the data directory.

remove_folder(relative_path: str) None[source]

Remove a folder and all its contents.

Parameters:

relative_path (str) – The absolute path to the folder to be removed.

get_abs_path(relative_path: str, create_dirs: bool = False) str[source]

Get the absolute path to a file or directory based on a relative path.

Parameters:
  • relative_path (str) – Path relative to one of the registered roots.

  • create_dirs (bool, default False) – If True, create the parent directories if they don’t exist.

Returns:

Absolute path in OS-native format.

Return type:

str

Examples

>>> pm = PathManager('/path/to/model')
>>> pm.get_abs_path('stimuli/depolarizing/protocol.json')
'/path/to/model/stimuli/depolarizing/protocol.json'
list_folders(relative_path: str) List[str][source]

List all folders in a given directory.

Parameters:

relative_path (str) – Path relative to one of the registered roots.

Returns:

A list of folder names.

Return type:

List[str]

Examples

>>> pm = PathManager('/path/to/model')
>>> pm.list_folders('stimuli')
['depolarizing_current', 'hyperpolarizing_current']
list_files(relative_path: str, extension: str | None = None) List[str][source]

List all files in a given directory with an optional extension filter. If the extension is None, su

Parameters:
  • relative_path (str) – Path relative to one of the registered roots.

  • extension (str) – The file extension to filter by (e.g., ‘mod’, ‘swc’).

Returns:

A list of file names.

Return type:

List[str]

list_morphologies(extension: str = '.swc') List[str][source]

List all SWC files.

Returns:

A list of SWC file names.

Return type:

List[str]

list_stimuli() List[str][source]

List all JSON files.

Returns:

A list of JSON file names.

Return type:

List[str]

list_biophys()[source]

List all biophysics files.

Returns:

A list of biophysics file names.

Return type:

List[str]

print_directory_tree(subfolder=None) None[source]

Print a directory tree for a given file type.

Parameters:

file_type (str) – The type of file (e.g., ‘mod’, ‘swc’).

get_channel_paths(mechanism_name: str, python_template_name: str = None) Dict[str, str][source]

Get all necessary paths for creating a channel.

Parameters:
  • mechanism_name (str) – The name of the mechanism.

  • python_template_name (str, optional) – The name of the Python template file.

Returns:

A dictionary of paths.

Return type:

Dict[str, str]

get_standard_channel_paths(mechanism_name: str, python_template_name: str = None, mod_template_name: str = None) Dict[str, str][source]

Get all necessary paths for creating a standard channel.

Parameters:
  • mechanism_name (str) – The name of the mechanism.

  • python_template_name (str, optional) – The name of the Python template file.

  • mod_template_name (str, optional) – The name of the MOD template file.

Returns:

A dictionary of paths.

Return type:

Dict[str, str]