falconz package

Submodules

falconz.constants module

This module contains the constants that are used in the falconz.

The variables in this module can be imported and used in other modules within the falconz.

falconz.display module

This module shows predefined display messages for the falconz.

Usage:

The functions in this module can be imported and used in other modules within the falconz to show predefined display messages.

falconz.display.citation()[source][source]

Display manuscript citation.

Returns:

None

falconz.display.default_parameters(input_args)[source][source]

Display default parameters for FALCON.

Parameters:

input_args (argparse.Namespace) – Input arguments for FALCON.

Returns:

None

falconz.display.derived_parameters(input_args)[source][source]

Display derived parameters for FALCON.

Parameters:

input_args (argparse.Namespace) – Input arguments for FALCON.

Returns:

None

falconz.display.expectations()[source][source]

Display expected modalities for FALCON. This is used to check if the user has provided the correct set of modalities for each tracer set.

Returns:

None

Display FALCON logo.

Returns:

None

falconz.download module

Note

Research Group: Quantitative Imaging and Medical Physics (QIMP) Team

Version: 0.1.0

Date: 04.07.2023

Usage

The functions in this module can be imported and used in other modules within the falconz to download the necessary binaries and models for the falconz.

falconz.download.download(item_name, item_path, item_dict)[source][source]

Downloads the item (model or binary) for the current system.

Parameters:
  • item_name (str) – The name of the item to download.

  • item_path (str) – The path to store the item.

  • item_dict (dict) – The dictionary containing item info.

Returns:

The path to the downloaded item.

Return type:

str

falconz.falconz module

falconz.file_utilities module

This module provides various utilities to handle file operations necessary for the falconz project.

Usage:

The functions in this module can be imported and used in other modules within the falconz to perform file operations.

falconz.file_utilities.copy_file(file, destination)[source][source]

Copies a file to the destination directory.

Parameters:
  • file (str) – The path to the file.

  • destination (str) – The path to the destination directory.

falconz.file_utilities.copy_files_to_destination(files: list, destination: str)[source][source]

Copies the files inside the list to the destination directory in a parallel fashion.

Parameters:
  • files (list) – The list of files to be copied.

  • destination (str) – The path to the destination directory.

falconz.file_utilities.create_directory(directory_path: str)[source][source]

Creates a directory at the specified path.

Parameters:

directory_path (str) – The path to the directory.

falconz.file_utilities.get_files(directory_path: str, wildcard: str)[source][source]

Gets the files from the specified directory using the wildcard.

Parameters:
  • directory_path (str) – The path to the directory.

  • wildcard (str) – The wildcard to be used.

Returns:

The list of files.

Return type:

list

falconz.file_utilities.get_number_of_possible_jobs(process_memory: int, process_threads: int) int[source][source]

Gets the number of available jobs based on system specifications and process parameters.

Parameters:
  • process_memory (int) – Specify how much memory a process needs.

  • process_threads (int) – Specify how many threads a process needs.

Returns:

Number of possible concurrent jobs as integer number.

Return type:

int

falconz.file_utilities.get_system()[source][source]

Gets the system and architecture information.

Returns:

A tuple containing the system and architecture information.

Return type:

tuple

Raises:

ValueError – If the system or architecture is not supported.

falconz.file_utilities.get_virtual_env_root()[source][source]

Gets the root directory of the virtual environment.

Returns:

The root directory of the virtual environment.

Return type:

str

falconz.file_utilities.move_file(file, destination)[source][source]

Moves a file to the destination directory.

Parameters:
  • file (str) – The path to the file.

  • destination (str) – The path to the destination directory.

falconz.file_utilities.numeric_sort_key(file_path: str) int[source][source]

Extracts the numeric portion from a filename for sorting purposes.

Parameters:

file_path (str) – The path to the file.

Returns:

The numeric value extracted from the filename. Returns 0 if no number is found.

Return type:

int

falconz.file_utilities.organise_files_by_modality(tracer_dirs: list, modalities: list, pumaz_dir) None[source][source]

Organises the files by modality.

Parameters:
  • tracer_dirs (list) – The list of tracer directories.

  • modalities (list) – The list of modalities.

  • pumaz_dir (str) – The path to the pumaz directory.

falconz.file_utilities.select_files_by_modality(tracer_dirs: list, modality_tag: str) list[source][source]

Selects the files with the selected modality tag from the tracer directory.

Parameters:
  • tracer_dirs (list) – Path to the tracer directory.

  • modality_tag (str) – The modality tag to be selected.

Returns:

The list of selected files.

Return type:

list

falconz.file_utilities.set_permissions(file_path, system_type)[source][source]

Set permissions for a file based on the operating system.

Parameters:
  • file_path (str) – The path to the file.

  • system_type (str) – The type of the operating system.

Returns:

None

Return type:

None

Raises:

ValueError if the operating system is not supported.

This function sets permissions for a file based on the operating system. If the operating system is Windows, it uses the icacls command to grant full access to everyone. If the operating system is Linux or Mac, it uses the chmod command to add execute permission for the owner, read permission for the group, and read permission for others. If the operating system is not supported, it raises a ValueError.

Raises:

ValueError if the operating system is not supported.

Raises:

subprocess.CalledProcessError if the icacls command fails on Windows.

Raises:

PermissionError if the chmod command fails on Linux or Mac.

Raises:

Exception if an unknown error occurs.

Example:
>>> set_permissions('/path/to/file', 'linux')

falconz.image_conversion module

This module handles image conversion for the falconz.

Usage:

The functions in this module can be imported and used in other modules within the falconz to perform image conversion.

class falconz.image_conversion.NiftiConverter(input_directory: str, output_directory: str = None)[source][source]

Bases: object

A utility for converting various medical image formats in a directory into 3D NIFTI files.

Attributes:

input_directory (str): Path to the directory containing input images. output_directory (str): Path to the directory where the converted images will be saved.

dcm2niix(input_path: str, output_dir: str) str[source][source]

Converts DICOM files to NIfTI format using dcm2niix.

Args:

input_path (str): The path to the input directory. output_dir (str): The path to the output directory.

Returns:

str: The path to the output directory.

Raises:

NiftiConverterError: If there’s an error during DICOM to NIFTI conversion.

exception falconz.image_conversion.NiftiConverterError[source][source]

Bases: Exception

falconz.image_conversion.merge3d(nifti_dir: str, wild_card: str, nifti_outfile: str) None[source][source]

Merge 3D NIFTI files into a 4D NIFTI file using nibabel :param nifti_dir: Directory containing the 3D NIFTI files :param wild_card: Wildcard to use to find the 3D NIFTI files :param nifti_outfile: User-defined output file name for the 4D NIFTI file

falconz.image_processing module

falconz.input_validation module

This module handles input validation for the falconz.

Usage:

The functions in this module can be imported and used in other modules within the falconz to perform image conversion.

class falconz.input_validation.InputValidation(args)[source][source]

Bases: object

A class for input validation for the falconz.

Parameters:

args (Any) – The arguments to validate.

validate()[source][source]

Validates the input arguments.

falconz.resources module

This module contains the urls and filenames of the binaries that are required for the falconz.

Usage:

The variables in this module can be imported and used in other modules within the falconz to download the necessary binaries for the falconz.

falconz.resources.get_system_stats()[source][source]

Module contents