AFQ.api.group#
Classes#
Module Contents#
- class AFQ.api.group.GroupAFQ(bids_path, bids_filters=None, dwi_preproc_pipeline='all', t1_preproc_pipeline=None, participant_labels=None, output_dir=None, parallel_params=None, bids_layout_kwargs=None, logging_level=logging.INFO, **kwargs)[source]#
Bases:
object- classmethod from_qsiprep(qsi_dir, participant_labels=None, output_dir=None, parallel_params=None, **kwargs)[source]#
Initialize a GroupAFQ object from a QSIPrep BIDS derivative dataset, given just the path to the BIDS dataset that contains the QSIPrep outputs in its derivatives folder.
- Parameters:
- qsi_dirstr
The path to the BIDS dataset that contains the QSIPrep outputs in its derivatives folder.
- participant_labelslist or None, optional
List of participant labels (subject IDs) to perform processing on. If None, all subjects are used. Default: None
- output_dirstr or None, optional
Path to output directory. If None, outputs are put in a AFQ pipeline folder in the derivatives folder of the BIDS directory. pyAFQ will use existing derivatives from the output directory if they exist, instead of recalculating them (this means you need to clear the output folder if you want to recalculate a derivative). Default: None
- parallel_paramsdict, optional
Parameters to pass to paramap in AFQ.utils.parallel, to parallelize computations across subjects and sessions. Set “n_jobs” to -1 to automatically parallelize as the number of cpus. Here is an example for how to do multiprocessing with 4 cpus: {“n_jobs”: 4, “engine”: “ray”} Default: {“engine”: “serial”}
- kwargsadditional optional parameters
You can set additional parameters for any step of the process. See usage/kwargs for more details.
- export_all(viz=True, afqbrowser=True, xforms=True, indiv=True)[source]#
Exports all the possible outputs
- Parameters:
- vizbool
Whether to output visualizations. This includes tract profile plots, a figure containing all bundles, and, if using the AFQ segmentation algorithm, individual bundle figures. Default: True
- afqbrowserbool
Whether to output an AFQ-Browser from this AFQ instance. Default: True
- xformsbool
Whether to output the reg_template image in subject space and, depending on if it is possible based on the mapping used, to output the b0 in template space. Default: True
- indivbool
Whether to output individual bundles in their own files, in addition to the one file containing all bundles. If using the AFQ segmentation algorithm, individual ROIs are also output. Default: True
- cmd_outputs(cmd='rm', dependent_on=None, up_to=None, exceptions=None, suffix='')[source]#
Perform some command some or all outputs of pyafq. This is useful if you change a parameter and need to recalculate derivatives that depend on it. Some examples: cp, mv, rm . -r will be automatically added when necessary.
- Parameters:
- cmdstr
Command to run on outputs. Default: ‘rm’
- dependent_onstr or None
Which derivatives to perform command on . If None, perform on all. If “track”, perform on all derivatives that depend on the tractography. If “recog”, perform on all derivatives that depend on the bundle recognition. Default: None
- up_tostr or None
If None, will perform on all derivatives. If “track”, will perform on all derivatives up to (but not including) tractography. If “recog”, will perform on all derivatives up to (but not including) bundle recognition. If “prof”, will perform on all derivatives up to (but not including) bundle profiling. Default: None
- exceptionslist of str
Name outputs that the command should not be applied to. Default: []
- suffixstr
Parts of command that are used after the filename. Default: “”
- make_all_participant_montages(images_per_row=3)[source]#
Generate montage of all bundles for a all subjects.
- Parameters:
- images_per_rowint
Number of bundle images per row in output file. Default: 3
- Returns:
- filename of montage images
- group_montage(bundle_name, size, view, direc, slice_pos=None)[source]#
Generate montage file(s) of a given bundle at a given angle.
- Parameters:
- bundle_namestr
Name of bundle to visualize, should be the same as in the bundle dictionary.
- sizetuple of int
The number of columns and rows for each file.
- viewstr
Which view to display. Can be one of sagittal, coronal, or axial.
- direcstr
Which direction to views. Can be one of left, right, top, bottom, front, back
- slice_posfloat, or None
If float, indicates the fractional position along the perpendicular axis to the slice. Currently only works with plotly. If None, no slice is displaid.
- Returns:
- list of filenames of montage images
- combine_bundle(bundle_name)[source]#
Transforms a given bundle to reg_template space for all subjects then merges them to one trk file. Useful for visualizing the variability in the bundle across subjects. Note: currently only implemented using built-in SynMap
- Parameters:
- bundle_namestr
- Name of the bundle to transform, should be one of the bundles in
- bundle_dict.
- export_group_density(boolify=True)[source]#
Generate a group density map by combining single subject density maps.
- Parameters:
- boolifybool
Whether to turn subject streamline count images into booleans before adding them into the group density map.
- assemble_AFQ_browser(output_path=None, metadata=None, page_title='AFQ Browser', page_subtitle='', page_title_link='', page_subtitle_link='')[source]#
Assembles an instance of the AFQ-Browser from this AFQ instance. First, we generate the combined tract profile if it is not already generated. This includes running the full AFQ pipeline if it has not already run. The combined tract profile is one of the outputs of export_all. Second, we generate a streamlines.json file from the bundle recognized in the first subject’s first session. Third, we call AFQ-Browser’s assemble to assemble an AFQ-Browser instance in output_path.
- Parameters:
- output_pathstr
Path to location to create this instance of the browser in. Called “target” in AFQ Browser API. If None, bids_path/derivatives/afq_browser is used. Default: None
- metadatastr
Path to subject metadata csv file. If None, an metadata file containing only subject ID is created. This file requires a “subjectID” column to work. Default: None
- page_titlestr
Page title. If None, prompt is sent to command line. Default: “AFQ Browser”
- page_subtitlestr
Page subtitle. If None, prompt is sent to command line. Default: “”
- page_title_linkstr
Title hyperlink (including http(s)://). If None, prompt is sent to command line. Default: “”
- page_subtitle_linkstr
Subtitle hyperlink (including http(s)://). If None, prompt is sent to command line. Default: “”