PUMI package
- PUMI.interfaces package
- PUMI.pipelines package
- PUMI.pipelines.anat package
- PUMI.pipelines.dwi package
- PUMI.pipelines.func package
- PUMI.pipelines.multimodal package
- PUMI.plot package
PUMI.engine module
- class PUMI.engine.AnatPipeline(inputspec_fields, outputspec_fields, regexp_sub=None, default_regexp_sub=True)[source]
Bases:
PumiPipeline# Todo docs
- class PUMI.engine.BidsApp(pipeline, name, bids_dir=None, output_dir=None, analysis_level=None, participant_label=None, working_dir='.', run_args=None, description=None, **kwargs)[source]
Bases:
object
- class PUMI.engine.BidsPipeline(output_query=None)[source]
Bases:
PumiPipelinedecorator for top-level pipelines, with BIDS input
- class PUMI.engine.FuncPipeline(inputspec_fields, outputspec_fields, regexp_sub=None, default_regexp_sub=True)[source]
Bases:
PumiPipeline# Todo docs
- class PUMI.engine.GroupPipeline(inputspec_fields, outputspec_fields, regexp_sub=None, default_regexp_sub=True)[source]
Bases:
PumiPipeline
- class PUMI.engine.NestedMapNode(interface, iterfield, name, serial=False, nested=False, **kwargs)[source]
Bases:
MapNode,NestedNode
- class PUMI.engine.NestedNode(interface, name, iterables=None, itersource=None, synchronize=False, overwrite=None, needed_outputs=None, run_without_submitting=False, n_procs=None, mem_gb=0.2, **kwargs)[source]
Bases:
Node
- class PUMI.engine.PumiPipeline(inputspec_fields=None, outputspec_fields=None, regexp_sub=None)[source]
Bases:
object# Todo docs
- class PUMI.engine.QcPipeline(inputspec_fields, outputspec_fields, regexp_sub=None, default_regexp_sub=True)[source]
Bases:
PumiPipeline# Todo docs
PUMI.utils module
- PUMI.utils.TsExtractor(labels, labelmap, func, mask, global_signal=True, pca=False, outfile='reg_timeseries.tsv', outlabelmap='individual_gm_labelmap.nii.gz')[source]
- PUMI.utils.above_threshold(in_file, threshold=0.2, frames_before=1, frames_after=2)[source]
todo docs
- PUMI.utils.calc_friston_twenty_four(in_file)[source]
Method to calculate friston twenty-four parameters
- Parameters:
in_file (str) – input movement parameters file from motion correction
- Returns:
output 1D file containing 24 parameter values
- Return type:
new_file (str)
- PUMI.utils.calculate_FD_Jenkinson(in_file)[source]
Method to calculate friston twenty four parameters
- Parameters:
in_file (str) – input movement parameters file from motion correction
- Returns:
path to output file
- Return type:
new_file (str)
- PUMI.utils.create_coregistration_qc(registered_brain, template, output_file=None, levels=None, cmap='winter', **kwargs)[source]
Create coregistration quality check images.
Can be used in a nipype function node. In this case output_file should stay None!
- Parameters:
(str) (output_file) –
(str) –
(str) – If it’s set to None (default), the path and filename is automatically generated.
(list) (levels) –
colormap) (cmap (matplotlib) –
**kwargs (These parameters are passed to plot_roi method.) –
- Returns:
output_file (str)
- Return type:
Path to the saved plot.
- PUMI.utils.create_segmentation_qc(overlay, bg_img=None, output_file=None, cut_coords=5, cmap='winter', **kwargs)[source]
Create segmentation (e.g. brain extraction, tissue segmentation) quality check images.
Can be used in a nipype function node. In this case output_file should stay None!
- Parameters:
overlay (str) – Path to the overlay (e.g. in brain extraction workflows the extracted brain).
bg_img (str) – Path to the background (e.g. in brain extraction workflows the head).
output_file (str) – Filename of quality check image. Can be be an absolute path or a relative path. If it’s set to None (default), the filename is automatically generated.
cmap (matplotlib colormap) – Colormap.
**kwargs – These parameters are passed to the plot_roi method.
- Returns:
Path to the saved plot.
- Return type:
output_file (str)
- PUMI.utils.get_config(wf, section, config)[source]
Return the absolute path to the desired config file.
The method is going to search for a specified path in the settings.ini. If no path was specified, a fallback value is used if possible.
Note: Unlike some other methods, in the case of a relative path the path is NOT considered relative to the FSL-Dir, but relative to the current working directory!
- Parameters:
wf (Workflow) – the workflow
section (str) – the section where the path should be found in settings.ini (e.g. ‘FSL’)
config (str) – name (key) of the config (e.g. ‘fnirt_config’)
- PUMI.utils.get_indx(scrub_input, frames_in_1D_file)[source]
Method to get the list of time frames that are to be included
- Parameters:
in_file (str) – path to file containing the valid time frames
- Returns:
- input string for 3dCalc in scrubbing workflow,
looks something like ” 4dfile.nii.gz[0,1,2,..100] “
- Return type:
scrub_input_string (str)
- PUMI.utils.get_ref_from_templateflow(query)[source]
Try to get the specified reference from templateflow and return the absolute path to the file. The schema for the query is ‘template/file’. Note: ‘tpl-’ in the template specification (NOT the file specification!) can be omitted. Look at the available references at ‘https://www.templateflow.org/browse/’
A possible query would be: ‘tpl-MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz’ Also okay: ‘MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz’
- PUMI.utils.get_ref_locally(wf, ref)[source]
Try to get the reference locally and return the absolute path to the file Possible values for the ref parameter are ‘head’, ‘brain’, ‘brain_mask’ or ‘ventricle_mask’.
The method looks in the settings.ini for specified paths for the desired reference in the TEMPLATES section.
If no path was specified, the respective 2mm reference from FSL’s standard repertoire is returned. If a path was specified, it is checked if the path starts with a ‘/’. If so, this path is considered as an absolute path, otherwise the path is considered relative to the FSL-Dir (NOT the current working directory)!
- PUMI.utils.get_reference(wf, type, ref=None)[source]
Returns the absolute path to the desired reference. Possible values for the type parameter are ‘head’, ‘brain’, ‘brain_mask’ or ‘ventricle_mask’.
If ref = None, the method looks in the settings.ini for specified paths (and source specifications) for the desired reference in the TEMPLATES section.
If no path was specified, the respective 2mm reference from FSL’s standard repertoire is returned. If a path was specified, it looks if also a source was specified. If no source was specified (or the source is ‘local’), then it’s going to search local. If a local search is performed, it is checked if the path starts with a ‘/’. If so, this path is considered as an absolute path, otherwise the path is considered relative to the FSL-Dir (NOT the current working directory)! If the source is ‘templateflow’ or also ‘tf’, it is tried to get the reference from templateflow.
Some possible path specification without use of templateflow: ‘head = data/standard/MNI152_T1_2mm.nii.gz’ or ‘head = data/standard/MNI152_T1_2mm.nii.gz; source=local’ or ‘head = /usr/local/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz’
Possible path specification with use of templateflow: ‘head = tpl-MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz; source=templateflow’
The ‘tpl-’ in the folder/template specification (NOT the file specification!) can also be omitted. Also ‘tf’ can be used as abbreviation for templateflow.
So this is also okay: ‘head = MNI152Lin/tpl-MNI152Lin_res-02_T1w.nii.gz; source=tf’
Be aware that ‘head’, ‘brain’ and ‘brain_mask’ must also be lowercased in the settings.ini!
- PUMI.utils.max_from_txt(in_file, axis=None, header=False, out_file='max.txt')[source]
Saves the maximum along a given axis into another text-file.
Caution: Name in the old PUMI was txt2MaxTxt
- Parameters:
in_file (str) – input file
axis (None/int/(int,int)) – axis or axes along the maximum values are computed. Default: Use flattened array.
header (bool) – Drop line if True
out_file (str) – Name of the resulting text-file. If only the filename is given, it will be saved into the current working directory.
- Returns:
path to new file
- Return type:
new_file (str)
- PUMI.utils.mean_from_txt(in_file, axis=None, header=False, out_file='mean.txt')[source]
Calculate column-means, row-means or the global mean depending on the ‘axis’ parameter and save it to another text-file.
Caution: Name in the old PUMI was txt2MeanTxt
- Parameters:
in_file (str) – input file
axis (None/int/(int,int)) – axis or axes along which the means are computed. Default: Compute mean of the flattened array.
header (bool) – Drop line if True
out_file (str) – Name of the resulting text-file. If only the filename is given, it will be saved into the current working directory.
- Returns:
path to new file
- Return type:
new_file (str)
- PUMI.utils.mist_labels(mist_directory, resolution='122')[source]
Return a list of the labels contained in the MIST atlas :param mist_directory: Path to the MIST directory :type mist_directory: str :param resolution: Resolution (you have to check which resolutions are valid) :type resolution: str
- Returns:
A list containing the labels in the MIST atlas
- Return type:
result ([str])
- PUMI.utils.mist_modules(mist_directory, resolution='122')[source]
Return a list of the modules contained in the MIST atlas :param mist_directory: Path to the MIST directory :type mist_directory: str :param resolution: Resolution (you have to check which resolutions are valid) :type resolution: str
- Returns:
A list containing the modules in the MIST atlas
- Return type:
result ([str])
- PUMI.utils.plot_carpet_ts(timeseries, modules, atlas=None, background_file=None, subplot=None, output_file='regts.png')[source]
Adapted from: https://github.com/poldracklab/niworkflows Plot an image representation of voxel intensities across time also know as the “carpet plot” or “Power plot”. See Jonathan Power Neuroimage 2017 Jul 1; 154:150-158. :param timeseries: 4D input image. See http://nilearn.github.io/manipulating_images/input_output.html. :type timeseries: numpy.ndarray :param output_file: Optional! The name of the output image. Valid extensions are .png, .pdf, .svg. :type output_file: str, None
- PUMI.utils.plot_roi(roi_img, bg_img=None, cut_coords=5, output_file=None, display_mode='mosaic', figure=None, axes=None, title=None, annotate=True, draw_cross=True, black_bg=True, threshold=0.5, alpha=0.7, cmap='tab10', dim='auto', vmin=None, vmax=None, resampling_interpolation='nearest', view_type='continuous', linewidths=2.5, colorbar=False, save_img=True, **kwargs)[source]
Wrapper for nilearn’s plot_roi method (with small modifications).
Can be used in a nipype function node. In this case output_file should stay None and save_img should stay True!
- Parameters:
save_img. (Only parameter that does not occur in nilearn's plot_roi method is) –
object. (Set to False if you don't want to save the result and just need the plot) –
suitable (This parameter is necessary because we substitute output_file by the current working directory and a) –
None (filename if output_file is set to) –
node (In case the function is executed within a nipype function) –
working (the current working directory is the) –
node. (directory of the respective) –
nodes. (We introduced this modifications in order to be able to use this method easily in nipype function) –
For more information about the other parameters, see the documentation of nilearn. https://nilearn.github.io/modules/generated/nilearn.plotting.plot_roi.html
Only a few changes have been made to the default parameters. Here a mosaic plot with 5 columns is generated by default, the background of every plot is black and the default cmap has been changed.
- Returns:
Plot object. output_file (str): Path to the saved plot (if save_img is False, None is returned).
- Return type:
plot (nilearn.plotting.displays.OrthoSlicer)
- Acknowledgements:
- Further informations:
- PUMI.utils.registration_ants_hardcoded(brain, reference_brain, head, reference_head)[source]
Todo Docs
- PUMI.utils.relabel_atlas(atlas_file, modules, labels)[source]
Relabel atlas * Beware : currently works only with labelmap!! :param atlas_file: Path to the atlas file :type atlas_file: str :param modules: List containing the modules in MIST :type modules: [str] :param labels: List containing the labels in MIST :type labels: [str]
- Returns:
Path to relabeld atlas file reordered_modules ([str]): list containing reordered module names reordered_labels ([str]): list containing reordered label names new_labels (str): Path to .tsv-file with the new labels
- Return type:
relabel_file (str)
- PUMI.utils.scrub_image(scrub_input)[source]
Method to run 3dcalc in order to scrub the image. This is used instead of the Nipype interface for 3dcalc because functionality is needed for specifying an input file with specifically-selected volumes. For example: input.nii.gz[2,3,4,..98], etc.
- Parameters:
scrub_input (str) – path to 4D file to be scrubbed, plus with selected volumes to be included
- Returns:
path to the scrubbed 4D file
- Return type:
scrubbed_image (str)