Package: pfc-toolkit
pfc-toolkitThe Precomputed Functional Connectome Toolkit (pfc-toolkit) is a Python module for functional lesion network mapping using the Precomputed Functional Connectome and is distributed under the 3-Cause BSD license.This project is also known as the Precomputed Human Brain Connectome Toolkit.The project was started in 2019 by William Drew for his Harvard undergraduate thesis project ('21).The project was supervised by Dr. Michael D. Fox, MD, PhD first at the Berenson-Allen Center for Noninvasive Brain Stimulation at Beth Israel Deaconess Medical Center and later at the Center for Brain Circuit Therapeutics at Brigham and Women's Hospital.This project references work from@clin045's and@alexlicohen'sconnectome_quick.pyfromnimlaband@andreashorn'sconnectome.shfromLeadDBS.The Precomputed Functional Connectome Toolkit is for research only; please do not use results from PFC Toolkit for clinical decisions.InstallationDependenciespfc-toolkit requires:Python (>=3.6)NumPySciPyNumbaNibabelNilearntqdmnatsortimportlibUser InstallationInstall usingpippip install pfc-toolkitUsageGenerate Functional Lesion Network MapsCreate a folder namedpfctoolkit_configin your home directory.mkdir ~/pfctoolkit_configSet up your precomputed connectome config file. An example config file is locatedhere. Make a copy of the config file to thepfctoolkit_configfolder. Edit the config file and swap out the precomputed connectome paths to where you have downloaded the connectome files on your machine.Run the precomputed connectome script. If your precomputed connectome config file is namedyeo1000_dil.json, the name of your precomputed connectome config isyeo1000_dil.connectome_precomputed-r<pathtodirectorycontainingrois>-c<nameofprecomputedconnectomeconfig>-o<outputdirectory>Generate a Precomputed Connectome (Instructions WIP)If instead of using the provided precomputed connectome, you would like to generate your own, first you need preprocessed BOLD fMRI timecourse data from a set of subjects. Each subject's preprocessed data must contain the same number of timepoints, must be registered to the same MNI152 space, and must be masked with the sameMASK. If you are not using the defaultMNI152_T1_2mm_brain_mask_dil.nii.gzmask file included with FSL, please usepfctoolkit.chunker.generate_chunk_maskto generate a chunk mask filechunk_idx.nii.gz.Once you have such data, for each subject please create two.npyfiles.For a subject with IDSUB001, the first.npyfile should be namedSUB001.npyand contain the preprocessed BOLD fMRI timecourse data in anumpyarray with shape(n_timepoints, n_voxels). The order of the voxels should be determined withnilearn.maskers.NiftiMasker.The second.npyfile should be namedSUB001_norms.npyand contain the norms of each voxel's BOLD fMRI timecourse signal in anumpyarray with shape(n_voxels,)in the same order as in the first.npyfile.After you have done this for all subjects in your dataset, please place all.npyfiles in a single "connectome" folder.Next, to generate functional connectivity chunks for the precomputed connectome, run the following script for each chunk indexi:generate_pfc_fc_chunks-b<nameofbrainmask>-c<pathtochunk_idx.nii.gz>-i<indexofchunktoprocess,i>-cs<pathtoconnectomedirectorycontaining.npyfiles>-o<pathtooutputdirectory>Please see additional usage instructions withgenerate_pfc_fc_chunks -h.Next, to generate combo chunks for the precomputed connectome, run the following script for each chunk indexi:generate_pfc_combo_chunks-b<nameofbrainmask>-c<pathtochunk_idx.nii.gz>-i<indexofchunktoprocess,i>-cs<pathtoconnectomedirectorycontaining.npyfiles>-o<pathtooutputdirectory>Please see additional usage instructions withgenerate_pfc_combo_chunks -h.Lastly, to generate BOLD timecourse norm and standard-deviation weighted masks for the precomputed connectome, run the following script for each chunk indexi:generate_pfc_weighted_masks-b<nameofbrainmask>-cs<pathtoconnectomedirectorycontaining.npyfiles>-n<nameofprecomputedconnectome>-o<pathtooutputdirectory>Please see additional usage instructions withgenerate_pfc_weighted_masks -h.DevelopmentSource codeYou can check the latest sources with the command:git clone https://github.com/thewilliamdrew/pfc-toolkit.gitHelp and SupportDocumentationDocumentation is locatedhere. (WIP)