-
Notifications
You must be signed in to change notification settings - Fork 291
PFMs #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
PFMs #378
Changes from 64 commits
f92be17
dc7db84
3041214
7346fbe
98ee4c2
359d752
427e75a
bcef6f5
23260a9
e45ea93
2868e12
42f9c98
da38924
61dd140
48f97b8
4375d35
e3d1986
47e2c86
1c17127
586b2e7
f0573be
5ce1478
3d5eee2
08533a1
1d3a04e
ed0e699
e354d0f
d1f57f9
85cceed
9922f37
f7d1d3d
5e26211
8cf3c8a
1764c3f
78a12a9
9b9618f
bb787d6
73efef6
1d5ad7c
cead749
4f8df64
64b0d78
63634d1
c377ddb
1c07db5
ce5480e
aad74dc
774d7d4
a888a26
d5edd76
1f7bcd9
0a7af01
acdca96
ddb9f13
bb4826b
47a38db
271f419
5b48d6f
aa474a0
9046688
4a109c7
b1fd5f9
9863892
111dec7
9c3d9b0
bd78fe2
3ba3bf5
90f5b20
4d19505
ae4f2af
9e66de1
d419332
9a9962a
e233cff
9b88271
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,248 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -eu | ||
|
|
||
| # This is an example script to run the full PFM postprocessing pipeline | ||
| # Steps involved: | ||
| # 1. RunPROFUMO - Run PROFUMO analysis | ||
| # 2. PostPROFUMO - Create time courses, spectra, and maps from PFM results | ||
| # 3. RSNRegression - Run RSN regression on PFM data for dual regression | ||
| # 4. GroupPFMs - Generate group-level statistics and averages | ||
| # | ||
| # Please make sure that PROFUMO, ICA-FIX, MSMAll and MakeAverageDataset are done properly | ||
| # matching the input arguments before running this PFM pipeline | ||
|
|
||
| get_options() { | ||
| local scriptName=$(basename "$0") | ||
| local arguments=("$@") | ||
|
|
||
| # initialize variables | ||
| StudyFolder="${HOME}/data/HCPpipelines_ExampleData" | ||
| Subjlist="100610@102311" | ||
| EnvironmentScript="${HOME}/projects/HCPpipelines/Examples/Scripts/SetUpHCPPipeline.sh" | ||
| GroupAverageName="S1200_MSMAll7T175" | ||
|
|
||
| RegName="MSMAll" | ||
| MatlabMode=1 | ||
| RunLocal=0 | ||
| QUEUE="matlabparallelhigh.q" | ||
|
|
||
| # parse arguments | ||
| local index argument | ||
|
|
||
| for ((index = 0; index < ${#arguments[@]}; ++index)) | ||
| do | ||
| argument="${arguments[index]}" | ||
|
|
||
| case "$argument" in | ||
| --StudyFolder=*) | ||
| StudyFolder="${argument#*=}" | ||
| ;; | ||
| --Subject=*) | ||
| Subjlist="${argument#*=}" | ||
| ;; | ||
| --EnvironmentScript=*) | ||
| EnvironmentScript="${argument#*=}" | ||
| ;; | ||
| --GroupAverageName=*) | ||
| GroupAverageName="${argument#*=}" | ||
| ;; | ||
| --RegName=*) | ||
| RegName="${argument#*=}" | ||
| ;; | ||
| --MatlabMode=*) | ||
| MatlabMode="${argument#*=}" | ||
| ;; | ||
| *) | ||
| echo "ERROR: Unrecognized Option: ${argument}" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| # check required parameters | ||
| if [[ "$StudyFolder" == "" ]] | ||
| then | ||
| echo "ERROR: StudyFolder not specified" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$Subjlist" == "" ]] | ||
| then | ||
| echo "ERROR: Subjlist not specified" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$EnvironmentScript" == "" ]] | ||
| then | ||
| echo "ERROR: EnvironmentScript not specified" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$GroupAverageName" == "" ]] | ||
| then | ||
| echo "ERROR: GroupAverageName not specified" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # if [[ "$RegName" == "" ]] | ||
| # then | ||
| # echo "ERROR: RegName not specified" | ||
| # exit 1 | ||
| # fi | ||
|
|
||
| if [[ "$MatlabMode" == "" ]] | ||
| then | ||
| echo "ERROR: MatlabMode not specified" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # report options | ||
| echo "-- ${scriptName}: Specified Command-Line Options: -- Start --" | ||
| echo " StudyFolder: ${StudyFolder}" | ||
| echo " Subjlist: ${Subjlist}" | ||
| echo " EnvironmentScript: ${EnvironmentScript}" | ||
| echo " GroupAverageName: ${GroupAverageName}" | ||
| echo " RegName: ${RegName}" | ||
| echo " MatlabMode: ${MatlabMode}" | ||
| echo "-- ${scriptName}: Specified Command-Line Options: -- End --" | ||
| } | ||
|
|
||
| # get command line options | ||
| get_options "$@" | ||
|
|
||
| # set up pipeline environment variables and software | ||
| source "${EnvironmentScript}" | ||
|
|
||
| if ((RunLocal)) || [[ "$QUEUE" == "" ]]; then | ||
| echo "running locally" | ||
| queuing_command=("$HCPPIPEDIR"/global/scripts/captureoutput.sh) | ||
| else | ||
| echo "queueing with fsl_sub to $QUEUE" | ||
| queuing_command=("$FSLDIR/bin/fsl_sub" -q "$QUEUE") | ||
| fi | ||
|
|
||
| # Download the PROFUMO Singularity image from the following link and place it in the PFM folder, | ||
| # or change the path below to point to your own copy of the image | ||
| # https://balsa.wustl.edu/myelin/download?dirName=public&filepath=profumo_v2.sif | ||
| ProfumoSingularity="$HCPPIPEDIR/PFM/profumo_v2.sif" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually stuff like this is handled in the HCP Pipelines setup script.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I commented earlier, unless we are expecting every user to be required to run PFMs, then downloading and specifying the location of the profumo container seems specific to only this pipeline, unlike FSL or wb_command, which are used by nearly all pipelines. Even for freesurfer, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I m thinking if we can make it overridable rather than required in the global setup: ProfumoSingularity="${ProfumoSingularity:-$HCPPIPEDIR/PFM/profumo_v2.sif}"That way users who don't run PFMs never have to set anything, but anyone running this regularly can export it from their setup script if they prefer.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't expect all end users to feel comfortable editing a line that has This particular container appears to be single-purpose for a single pipeline. As long as that is the case, I don't think it belongs in a centralized configuration location (where people who aren't running PFMs would have to read it and understand that the setting isn't relevant to them).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With regard to putting it in the setup script, if we make it optional in there, isn't that fine? I think it might be best to keep all external dependencies referenced in there instead of scattered across the pipelines. I don't think we currently have any external dependencies that are not in the setup script.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we expect nearly all users to run PFMs, it might make sense. For any user that isn't going to run PFMs, having it in the global setup would just be clutter that they have to read, understand, and then skip over. We can move it to a global location later if it becomes something that an overwhelming majority of users will need to do. Keeping the global setup short by only containing things that nearly all users need to do is a benefit to the user experience and gets them started faster before asking them to make judgement calls. "External" isn't the reason I put things in a global location, it is whether they are used in more than one pipeline (or aren't actually associated with any specific pipeline, like
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the long run, I think HippUnfold will be run by most/all users (as the future CIFTI grayordinates space will use hippocampal surfaces rather than hippocampal volumes). Also, in the long run, I think PFMs will be the primary functional network analysis tool. I am leaning strongly towards putting them in the setup script for that reason. |
||
|
|
||
| # general settings | ||
| # set the start step beginning from RunPROFUMO which is by default the first step | ||
| StartStep="RunPROFUMO" | ||
| StopStep="GroupPFMs" | ||
| NumWishart="6" | ||
| KeepWishartFiles="NO" | ||
|
|
||
| # set how many subjects to do in parallel (local, not cluster-distributed) during RSN regression, defaults to all detected physical cores, '-1' | ||
| parLimit=-1 | ||
|
|
||
| # general inputs | ||
| fMRINames="rfMRI_REST1_LR@rfMRI_REST1_RL@rfMRI_REST2_LR@rfMRI_REST2_RL" | ||
|
|
||
| randSeed=123 # random seed for PROFUMO | ||
|
|
||
| OutputfMRIName="rfMRI_REST" | ||
| # set the MR concat fMRI name, if multi-run FIX was used, leave empty for single runs | ||
| ConcatName="" | ||
|
|
||
| # set the output spectra size for individual projection, RunsXNumTimePoints #subjectExpectedTimepoints="3655" | ||
| subjectExpectedTimepoints="4800" | ||
|
|
||
| # set temporal highpass full-width (2*sigma) used in preprocessing | ||
| HighPass="2000" | ||
|
|
||
| #set fMRIResolution of data, like '2','1.60' or '2.40' | ||
| fMRIResolution="2.0" | ||
|
|
||
| # PFM settings for REST data | ||
| # set the PFM dimensionality | ||
| PFMdim="76" | ||
|
|
||
| PFMFolder=${StudyFolder}/$GroupAverageName/MNINonLinear/Results/${OutputfMRIName}_PFM_d${PFMdim} | ||
| # Reference image for PROFUMO | ||
| RefImage="${StudyFolder}/$GroupAverageName/MNINonLinear/Results/${OutputfMRIName}/${OutputfMRIName}_Atlas_MSMAll_hp${HighPass}_clean_rclean_tclean_meanvn.dscalar.nii" | ||
|
|
||
| # set the file name component representing the preprocessing already done | ||
| fMRIProcSTRING="hp${HighPass}_clean_rclean_tclean" | ||
|
|
||
| # set the mesh resolution, like '32' for 32k_fs_LR | ||
| LowResMesh="32" | ||
|
|
||
| # Define OutputSTRING with seed designation | ||
| OutputSTRING="${OutputfMRIName}_d${PFMdim}_${GroupAverageName}_seed${randSeed}_PFMs" | ||
|
|
||
| # RSN regression settings | ||
| FixLegacyBiasString="NO" | ||
| ScaleFactor="0.01" | ||
|
|
||
| # Volume template file | ||
| VolumeTemplateCIFTI="${HOME}/data/HCPpipelines_ExampleData/${GroupAverageName}/MNINonLinear/${GroupAverageName}_CIFTIVolumeTemplate_${OutputfMRIName}.${fMRIResolution}.dscalar.nii" | ||
|
|
||
| ## PROFUMO settings | ||
| ProfumoConfig="${PFMFolder}/dataLocations.json" | ||
| TR="0.72" | ||
| ProfumoThreads="-1" # number of threads for PROFUMO, -1 means auto-detect physical cores | ||
| DOFCorrection="0.5" | ||
| CovModel="Subject" | ||
| nStarts="5" # number of multi-start iterations for PROFUMO | ||
| RandomSeed="$randSeed" # random seed for PROFUMO reproducibility | ||
| # RefImage will be auto-set based on data type below | ||
|
|
||
| # build Profumo data location json | ||
| mkdir -p $PFMFolder | ||
| echo '{' > $ProfumoConfig | ||
| for Subject in $(echo $Subjlist | tr "@" "\n"); do | ||
| echo -e "\t\"$Subject\": {" >> $ProfumoConfig | ||
| for fMRIName in $(echo $fMRINames | tr "@" "\n"); do | ||
| runFile="${StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}_Atlas${RegString}_${fMRIProcSTRING}.dtseries.nii" | ||
| if [[ -e $runFile ]]; then | ||
| echo -e "\t\t\"$fMRIName\": \"$runFile\"," >> $ProfumoConfig | ||
| fi | ||
| done | ||
| perl -pi -e 'if (eof) { s/,$// }' $ProfumoConfig # remove trailing comma | ||
| echo -e "\t}," >> $ProfumoConfig | ||
| done | ||
| perl -pi -e 'if (eof) { s/,$// }' $ProfumoConfig # remove trailing comma | ||
| echo "}" >> $ProfumoConfig | ||
|
|
||
| # PFM pipeline execution | ||
| echo "Starting PFM postprocessing pipeline" | ||
| echo "Data type: ${OutputfMRIName}" | ||
| echo "PFM dimension: ${PFMdim}" | ||
|
|
||
| "${queuing_command[@]}" "$HCPPIPEDIR"/PFM/PFMPipeline.sh \ | ||
| --study-folder="$StudyFolder" \ | ||
| --subject-list="$Subjlist" \ | ||
| --fmri-names="$fMRINames" \ | ||
| --output-fmri-name="$OutputfMRIName" \ | ||
| --output-string="$OutputSTRING" \ | ||
| --proc-string="$fMRIProcSTRING" \ | ||
| --group-average-name="$GroupAverageName" \ | ||
| --pfm-dimension="$PFMdim" \ | ||
| --pfm-folder="$PFMFolder" \ | ||
| --surf-reg-name="$RegName" \ | ||
| --concat-name="$ConcatName" \ | ||
| --low-res-mesh="$LowResMesh" \ | ||
| --runs-timepoints="$subjectExpectedTimepoints" \ | ||
| --fix-legacy-bias="$FixLegacyBiasString" \ | ||
| --num-wishart="$NumWishart"\ | ||
| --scale-factor="$ScaleFactor" \ | ||
| --starting-step="$StartStep" \ | ||
| --stop-after-step="$StopStep" \ | ||
| --parallel-limit="$parLimit" \ | ||
| --matlab-run-mode="$MatlabMode" \ | ||
| --profumo-config="$ProfumoConfig" \ | ||
| --profumo-singularity="$ProfumoSingularity" \ | ||
| --profumo-tr="$TR" \ | ||
| --keep-wishart-files="$KeepWishartFiles" \ | ||
| --profumo-threads="$ProfumoThreads" \ | ||
| --profumo-dof-correction="$DOFCorrection" \ | ||
| --profumo-cov-model="$CovModel" \ | ||
| --profumo-multi-start-iterations="$nStarts" \ | ||
| --profumo-random-seed="$RandomSeed" \ | ||
| --ref-image="$RefImage" \ | ||
| --volume-template-file="$VolumeTemplateCIFTI" | ||
|
|
||
| echo "PFM pipeline submitted successfully!" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| *.sif |
Uh oh!
There was an error while loading. Please reload this page.