Utility (utils) module

PyMIALSRTK utils functions.

pymialsrtk.interfaces.utils.reorder_by_run_ids(p_files, p_order)[source]

Function used to reorder images by their run-id IDS tag.

The images are sorted according to the input parameters. If more images are available, they remaining are sorted in scending order.

Parameters:
  • <list<string>> (p_files) – List of image paths - containing a ‘run-‘ id tag, to be reordered
  • <list<int>> (env) – List of expecting run id order.

Examples

>>> in_files = ['sub-01_run-2_T2w.nii.gz', 'sub-01_run-5_T2w.nii.gz', 'sub-01_run-3_T2w.nii.gz', 'sub-01_run-1_T2w.nii.gz']
>>> my_order = [1,5,3]
>>> reorder_by_run_ids(in_files, my_order)
pymialsrtk.interfaces.utils.run(command, env=None, cwd=None)[source]

Function calls by each MIALSRTK interface.

It runs the command specified as input via subprocess.run().

Parameters:
  • <string> (command) – String containing the command to be executed (required)
  • <os.environ> (env) – Specify a custom os.environ
  • <Directory> (cwd) – Specify a custom current working directory

Examples

>>> cmd = 'btkNLMDenoising -i "/path/to/in_file" -o "/path/to/out_file" -b 0.1'
>>> run(cmd)
pymialsrtk.interfaces.utils.sort_ascending(p_files)[source]

Function used to sort images at the input of a nipype node.

Parameters:<list<string>> (p_files) – List of image paths to be sorted in ascending order

Examples

>>> in_files = ['sub-01_run-2_T2w.nii.gz', 'sub-01_run-5_T2w.nii.gz', 'sub-01_run-3_T2w.nii.gz', 'sub-01_run-1_T2w.nii.gz']
>>> sort_ascending(in_files)