AFQ.api.group#

Module Contents#

Classes#

GroupAFQ

Functions#

get_afq_bids_entities_fname()

AFQ.api.group.get_afq_bids_entities_fname()[source]#
class AFQ.api.group.GroupAFQ(bids_path, bids_filters={'suffix': 'dwi'}, preproc_pipeline='all', participant_labels=None, output_dir=None, parallel_params={'engine': 'serial'}, bids_layout_kwargs={}, **kwargs)[source]#

Bases: object

clobber[source]#
combine_profiles()[source]#
get_streamlines_json()[source]#
export(attr_name='help', collapse=True)[source]#
export_up_to(attr_name='help')[source]#
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, exceptions=[], 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 automtically 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

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=2)[source]#

Generate montage of all bundles for a all subjects.

Parameters
images_per_rowint

Number of bundle images per row in output file. Default: 2

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 displayed.

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.
upload_to_s3(s3fs, remote_path)[source]#

Upload entire AFQ derivatives folder to S3

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: “”