Setting 'brain_mask_definition' in pyAFQ config.toml

The information about options and how to set / format the ‘brain_mask_definition’ in the config.toml file required for pyAFQ is unclear to me:

# This will be used to create
# the brain mask, which gets applied before registration to a
# template.
# If you want no brain mask to be applied, use FullImage.
# If None, use B0Image()
# Default: None
brain_mask_definition = ""

I’d like to be able to set similar to how it is defined in API examples:

brain_mask_definition = LabelledImageFile(
    suffix="seg",
    filters={"scope": "freesurfer"},
    exclusive_labels=[0])

Any suggestions or help would be greatly appreciated.

For brain_mask_definition, you can set it to the path of your brain mask.

minimal example:

from AFQ.api.participant import ParticipantAFQ
from AFQ.definitions.image import ImageFile
brain_mask_definition = ImageFile(path=mask_path)
myafq = ParticipantAFQ(
            dwi_path, bval_path, bvec_path, out_dir,
            import_tract=tck_path,
            brain_mask_definition=brain_mask_definition,
            mapping_definition=None)
myafq.export_all()

Best,
Steven

1 Like

Thank you. This is helpful if using the API but my question is how to set the brain_mask_definition in the config.toml file if using the command-line interface (CLI). I’m nearly about to give up trying to using the pyAFQ bash command and just revert to the API commands and run them through Python since it seems there’s more flexibility.

Ah sorry, read your question too quickly! Not sure how to change the config.toml to do this automatic filtering. Hopefully you figure it out or are able to switch to the API.

1 Like