From 043bcbbc8084c1dab7d15e9be232c613ca26d781 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Wed, 12 Jul 2023 20:19:22 -0500 Subject: [PATCH 01/23] create sub-folder in outputs if requested; not tested yet --- babs/babs.py | 19 ++- babs/constants.py | 5 + babs/utils.py | 138 ++++++++++++++---- .../eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml | 5 - ..._fmriprepfake-unstable_full_slurm_msi.yaml | 49 +++++++ 5 files changed, 176 insertions(+), 40 deletions(-) create mode 100644 notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml diff --git a/babs/babs.py b/babs/babs.py index c52fa2d1..00f7e0f2 100644 --- a/babs/babs.py +++ b/babs/babs.py @@ -25,6 +25,7 @@ generate_cmd_set_envvar, generate_cmd_filterfile, generate_cmd_singularityRun_from_config, generate_cmd_unzip_inputds, + get_info_zip_foldernames, generate_cmd_zipping_from_config, validate_type_session, validate_type_system, @@ -2257,10 +2258,9 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): When writing `singularity run` part, each chunk to write should start with " \\" + "\n\t", meaning, starting with space, a backward slash, a return, and a tab. """ - from .constants import PATH_FS_LICENSE_IN_CONTAINER + from .constants import PATH_FS_LICENSE_IN_CONTAINER, OUTPUT_MAIN_FOLDERNAME type_session = validate_type_session(type_session) - output_foldername = "outputs" # folername of BIDS App outputs # Check if the folder exist; if not, create it: bash_dir = op.dirname(bash_path) @@ -2268,6 +2268,7 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): os.makedirs(bash_dir) # check if `self.config` from the YAML file contains information we need: + # 1. check `singularity_run` section: if "singularity_run" not in self.config: # sanity check: there should be only one input ds # otherwise need to specify in this section: @@ -2295,10 +2296,14 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): cmd_singularity_flags, flag_fs_license, path_fs_license, singuRun_input_dir = \ generate_cmd_singularityRun_from_config(self.config, input_ds) - print() - # TODO: also corporate the `call-fmt` in `datalad containers-add` + # 2. check `zip_foldernames` section: + dict_zip_foldernames, if_mk_output_folder, path_output_folder = \ + get_info_zip_foldernames(self.config) + + print() + # Check if the bash file already exist: if op.exists(bash_path): os.remove(bash_path) # remove it @@ -2386,7 +2391,7 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): cmd_head_singularityRun += " \\" + "\n\t" cmd_head_singularityRun += singuRun_input_dir # inputs/data/ cmd_head_singularityRun += " \\" + "\n\t" - cmd_head_singularityRun += output_foldername # output folder + cmd_head_singularityRun += path_output_folder # defined above # currently all BIDS App support `participant` positional argu: cmd_head_singularityRun += " \\" + "\n\t" @@ -2411,7 +2416,7 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): print(cmd_head_singularityRun + cmd_singularity_flags) # Zip: - cmd_zip = generate_cmd_zipping_from_config(self.config, type_session, output_foldername) + cmd_zip = generate_cmd_zipping_from_config(dict_zip_foldernames, type_session) bash_file.write(cmd_zip) # Delete folders and files: @@ -2419,7 +2424,7 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): rm -rf prep .git/tmp/wkdir rm ${filterfile} """ - cmd_clean = "rm -rf " + output_foldername + " " + ".git/tmp/wkdir" + "\n" + cmd_clean = "rm -rf " + path_output_folder + " " + ".git/tmp/wkdir" + "\n" if flag_filterfile is True: cmd_clean += "rm ${filterfile}" + " \n" diff --git a/babs/constants.py b/babs/constants.py index 451ab9f6..dfb1c6b8 100644 --- a/babs/constants.py +++ b/babs/constants.py @@ -1,3 +1,8 @@ MSG_NO_ALERT_IN_LOGS = "BABS: No alert message found in log files." CHECK_MARK = u'\N{check mark}' # can be used by print(CHECK_MARK) PATH_FS_LICENSE_IN_CONTAINER = "/SGLR/FREESURFER_HOME/license.txt" + +# The upper layer of output folder - BABS expects there are sub-folers in it to zip: +OUTPUT_MAIN_FOLDERNAME = "outputs" +# Placeholder for creating a sub-folder to hold all outputs: +PLACEHOLDER_MK_SUB_OUTPUT_FOLDER = "$TO_CREATE_FOLDER" diff --git a/babs/utils.py b/babs/utils.py index b8f3ba2b..c295a828 100644 --- a/babs/utils.py +++ b/babs/utils.py @@ -442,20 +442,105 @@ def generate_cmd_set_envvar(env_var_name): return cmd, env_var_value, env_var_value_in_container - -def generate_cmd_zipping_from_config(config, type_session, output_foldername="outputs"): +def get_info_zip_foldernames(config): """ - This is to generate bash command to zip BIDS App outputs. + This is to get information from `zip_foldernames` section + in the container configuration YAML file. + Note that users have option to request creating a sub-folder in `outputs` folder, + if the BIDS App does not do so (e.g., fMRIPrep new BIDS output layout). + + Information: + 1. foldernames to zip + 2. whether the user requests creating a sub-folder + 3. path to the output dir to be used in the `singularity run` Parameters: ------------ config: dictionary attribute `config` in class Container; got from `read_container_config_yaml()` + + Returns: + --------- + dict_zip_foldernames: dict + `config["zip_foldernames"]` w/ placeholder key/value pair removed. + if_mk_folder: bool + whether requested to create a sub-folder in `outputs`. + path_output_folder: str + output folder used in `singularity run` of the BIDS App. + see examples below. + + Examples `path_output_folder` of BIDS App: + ------------------------------------------------- + In `zip_foldernames` section: + 1. No placeholder: outputs + 2. placeholder = true & 1 folder: outputs/ + + Notes: + ---------- + In fact, we use `OUTPUT_MAIN_FOLDERNAME` to define the 'outputs' string. + """ + + from .constants import OUTPUT_MAIN_FOLDERNAME, PLACEHOLDER_MK_SUB_OUTPUT_FOLDER + + # Sanity check: this section should exist: + if "zip_foldernames" not in config: + raise Exception("The `container_config_yaml_file` does not contain" + + " the section `zip_foldernames`. Please add this section!") + + # Check if placeholder to make a sub-folder in `outputs` folder: + if_mk_folder = False + if PLACEHOLDER_MK_SUB_OUTPUT_FOLDER in config["zip_foldernames"]: + # check its value: + # there cannot be two placeholders (w/ same strings); + # otherwise error when loading yaml file + value = config["zip_foldernames"][PLACEHOLDER_MK_SUB_OUTPUT_FOLDER] + if value == "true": + if_mk_folder = True + + # Get the dict of foldernames + version number: + dict_zip_foldernames = config["zip_foldernames"] + if if_mk_folder: + # remove key of placeholder if there is: + _ = dict_zip_foldernames.pop(PLACEHOLDER_MK_SUB_OUTPUT_FOLDER) + # ^^ the returned value is the value of this key + + # sanity check: if there was placeholder, we expect only one output folder to create: + if len(dict_zip_foldernames) == 1: # good + pass + elif len(dict_zip_foldernames) == 0: # only placeholder was provided: + raise Exception("Only placeholder '" + PLACEHOLDER_MK_SUB_OUTPUT_FOLDER + "'" + + " is provided in section 'zip_foldernames'." + + " You should also provide" + + " a name of output folder to create and zip.") + else: # len(dict_zip_foldernames) > 1: # more than one foldernames provided: + raise Exception("You ask BABS to create more than one output folder," + + " but BABS can only create one output folder." + + " Please only keep one of them in 'zip_foldernames' section.") + + # Get the list of foldernames (w/o version number): + list_foldernames = list(dict_zip_foldernames.keys()) + + # Generate the output folder path: + path_output_folder = OUTPUT_MAIN_FOLDERNAME + if if_mk_folder: + the_folder = list_foldernames[0] # there is only one folder + path_output_folder += "/" + the_folder + + return dict_zip_foldernames, if_mk_folder, path_output_folder + + +def generate_cmd_zipping_from_config(dict_zip_foldernames, type_session): + """ + This is to generate bash command to zip BIDS App outputs. + + Parameters: + ------------ + dict_zip_foldernames: dictionary + `config["zip_foldernames"]` w/ placeholder key/value pair removed. + got from `get_info_zip_foldernames()`. type_session: str "multi-ses" or "single-ses" - output_foldername: str - the foldername of the outputs of BIDS App; default is "outputs". Returns: --------- @@ -464,8 +549,10 @@ def generate_cmd_zipping_from_config(config, type_session, output_foldername="ou based on section `zip_foldernames` in the yaml file. """ + from .constants import OUTPUT_MAIN_FOLDERNAME + # cd to output folder: - cmd = "cd " + output_foldername + "\n" + cmd = "cd " + OUTPUT_MAIN_FOLDERNAME + "\n" # 7z: if type_session == "multi-ses": @@ -473,28 +560,23 @@ def generate_cmd_zipping_from_config(config, type_session, output_foldername="ou else: str_sesid = "" - if "zip_foldernames" in config: - value_temp = "" - temp = 0 - - for key, value in config["zip_foldernames"].items(): - # each key is a foldername to be zipped; - # each value is the version string; - temp = temp + 1 - if (temp != 1) & (value_temp != value): # not matching last value - warnings.warn("In section `zip_foldernames` in `container_config_yaml_file`: \n" - "The version string of '" + key + "': '" + value + "'" - + " does not match with the last version string; " - + "we suggest using the same version string across all foldernames.") - value_temp = value - - cmd += "7z a ../${subid}" + str_sesid + "_" + \ - key + "-" + value + ".zip" + " " + key + "\n" - # e.g., 7z a ../${subid}_${sesid}_fmriprep-0-0-0.zip fmriprep # this is multi-ses - - else: # the yaml file does not have the section `zip_foldernames`: - raise Exception("The `container_config_yaml_file` does not contain" - + " the section `zip_foldernames`. Please add this section!") + # start to generate 7z commands: + value_temp = "" + temp = 0 + for key, value in dict_zip_foldernames.items(): + # each key is a foldername to be zipped; + # each value is the version string; + temp = temp + 1 + if (temp != 1) & (value_temp != value): # not matching last value + warnings.warn("In section `zip_foldernames` in `container_config_yaml_file`: \n" + "The version string of '" + key + "': '" + value + "'" + + " does not match with the last version string; " + + "we suggest using the same version string across all foldernames.") + value_temp = value + + cmd += "7z a ../${subid}" + str_sesid + "_" + \ + key + "-" + value + ".zip" + " " + key + "\n" + # e.g., 7z a ../${subid}_${sesid}_fmriprep-0-0-0.zip fmriprep # this is multi-ses # return to original dir: cmd += "cd ..\n" diff --git a/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml b/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml index 0d877816..c56f58c5 100644 --- a/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml +++ b/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml @@ -53,11 +53,6 @@ script_preamble: | source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. conda activate babs # [FIX ME] replace 'babs' with your env variable name -# ^^ conda env above: where the scripts generated by BABS will run -# not necessary the same one for running `babs-init` -# ^^ based on what you need on your cluster; some people even don't use `conda`... -# for MSI, might need to add command e.g., "module_load" - # Where to run the jobs: job_compute_space: "/tmp" # [FIX ME] MSI cluster diff --git a/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml b/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml new file mode 100644 index 00000000..c88adb04 --- /dev/null +++ b/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml @@ -0,0 +1,49 @@ +# This is an example config yaml file for fmriprep-fake version 'unstable'. +# fmriprep-fake's Docker image is publicly available at: https://hub.docker.com/r/djarecka/fmriprep_fake + # However, the version we use here is available at: https://hub.docker.com/r/chenyingzhao/fmriprep_fake +# fmriprep-fake generates fMRIPrep outputs without running fMRIPrep itself. You may use it to check fmriprep outputs. +# More details please see: https://github.com/djarecka/fmriprep-fake +# Thanks to Dorota Jarecka for preparing and sharing this BIDS App! + +# Warning!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the toy BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# 'singularity_run': There is no such section for fmriprep-fake +# as all commands needed by fmriprep-fake have been handled by BABS. + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +zip_foldernames: + fmriprepfake: "unstable" # folder 'fmriprepfake' will be zipped into 'sub-xx_ses-yy_fmriprepfake-0-1-1.zip' + +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 2G + temporary_disk_space: 20G + hard_runtime_limit: "20" # 20min + customized_text: | + #SBATCH -p amd2tb,ram256g +# Other choices of job partitions on MSI: amd2tb,ram256g,v100,k40 +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters + +# Users need to add their customized bash command below, +# they will be used as preambles in `participant_job.sh` +# the commands should not be quoted! +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# Below is to filter out subjects (or sessions) +# right now we only filter based on unzipped dataset +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# 'alert_log_messages': not to include this section for now. From 92621da1124a1736eedfc85a31fd14fb094c9e52 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 13 Jul 2023 15:16:52 -0500 Subject: [PATCH 02/23] minor fix --- babs/babs.py | 3 +- babs/utils.py | 2 +- notebooks/show_babs_init_InputBIDS.ipynb | 36 ++++++++++++------------ 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/babs/babs.py b/babs/babs.py index 00f7e0f2..78024e0a 100644 --- a/babs/babs.py +++ b/babs/babs.py @@ -2424,7 +2424,8 @@ def generate_bash_run_bidsapp(self, bash_path, input_ds, type_session): rm -rf prep .git/tmp/wkdir rm ${filterfile} """ - cmd_clean = "rm -rf " + path_output_folder + " " + ".git/tmp/wkdir" + "\n" + cmd_clean = "rm -rf " + OUTPUT_MAIN_FOLDERNAME + " " + ".git/tmp/wkdir" + "\n" + # ^^ rm the entire output folder `outputs` if flag_filterfile is True: cmd_clean += "rm ${filterfile}" + " \n" diff --git a/babs/utils.py b/babs/utils.py index c295a828..f53794a3 100644 --- a/babs/utils.py +++ b/babs/utils.py @@ -495,7 +495,7 @@ def get_info_zip_foldernames(config): # there cannot be two placeholders (w/ same strings); # otherwise error when loading yaml file value = config["zip_foldernames"][PLACEHOLDER_MK_SUB_OUTPUT_FOLDER] - if value == "true": + if value.lower() == "true": # lower case is "true" if_mk_folder = True # Get the dict of foldernames + version number: diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index aa6d1b9b..e914d462 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -40,14 +40,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/cbica/projects/BABS/babs/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml\n" + "/home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml\n" ] } ], @@ -55,13 +55,13 @@ "# This notebook only accepts toybidsapp_rawBIDS, qsiprep or fmriprep\n", "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", - "bidsapp = \"qsiprep\"\n", - "task_name = \"sloppy\" # for fmriprep: 'anatonly', 'sloppy'; for toybidsapp: 'rawBIDS'\n", + "bidsapp = \"fmriprepfake\"\n", + "task_name = \"full\" # for fmriprep: 'anatonly', 'sloppy'; for toybidsapp: 'rawBIDS'\n", "type_session = \"multi-ses\"\n", - "which_dataset = \"toy_real\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\"\n", + "which_dataset = \"toy_fake\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\"\n", "\n", - "flag_where = \"cubic\" # \"cubic\" or \"local\" or \"msi\"\n", - "type_system = \"sge\" # \"sge\" or \"slurm\"\n", + "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", + "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", "# ++++++++++++++++++++++++++++++++++\n", "\n", "# sanity checks:\n", @@ -124,7 +124,7 @@ "elif bidsapp == \"qsiprep\":\n", " container_name = bidsapp + \"-0-16-0RC3\"\n", "elif bidsapp == \"fmriprepfake\":\n", - " container_name = bidsapp + \"-0-1-1\"\n", + " container_name = bidsapp + \"-unstable\" # +++++++++\n", "else:\n", " raise Exception(\"Invalid `flag_instance`!\")\n", "\n", @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -173,14 +173,14 @@ "text": [ "The command to execute:\n", "babs-init \\\n", - "\t--where_project /cbica/projects/BABS/data \\\n", - "\t--project_name test_babs_multi-ses_qsiprep_sloppy \\\n", - "\t--input BIDS /cbica/projects/BABS/data/testdata_NKI/data_hashedID_bids \\\n", - "\t--container_ds /cbica/projects/BABS/data/qsiprep-container \\\n", - "\t--container_name qsiprep-0-16-0RC3 \\\n", - "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml \\\n", + "\t--where_project /home/faird/zhaoc/data \\\n", + "\t--project_name test_babs_multi-ses_fmriprepfake_full \\\n", + "\t--input BIDS https://osf.io/w2nu3/ \\\n", + "\t--container_ds /home/faird/zhaoc/data/fmriprepfake-container \\\n", + "\t--container_name fmriprepfake-unstable \\\n", + "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml \\\n", "\t--type_session multi-ses \\\n", - "\t--type_system sge\n", + "\t--type_system slurm\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] } @@ -215,7 +215,7 @@ ], "metadata": { "kernelspec": { - "display_name": "mydatalad", + "display_name": "babs", "language": "python", "name": "python3" }, @@ -234,7 +234,7 @@ "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "abcc7813313a81f6f916a4574498d1c2de65ad7fdfeb04d04cdf237cdcbdda8b" + "hash": "2538d15ebb217aff7ed13fa29cc6f5f706af190e6008d76f30d7ce8c1383d79a" } } }, From b15513e44a53b8f97e1e685bb25650a9c8a81755 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 13 Jul 2023 15:18:15 -0500 Subject: [PATCH 03/23] tested w/ BABS commit 92621da; probably 0.0.4+76 --- notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml b/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml index c88adb04..cd5a58d9 100644 --- a/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml +++ b/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml @@ -16,6 +16,7 @@ # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): zip_foldernames: + $TO_CREATE_FOLDER: "true" fmriprepfake: "unstable" # folder 'fmriprepfake' will be zipped into 'sub-xx_ses-yy_fmriprepfake-0-1-1.zip' cluster_resources: From 12814a621016fdc5a53d95beeb9da3cf58d4a8e3 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 13 Jul 2023 17:00:55 -0500 Subject: [PATCH 04/23] tested w/ BABS version 0.0.4+77.gb15513e --- ...eg_fmriprepfake-0-1-2_full_slurm_msi.yaml} | 0 ...epfake-0-1-2_legacy-layout_slurm_msi.yaml} | 34 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) rename notebooks/{eg_fmriprepfake-unstable_full_slurm_msi.yaml => eg_fmriprepfake-0-1-2_full_slurm_msi.yaml} (100%) rename notebooks/{eg_fmriprepfake-0-1-1_full_sge_cubic.yaml => eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml} (54%) diff --git a/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml b/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml similarity index 100% rename from notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml rename to notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml diff --git a/notebooks/eg_fmriprepfake-0-1-1_full_sge_cubic.yaml b/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml similarity index 54% rename from notebooks/eg_fmriprepfake-0-1-1_full_sge_cubic.yaml rename to notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml index 46622b98..358d742d 100644 --- a/notebooks/eg_fmriprepfake-0-1-1_full_sge_cubic.yaml +++ b/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml @@ -1,5 +1,6 @@ -# This is an example config yaml file for fmriprep-fake version 0.1.0. +# This is an example config yaml file for fmriprep-fake version 'unstable'. # fmriprep-fake's Docker image is publicly available at: https://hub.docker.com/r/djarecka/fmriprep_fake + # However, the version we use here is available at: https://hub.docker.com/r/chenyingzhao/fmriprep_fake # fmriprep-fake generates fMRIPrep outputs without running fMRIPrep itself. You may use it to check fmriprep outputs. # More details please see: https://github.com/djarecka/fmriprep-fake # Thanks to Dorota Jarecka for preparing and sharing this BIDS App! @@ -10,33 +11,36 @@ # or be compatible to the toy BIDS App version you're using. # Therefore, please change and tailor it for your case before use it!!! -# 'singularity_run': There is no such section for fmriprep-fake -# as all commands needed by fmriprep-fake have been handled by BABS. +# Arguments in `singularity run`: +singularity_run: + --output-layout: "legacy" # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# For `--output-layout legacy`, users don't need to create the output folder, +# as all derivatives are in 'fmriprep' or 'freesurfer' folder. zip_foldernames: - fmriprepfake: "0-1-1" # folder 'fmriprepfake' will be zipped into 'sub-xx_ses-yy_fmriprepfake-0-1-1.zip' + fmriprep: "0-1-2" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-0-1-2.zip' + freesurfer: '0-1-2' # folder 'freesurfer' will be zipped into 'sub-xx_ses-yy_freesurfer-0-1-2.zip' cluster_resources: - interpreting_shell: /bin/bash # "-S /bin/bash" on cubic - hard_memory_limit: 2G # "-l h_vmem=25G" on cubic - temporary_disk_space: 20G # "-l tmpfree=50G" on cubic # this is highly-recommended on cubic - hard_runtime_limit: "24:00:00" # needed by cubic for PennLINC lab members; otherwise jobs will be sent to generic nodes + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 2G + temporary_disk_space: 20G + hard_runtime_limit: "20" # 20min customized_text: | - #$ -R y - #$ -l hostname=!compute-fed* -# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. -# So it's probably not relevant for other clusters + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters # Users need to add their customized bash command below, # they will be used as preambles in `participant_job.sh` # the commands should not be quoted! script_preamble: | - source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name - echo "I am running BABS." # this is an example command to show how to add another line; not necessary to include. + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name # Where to run the jobs: -job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space +job_compute_space: "/tmp" # [FIX ME] MSI cluster # Below is to filter out subjects (or sessions) # right now we only filter based on unzipped dataset From c70f65073248b02da9dafb66b928bee7f094a4fe Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 13 Jul 2023 17:03:14 -0500 Subject: [PATCH 05/23] cupdate fmriprep-fake to 0.1.2; update README; changemsi partitioons --- notebooks/README.md | 14 +++++++++++++- notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml | 3 +-- .../eg_fmriprepfake-0-1-2_full_slurm_msi.yaml | 4 ++-- .../eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml | 3 +-- notebooks/show_babs_init_InputBIDS.ipynb | 12 ++++++------ 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index 8357b6b0..0003fe4b 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -21,8 +21,20 @@ | [link](eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml) | fMRIPrep | 20.2.3 | fMRIPrep with FreeSurfer results ingressed | one raw BIDS dataset + one zipped BIDS derivatives dataset (of FreeSurfer results) | SGE | | | [link](eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml) | fMRIPrep | 20.2.3 | fMRIPrep `--sloppy` mode | one raw BIDS dataset | SGE | ⚠️ WARNING: only for testing! ⚠️ | | [link](eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml) | fMRIPrep | 20.2.3 | fMRIPrep `--sloppy` mode | one raw BIDS dataset | Slurm | ⚠️ WARNING: only for testing! ⚠️ | -| [link](eg_fmriprepfake-0-1-1_full_sge_cubic.yaml) | fmriprep-fake | 0.1.1 | fmriprep-fake, mimicking legend output layout of fMRIPrep | one raw BIDS dataset | SGE | | +| [link](eg_fmriprepfake-0-1-2_full_slurm_msi.yaml) | fmriprep-fake | 0.1.2 | fmriprep-fake, mimicking current *BIDS output layout* of fMRIPrep (v21.0+) | one raw BIDS dataset | Slurm | | +| [link](eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml) | fmriprep-fake | 0.1.2 | fmriprep-fake, mimicking *legacy output layout* of fMRIPrep (< v21.0) | one raw BIDS dataset | Slurm | | | [link](eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | SGE | ⚠️ WARNING: only for testing! ⚠️ | | [link](eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | Slurm | ⚠️ WARNING: only for testing! ⚠️ | | [link](eg_xcpd-0-3-0_full_sge_cubic.yaml ) | XCP-D | 0.3.0 | XCP full run | one zipped BIDS derivatives dataset (of fMRIPrep results) | SGE | | +### BIDS App links +| BIDS App | Function | Docker Hub | Docs | Notes | +| :-- | :--|:-- | :-- |:-- | +| fMRIPrep | Preprocessing fMRI data | ___ | ___ | The default output layout changed in `21.0.0`. BABS YAML files for new BIDS layout and legacy layout are different. | +| QSIPrep | Preprocessing dMRI data | ___ | ____ | | +| XCP-D | Post-processing fMRI data | ____ | _____ | The 0.4.0 version is labeled as `04.0` on Docker Hub. | +| toy BIDS App | Quick test of BABS | ____ | _____ | | +| fmriprep-fake | Mimicking fMRIPrep derivatives, for quick test | ____ | _____ | | + +* fMRI = functional MRI +* dMRI = diffusion MRI diff --git a/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml b/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml index c56f58c5..c40a98dc 100644 --- a/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml +++ b/notebooks/eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml @@ -41,8 +41,7 @@ cluster_resources: temporary_disk_space: 200G # --> "#SBATCH --tmp=200G" hard_runtime_limit: "72:00:00" # --> "--time=72:00:00", i.e., 3 days. Should NOT large than partition's time limit! customized_text: | - #SBATCH -p k40 -# Other choices of job partitions on MSI: amd2tb,ram256g,v100,k40 + #SBATCH -p amd2tb,ram256g # Notes: Above `customized_text` is MSI Slurm cluster specific. # So it may not be relevant for other clusters diff --git a/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml b/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml index cd5a58d9..8bd061c5 100644 --- a/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml +++ b/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml @@ -15,9 +15,10 @@ # as all commands needed by fmriprep-fake have been handled by BABS. # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprepfake' to wrap all derivatives: zip_foldernames: $TO_CREATE_FOLDER: "true" - fmriprepfake: "unstable" # folder 'fmriprepfake' will be zipped into 'sub-xx_ses-yy_fmriprepfake-0-1-1.zip' + fmriprepfake: "0-1-2" # folder 'fmriprepfake' will be zipped into 'sub-xx_ses-yy_fmriprepfake-0-1-2.zip' cluster_resources: interpreting_shell: "/bin/bash -l" @@ -26,7 +27,6 @@ cluster_resources: hard_runtime_limit: "20" # 20min customized_text: | #SBATCH -p amd2tb,ram256g -# Other choices of job partitions on MSI: amd2tb,ram256g,v100,k40 # Notes: Above `customized_text` is MSI Slurm cluster specific. # So it may not be relevant for other clusters diff --git a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml index e292b7bf..a6d9f2cc 100644 --- a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml +++ b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml @@ -41,8 +41,7 @@ cluster_resources: number_of_cpus: "6" # --> "#SBATCH --cpus-per-task=6" hard_runtime_limit: "48:00:00" # --> "--time=48:00:00", i.e., 2 days. Should NOT large than partition's time limit! customized_text: | - #SBATCH -p ram256g -# Other choices of job partitions on MSI: amd2tb,ram256g,v100,k40 + #SBATCH -p amd2tb,ram256g # Notes: Above `customized_text` is MSI Slurm cluster specific. # So it may not be relevant for other clusters diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index e914d462..89ca92ac 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -47,7 +47,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "/home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml\n" + "/home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml\n" ] } ], @@ -56,7 +56,7 @@ "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", "bidsapp = \"fmriprepfake\"\n", - "task_name = \"full\" # for fmriprep: 'anatonly', 'sloppy'; for toybidsapp: 'rawBIDS'\n", + "task_name = \"legacy-layout\" # for fmriprep: 'anatonly', 'sloppy'; for toybidsapp: 'rawBIDS'\n", "type_session = \"multi-ses\"\n", "which_dataset = \"toy_fake\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\"\n", "\n", @@ -124,7 +124,7 @@ "elif bidsapp == \"qsiprep\":\n", " container_name = bidsapp + \"-0-16-0RC3\"\n", "elif bidsapp == \"fmriprepfake\":\n", - " container_name = bidsapp + \"-unstable\" # +++++++++\n", + " container_name = bidsapp + \"-0-1-2\"\n", "else:\n", " raise Exception(\"Invalid `flag_instance`!\")\n", "\n", @@ -174,11 +174,11 @@ "The command to execute:\n", "babs-init \\\n", "\t--where_project /home/faird/zhaoc/data \\\n", - "\t--project_name test_babs_multi-ses_fmriprepfake_full \\\n", + "\t--project_name test_babs_multi-ses_fmriprepfake_legacy-layout \\\n", "\t--input BIDS https://osf.io/w2nu3/ \\\n", "\t--container_ds /home/faird/zhaoc/data/fmriprepfake-container \\\n", - "\t--container_name fmriprepfake-unstable \\\n", - "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-unstable_full_slurm_msi.yaml \\\n", + "\t--container_name fmriprepfake-0-1-2 \\\n", + "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml \\\n", "\t--type_session multi-ses \\\n", "\t--type_system slurm\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" From 6a98e15052d811b8303656374d9137fdfea96b83 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Fri, 14 Jul 2023 15:02:04 -0500 Subject: [PATCH 06/23] add eg yaml files: tested w/ BABS 0.0.4+77.gb15513e --- ...fmriprepfake-0-1-2_anatonly_slurm_msi.yaml | 54 +++++++++++++++++++ .../eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml | 44 +++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 notebooks/eg_fmriprepfake-0-1-2_anatonly_slurm_msi.yaml create mode 100644 notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml diff --git a/notebooks/eg_fmriprepfake-0-1-2_anatonly_slurm_msi.yaml b/notebooks/eg_fmriprepfake-0-1-2_anatonly_slurm_msi.yaml new file mode 100644 index 00000000..32a9c1ae --- /dev/null +++ b/notebooks/eg_fmriprepfake-0-1-2_anatonly_slurm_msi.yaml @@ -0,0 +1,54 @@ +# This is an example config yaml file for: +# BIDS App: fmriprep-fake +# BIDS App version: 0.1.2 +# Task: `--anat-only` mode +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster + +# Warning!!! +# although `fmriprep-fake` version 0.1.2 takes argument `--anat-only`, it won't do anything different, +# and it will still generate all derivatives (including fMRI data derivatives)... +# Therefore, this is only for testing purpose! + +# Warning!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +singularity_run: + --anat-only: "" + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep_anat' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep_anat: "0-1-2" # folder 'fmriprep_anat' will be zipped into 'sub-xx_(ses-yy_)fmriprep_anat-0-1-2.zip' + +# How much cluster resources it needs: +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 2G + temporary_disk_space: 20G + hard_runtime_limit: "20" # 20min + customized_text: | + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +# Because of `--anat-only`, func bold data is not needed. +required_files: + $INPUT_DATASET_#1: + - "anat/*_T1w.nii*" + +# 'alert_log_messages': not included in this example, but you may add it! diff --git a/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml b/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml new file mode 100644 index 00000000..ef742389 --- /dev/null +++ b/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml @@ -0,0 +1,44 @@ +# This is an example config yaml file for: +# BIDS App: toy BIDS App "toy_bids_app" +# BIDS App version: 0.0.7 +# Task: `--zipped`, for application to zipped BIDS derivatives dataset +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster + +# Warning!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +singularity_run: + --zipped: "" # for zipped input dataset + --dummy: "2" # this is a dummy variable, accepting values + -v: "" # this is also a dummy variable, not accepting values + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +zip_foldernames: + toybidsapp: "0-0-7" # folder 'toybidsapp' will be zipped into 'sub-xx_(ses-yy_)toybidsapp-0-0-7.zip' + +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 25G + temporary_disk_space: 50G + hard_runtime_limit: "20" # 20min + customized_text: | + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# 'required_files' section is not needed for toy BIDS App. + +# 'alert_log_messages' section is usually not needed for toy BIDS App. From 94daa6696f57214f2d21c55a7852c16a5c0e8b5d Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Fri, 14 Jul 2023 15:06:51 -0500 Subject: [PATCH 07/23] update README for yaml files and ipynb; revise header of yaml files; --- notebooks/README.md | 8 +-- .../eg_fmriprepfake-0-1-2_full_slurm_msi.yaml | 14 ++--- ...repfake-0-1-2_legacy-layout_slurm_msi.yaml | 14 ++--- notebooks/show_babs_init_InputBIDS.ipynb | 53 +++++++++++++------ 4 files changed, 56 insertions(+), 33 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index 0003fe4b..cc72600d 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -16,6 +16,7 @@ | [link](eg_toybidsapp-0-0-7_rawBIDS_sge_cubic.yaml) | toy BIDS App | 0.0.7 |for processing raw BIDS dataset | one raw BIDS dataset | SGE | | | [link](eg_toybidsapp-0-0-7_rawBIDS_slurm_msi.yaml) | toy BIDS App | 0.0.7 |for processing raw BIDS dataset | one raw BIDS dataset | Slurm | | | [link](eg_toybidsapp-0-0-7_zipped_sge_cubic.yaml) | toy BIDS App | 0.0.7 |for processing zipped BIDS derivatives dataset | one zipped BIDS derivatives dataset | SGE | | +| [link](eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml) | toy BIDS App | 0.0.7 |for processing zipped BIDS derivatives dataset | one zipped BIDS derivatives dataset | Slurm | | | [link](eg_fmriprep-20-2-3_full_sge_cubic.yaml) | fMRIPrep | 20.2.3 | Full run of fMRIPrep | one raw BIDS dataset | SGE | | | [link](eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml) | fMRIPrep | 20.2.3 | fMRIPrep `--anat-only` mode | one raw BIDS dataset | SGE | | | [link](eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml) | fMRIPrep | 20.2.3 | fMRIPrep with FreeSurfer results ingressed | one raw BIDS dataset + one zipped BIDS derivatives dataset (of FreeSurfer results) | SGE | | @@ -23,8 +24,9 @@ | [link](eg_fmriprep-20-2-3_sloppy_slurm_msi.yaml) | fMRIPrep | 20.2.3 | fMRIPrep `--sloppy` mode | one raw BIDS dataset | Slurm | ⚠️ WARNING: only for testing! ⚠️ | | [link](eg_fmriprepfake-0-1-2_full_slurm_msi.yaml) | fmriprep-fake | 0.1.2 | fmriprep-fake, mimicking current *BIDS output layout* of fMRIPrep (v21.0+) | one raw BIDS dataset | Slurm | | | [link](eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml) | fmriprep-fake | 0.1.2 | fmriprep-fake, mimicking *legacy output layout* of fMRIPrep (< v21.0) | one raw BIDS dataset | Slurm | | -| [link](eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | SGE | ⚠️ WARNING: only for testing! ⚠️ | -| [link](eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | Slurm | ⚠️ WARNING: only for testing! ⚠️ | +| [link](eg_fmriprepfake-0-1-2_anatonly_slurm_msi.yaml) | fmriprep-fake | 0.1.2 | fmriprep-fake, using `--anat-only` | one raw BIDS dataset | Slurm | ⚠️ WARNING: For version `0.1.2`, although `--anat-only` is on, the generated files won't be different and will still include fMRI derivatives. | +| [link](eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | SGE | ⚠️ WARNING: only for testing! | +| [link](eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml) | QSIPrep | 0.16.0RC3 | QSIPrep `--sloppy` mode | one raw BIDS dataset | Slurm | ⚠️ WARNING: only for testing! | | [link](eg_xcpd-0-3-0_full_sge_cubic.yaml ) | XCP-D | 0.3.0 | XCP full run | one zipped BIDS derivatives dataset (of fMRIPrep results) | SGE | | ### BIDS App links @@ -34,7 +36,7 @@ | QSIPrep | Preprocessing dMRI data | ___ | ____ | | | XCP-D | Post-processing fMRI data | ____ | _____ | The 0.4.0 version is labeled as `04.0` on Docker Hub. | | toy BIDS App | Quick test of BABS | ____ | _____ | | -| fmriprep-fake | Mimicking fMRIPrep derivatives, for quick test | ____ | _____ | | +| fmriprep-fake | Mimicks fMRIPrep output layout and generates fake derivatives, for quick test | [Docker Hub](https://hub.docker.com/r/djarecka/fmriprep_fake); Version 0.1.2 is available [here](https://hub.docker.com/r/chenyingzhao/fmriprep_fake) | see its [GitHub repo](https://github.com/djarecka/fmriprep-fake) | | * fMRI = functional MRI * dMRI = diffusion MRI diff --git a/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml b/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml index 8bd061c5..5525dceb 100644 --- a/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml +++ b/notebooks/eg_fmriprepfake-0-1-2_full_slurm_msi.yaml @@ -1,14 +1,14 @@ -# This is an example config yaml file for fmriprep-fake version 'unstable'. -# fmriprep-fake's Docker image is publicly available at: https://hub.docker.com/r/djarecka/fmriprep_fake - # However, the version we use here is available at: https://hub.docker.com/r/chenyingzhao/fmriprep_fake -# fmriprep-fake generates fMRIPrep outputs without running fMRIPrep itself. You may use it to check fmriprep outputs. -# More details please see: https://github.com/djarecka/fmriprep-fake -# Thanks to Dorota Jarecka for preparing and sharing this BIDS App! +# This is an example config yaml file for: +# BIDS App: fmriprep-fake +# BIDS App version: 0.1.2 +# Task: regular mode, generating BIDS output layout +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster # Warning!!! # This is only an example, which may not necessarily fit your purpose, # or be an optimized solution for your case, -# or be compatible to the toy BIDS App version you're using. +# or be compatible to the BIDS App version you're using. # Therefore, please change and tailor it for your case before use it!!! # 'singularity_run': There is no such section for fmriprep-fake diff --git a/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml b/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml index 358d742d..b60c21d3 100644 --- a/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml +++ b/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml @@ -1,14 +1,14 @@ -# This is an example config yaml file for fmriprep-fake version 'unstable'. -# fmriprep-fake's Docker image is publicly available at: https://hub.docker.com/r/djarecka/fmriprep_fake - # However, the version we use here is available at: https://hub.docker.com/r/chenyingzhao/fmriprep_fake -# fmriprep-fake generates fMRIPrep outputs without running fMRIPrep itself. You may use it to check fmriprep outputs. -# More details please see: https://github.com/djarecka/fmriprep-fake -# Thanks to Dorota Jarecka for preparing and sharing this BIDS App! +# This is an example config yaml file for: +# BIDS App: fmriprep-fake +# BIDS App version: 0.1.2 +# Task: `--output-layout legacy`, generating legacy output layout +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster # Warning!!! # This is only an example, which may not necessarily fit your purpose, # or be an optimized solution for your case, -# or be compatible to the toy BIDS App version you're using. +# or be compatible to the BIDS App version you're using. # Therefore, please change and tailor it for your case before use it!!! # Arguments in `singularity run`: diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index 89ca92ac..a3f4959d 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,8 @@ "InteractiveShell.ast_node_interactivity = 'all' # print all outputs\n", "\n", "import os\n", - "import os.path as op" + "import os.path as op\n", + "import warnings" ] }, { @@ -40,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml\n" + "/home/faird/zhaoc/babs/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml\n" ] } ], @@ -55,10 +56,17 @@ "# This notebook only accepts toybidsapp_rawBIDS, qsiprep or fmriprep\n", "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", - "bidsapp = \"fmriprepfake\"\n", - "task_name = \"legacy-layout\" # for fmriprep: 'anatonly', 'sloppy'; for toybidsapp: 'rawBIDS'\n", + "bidsapp = \"toybidsapp\"\n", + "task_name = \"zipped\" \n", + "input_ds_name = \"fmriprep_anat\" # `None` if task_name is not 'zipped'\n", + "\n", + "# for fmriprep: 'anatonly', 'sloppy';\n", + "# for toybidsapp: 'rawBIDS', 'zipped'\n", + "# for fmriprep-fake: 'full' or 'legacy-layout' or 'anatonly'\n", "type_session = \"multi-ses\"\n", - "which_dataset = \"toy_fake\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\"\n", + "which_dataset = \"customize\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"customize\"\n", + "input_ds = \"/home/faird/zhaoc/data/outputs_multi-ses_fmriprepfake_anatonly\" # None\n", + "# ^^ `None`` if `which_dataset` not 'customize'; please provide the path if `which_dataset` is 'customize'\n", "\n", "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", @@ -87,7 +95,10 @@ " raise Exception(\"not valid `flag_where`!\")\n", "\n", "# Input dataset:\n", - "if which_dataset == \"toy_fake\":\n", + "if which_dataset == \"customize\":\n", + " assert (input_ds is not None)\n", + " pass # just use `input_ds` provided\n", + "elif which_dataset == \"toy_fake\":\n", " if type_session == \"multi-ses\":\n", " input_ds = \"https://osf.io/w2nu3/\"\n", " # input_ds = op.join(where_project, \"w2nu3\")\n", @@ -111,14 +122,21 @@ " input_ds = \"/home/faird/zhaoc/data/PNC_BIDS\" # cloned from RBC github account\n", "\n", "\n", + "\n", "project_name = \"test_babs_\" + type_session\n", "# Based on which dataset:\n", "if which_dataset in [\"HBN\", \"PNC\"]: # specific real dataset\n", " project_name += \"_\" + which_dataset\n", "# Based on which BIDS App:\n", "if bidsapp == \"toybidsapp\":\n", - " input_cli = [[\"BIDS\", input_ds]]\n", " container_name = bidsapp + \"-0-0-7\"\n", + " if \"rawBIDS\" in task_name:\n", + " input_ds_name = \"BIDS\"\n", + " elif \"zipped\" in task_name:\n", + " if input_ds_name is not None:\n", + " pass # just use whatever provided\n", + " else:\n", + " input_ds_name = \"zipped\"\n", "elif bidsapp in [\"fmriprep\", \"fmriprep_anatonly\", \"fmriprep_sloppy\"]:\n", " container_name = bidsapp + \"-20-2-3\"\n", "elif bidsapp == \"qsiprep\":\n", @@ -128,6 +146,9 @@ "else:\n", " raise Exception(\"Invalid `flag_instance`!\")\n", "\n", + "if input_ds_name is None:\n", + " input_ds_name = \"BIDS\"\n", + "\n", "project_name += \"_\" + bidsapp + \"_\" + task_name\n", "\n", "\n", @@ -164,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -174,11 +195,11 @@ "The command to execute:\n", "babs-init \\\n", "\t--where_project /home/faird/zhaoc/data \\\n", - "\t--project_name test_babs_multi-ses_fmriprepfake_legacy-layout \\\n", - "\t--input BIDS https://osf.io/w2nu3/ \\\n", - "\t--container_ds /home/faird/zhaoc/data/fmriprepfake-container \\\n", - "\t--container_name fmriprepfake-0-1-2 \\\n", - "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprepfake-0-1-2_legacy-layout_slurm_msi.yaml \\\n", + "\t--project_name test_babs_multi-ses_toybidsapp_zipped \\\n", + "\t--input fmriprep_anat /home/faird/zhaoc/data/outputs_multi-ses_fmriprepfake_anatonly \\\n", + "\t--container_ds /home/faird/zhaoc/data/toybidsapp-container \\\n", + "\t--container_name toybidsapp-0-0-7 \\\n", + "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml \\\n", "\t--type_session multi-ses \\\n", "\t--type_system slurm\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" @@ -189,7 +210,7 @@ "cmd = \"babs-init \\\\\\n\"\n", "cmd += \"\\t\" + \"--where_project \" + where_project + \" \\\\\\n\"\n", "cmd += \"\\t\" + \"--project_name \" + project_name + \" \\\\\\n\"\n", - "cmd += \"\\t\" + \"--input \" + \"BIDS\" + \" \" + input_ds + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--input \" + input_ds_name + \" \" + input_ds + \" \\\\\\n\"\n", "if list_sub_file is not None:\n", " cmd += \"\\t\" + \"--list_sub_file \" + list_sub_file + \" \\\\\\n\"\n", "cmd += \"\\t\" + \"--container_ds \" + container_ds + \" \\\\\\n\"\n", From aecbb5a3aab7cdff2276d5b5e55ffb220b981c8f Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Fri, 14 Jul 2023 15:10:18 -0500 Subject: [PATCH 08/23] fix typo --- notebooks/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notebooks/README.md b/notebooks/README.md index cc72600d..4e4cbc2c 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -33,10 +33,10 @@ | BIDS App | Function | Docker Hub | Docs | Notes | | :-- | :--|:-- | :-- |:-- | | fMRIPrep | Preprocessing fMRI data | ___ | ___ | The default output layout changed in `21.0.0`. BABS YAML files for new BIDS layout and legacy layout are different. | -| QSIPrep | Preprocessing dMRI data | ___ | ____ | | +| QSIPrep | Preprocessing dMRI data | [Docker Hub](https://hub.docker.com/r/pennbbl/qsiprep) | ____ | | | XCP-D | Post-processing fMRI data | ____ | _____ | The 0.4.0 version is labeled as `04.0` on Docker Hub. | | toy BIDS App | Quick test of BABS | ____ | _____ | | -| fmriprep-fake | Mimicks fMRIPrep output layout and generates fake derivatives, for quick test | [Docker Hub](https://hub.docker.com/r/djarecka/fmriprep_fake); Version 0.1.2 is available [here](https://hub.docker.com/r/chenyingzhao/fmriprep_fake) | see its [GitHub repo](https://github.com/djarecka/fmriprep-fake) | | +| fmriprep-fake | Mimics fMRIPrep output layout and generates fake derivatives, for quick test | [Docker Hub](https://hub.docker.com/r/djarecka/fmriprep_fake); Version 0.1.2 is available [here](https://hub.docker.com/r/chenyingzhao/fmriprep_fake) | see its [GitHub repo](https://github.com/djarecka/fmriprep-fake) | | * fMRI = functional MRI * dMRI = diffusion MRI From f7c9690ef0da670f7039a155416bd9acbb8e7fec Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Fri, 14 Jul 2023 18:05:53 -0500 Subject: [PATCH 09/23] add eg yaml file for fmriprep --anat-only on slurm; under testing w/ BABS 0.0.4+77.gb15513e --- ...eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml diff --git a/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml b/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml new file mode 100644 index 00000000..68cd7580 --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml @@ -0,0 +1,67 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: `--anat-only` mode +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +singularity_run: + -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` + --n_cpus: "1" + --stop-on-first-crash: "" + --fs-license-file: "/home/faird/zhaoc/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 # TODO: needed? Only generated figures, not real images... + --force-bbr: "" # TODO: needed? + -v: '-v' + --anat-only: "" # only runs the anatomical workflows + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep_anat' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep_anat: "23-1-3" # folder 'fmriprep_anat' will be zipped into 'sub-xx_(ses-yy_)fmriprep_anat-23-1-3.zip' +# Note: The generated data can also be used to provide FreeSurfer derivatives as input dataset when running fMRIPrep on fMRI data, +# i.e., for use case: fMRIPrep with FreeSurfer results ingressed. +# For that case, when using `babs-init`, for `--input`, please call this FreeSurfer derivatives dataset 'fmriprep_anat'. + +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 25G + temporary_disk_space: 200G + hard_runtime_limit: "48:00:00" + customized_text: | + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +# Because of `--anat-only`, func bold data is not needed. +required_files: + $INPUT_DATASET_#1: + - "anat/*_T1w.nii*" + +# Alert messages that might be found in log files of failed jobs: +# These messages may be helpful for debugging errors in failed jobs. +alert_log_messages: + stdout: + - "Excessive topologic defect encountered" + - "Cannot allocate memory" + - "mris_curvature_stats: Could not open file" + - "Numerical result out of range" + - "fMRIPrep failed" From 11024daeec408eae46d2b9488eecfc20a802015f Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Fri, 14 Jul 2023 18:09:48 -0500 Subject: [PATCH 10/23] test w/ new fmriprep version; minor changes iin yaml files --- ...eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml | 1 - ...eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml | 1 - notebooks/show_babs_init_InputBIDS.ipynb | 56 +++++++++++-------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml index 43e9ec53..2221731c 100644 --- a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml +++ b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_sge_cubic.yaml @@ -4,7 +4,6 @@ # Task: `--sloppy` mode # Which system: SGE # Tested on which cluster: Penn Med CUBIC cluster -# QSIPrep's Docker image is publicly available at: https://hub.docker.com/r/pennbbl/qsiprep # WARNING!!! # This is only an example, which may not necessarily fit your purpose, diff --git a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml index a6d9f2cc..737a6812 100644 --- a/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml +++ b/notebooks/eg_qsiprep-0-16-0RC3_sloppy_slurm_msi.yaml @@ -4,7 +4,6 @@ # Task: `--sloppy` mode # Which system: Slurm # Tested on which cluster: MSI cluster -# QSIPrep's Docker image is publicly available at: https://hub.docker.com/r/pennbbl/qsiprep # WARNING!!! # This is only an example, which may not necessarily fit your purpose, diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index a3f4959d..32c117f2 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -41,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/home/faird/zhaoc/babs/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml\n" + "/home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml\n" ] } ], @@ -56,16 +56,22 @@ "# This notebook only accepts toybidsapp_rawBIDS, qsiprep or fmriprep\n", "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", - "bidsapp = \"toybidsapp\"\n", - "task_name = \"zipped\" \n", - "input_ds_name = \"fmriprep_anat\" # `None` if task_name is not 'zipped'\n", - "\n", + "bidsapp = \"fmriprep\"\n", + "bidsapp_version_dash = \"23-1-3\"\n", + "# fmriprep: '20-2-3'; '23-1-3'\n", + "# qsiprep: '0-16-0RC3'\n", + "# toybidsapp: '0-0-7'\n", + "# fmirprep-fake: '0-1-2'\n", + "task_name = \"anatonly\"\n", "# for fmriprep: 'anatonly', 'sloppy';\n", "# for toybidsapp: 'rawBIDS', 'zipped'\n", "# for fmriprep-fake: 'full' or 'legacy-layout' or 'anatonly'\n", - "type_session = \"multi-ses\"\n", - "which_dataset = \"customize\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"customize\"\n", - "input_ds = \"/home/faird/zhaoc/data/outputs_multi-ses_fmriprepfake_anatonly\" # None\n", + "input_ds_name = None\n", + "# `None` if task_name is not 'zipped'; \"fmriprep_anat\" for zip files from anat workflow\n", + "\n", + "type_session = \"single-ses\"\n", + "which_dataset = \"CCNP\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"CCNP\", \"customize\"\n", + "input_ds = None # None\n", "# ^^ `None`` if `which_dataset` not 'customize'; please provide the path if `which_dataset` is 'customize'\n", "\n", "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", @@ -119,17 +125,19 @@ " input_ds = \"/home/faird/zhaoc/data/HBN_BIDS\"\n", "elif which_dataset == \"PNC\": # PNC data:\n", " assert type_session == \"single-ses\"\n", - " input_ds = \"/home/faird/zhaoc/data/PNC_BIDS\" # cloned from RBC github account\n", - "\n", + " input_ds = \"/home/faird/zhaoc/data/PNC_BIDS\" # cloned from RBC github org\n", + "elif which_dataset == \"CCNP\":\n", + " assert type_session == \"single-ses\"\n", + " input_ds = \"/home/faird/zhaoc/data/CCNP_BIDS\" # cloned from RBC github org\n", "\n", "\n", "project_name = \"test_babs_\" + type_session\n", "# Based on which dataset:\n", - "if which_dataset in [\"HBN\", \"PNC\"]: # specific real dataset\n", + "if which_dataset in [\"HBN\", \"PNC\", \"CCNP\", \"customize\"]: # specific real dataset\n", " project_name += \"_\" + which_dataset\n", "# Based on which BIDS App:\n", "if bidsapp == \"toybidsapp\":\n", - " container_name = bidsapp + \"-0-0-7\"\n", + " container_name = bidsapp + \"-\" + bidsapp_version_dash\n", " if \"rawBIDS\" in task_name:\n", " input_ds_name = \"BIDS\"\n", " elif \"zipped\" in task_name:\n", @@ -138,11 +146,11 @@ " else:\n", " input_ds_name = \"zipped\"\n", "elif bidsapp in [\"fmriprep\", \"fmriprep_anatonly\", \"fmriprep_sloppy\"]:\n", - " container_name = bidsapp + \"-20-2-3\"\n", + " container_name = bidsapp + \"-\" + bidsapp_version_dash\n", "elif bidsapp == \"qsiprep\":\n", - " container_name = bidsapp + \"-0-16-0RC3\"\n", + " container_name = bidsapp + \"-\" + bidsapp_version_dash\n", "elif bidsapp == \"fmriprepfake\":\n", - " container_name = bidsapp + \"-0-1-2\"\n", + " container_name = bidsapp + \"-\" + bidsapp_version_dash\n", "else:\n", " raise Exception(\"Invalid `flag_instance`!\")\n", "\n", @@ -185,7 +193,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -195,12 +203,12 @@ "The command to execute:\n", "babs-init \\\n", "\t--where_project /home/faird/zhaoc/data \\\n", - "\t--project_name test_babs_multi-ses_toybidsapp_zipped \\\n", - "\t--input fmriprep_anat /home/faird/zhaoc/data/outputs_multi-ses_fmriprepfake_anatonly \\\n", - "\t--container_ds /home/faird/zhaoc/data/toybidsapp-container \\\n", - "\t--container_name toybidsapp-0-0-7 \\\n", - "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_toybidsapp-0-0-7_zipped_slurm_msi.yaml \\\n", - "\t--type_session multi-ses \\\n", + "\t--project_name test_babs_single-ses_CCNP_fmriprep_anatonly \\\n", + "\t--input BIDS /home/faird/zhaoc/data/CCNP_BIDS \\\n", + "\t--container_ds /home/faird/zhaoc/data/fmriprep-container \\\n", + "\t--container_name fmriprep-23-1-3 \\\n", + "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml \\\n", + "\t--type_session single-ses \\\n", "\t--type_system slurm\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] From b0780e2cf0a8eab6ecfa8d82b7fc3d37c5cec46d Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Tue, 18 Jul 2023 16:44:37 -0500 Subject: [PATCH 11/23] add eg yaml for fmriprep freesurfer ingressed on slurm - not tested yet --- ...eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml | 2 +- ...-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml | 69 ++++++ ...mriprep-23-1-3_ingressed-fs_slurm_msi.yaml | 65 ++++++ notebooks/show_babs_init_fpfsin.ipynb | 212 ++++++++++-------- 4 files changed, 251 insertions(+), 97 deletions(-) create mode 100644 notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml create mode 100644 notebooks/eg_fmriprep-23-1-3_ingressed-fs_slurm_msi.yaml diff --git a/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml b/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml index 68cd7580..2c897eee 100644 --- a/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml +++ b/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml @@ -13,7 +13,7 @@ # Arguments in `singularity run`: singularity_run: - -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. --n_cpus: "1" --stop-on-first-crash: "" --fs-license-file: "/home/faird/zhaoc/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file diff --git a/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml new file mode 100644 index 00000000..df249154 --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml @@ -0,0 +1,69 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: Preprocessing fMRI data with FreeSurfer results ingressed, however in a sloppy mode! +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster + +# WARNING!!! +# This is in `--sloppy` mode, which is for testing ONLY, NOT for generating productions used for research! + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +# In this example, we assume: +# 1. You used BABS to run `fMRIPrep --anat-only` w/ fMRIPrep version 23.1.3, and used current BIDS output layout (default); +# 2. You have got output folder called `fmriprep_anat` (i.e., `zip_foldernames`: `fmriprep_anat`) +# 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: +# --input BIDS # 1st input dataset \ +# --input fmriprep_anat # 2nd input dataset \ +singularity_run: + $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/home/faird/zhaoc/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 + --force-bbr: "" + --cifti-output: 91k + -v: "-v" + --fs-subjects-dir: inputs/data/fmriprep_anat/fmriprep_anat/sourcedata/freesurfer + --sloppy: '' # ADD THIS WHEN TEST RUN! TOOD: remove this in a full run! + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep: "23-1-3" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-23-1-3.zip' + +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 24G + number_of_cpus: '2' + temporary_disk_space: 200G + hard_runtime_limit: "96:00:00" # note: max on MSI cluster # TODO: what's preferred? + customized_text: | + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is MSI Slurm cluster specific. +# So it may not be relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# `alert_log_messages`: Here we did not provide examples for section `alert_log_messages`. However feel free to add it! diff --git a/notebooks/eg_fmriprep-23-1-3_ingressed-fs_slurm_msi.yaml b/notebooks/eg_fmriprep-23-1-3_ingressed-fs_slurm_msi.yaml new file mode 100644 index 00000000..d474651f --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_ingressed-fs_slurm_msi.yaml @@ -0,0 +1,65 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: Preprocessing fMRI data with FreeSurfer results ingressed +# Which system: Slurm +# Tested on which cluster: UMN MSI cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +# In this example, we assume: +# 1. You used BABS to run `fMRIPrep --anat-only` w/ fMRIPrep version 23.1.3, and used current BIDS output layout (default); +# 2. You have got output folder called `fmriprep_anat` (i.e., `zip_foldernames`: `fmriprep_anat`) +# 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: +# --input BIDS # 1st input dataset \ +# --input fmriprep_anat # 2nd input dataset \ +singularity_run: + $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/home/faird/zhaoc/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 + --force-bbr: "" + --cifti-output: 91k + -v: "-v" + --fs-subjects-dir: inputs/data/fmriprep_anat/fmriprep_anat/sourcedata/freesurfer + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep: "23-1-3" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-23-1-3.zip' + +cluster_resources: + interpreting_shell: "/bin/bash -l" + hard_memory_limit: 24G + number_of_cpus: '2' + temporary_disk_space: 200G + hard_runtime_limit: "96:00:00" # note: max on MSI cluster # TODO: what's preferred? + customized_text: | + #SBATCH -p amd2tb,ram256g +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source /home/faird/shared/code/external/envs/miniconda3/load_miniconda3.sh # [FIX ME] MSI cluster faird group. Replace filepath with yours. + conda activate babs # [FIX ME] replace 'babs' with your env variable name + +# Where to run the jobs: +job_compute_space: "/tmp" # [FIX ME] MSI cluster + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# `alert_log_messages`: Here we did not provide examples for section `alert_log_messages`. However feel free to add it! diff --git a/notebooks/show_babs_init_fpfsin.ipynb b/notebooks/show_babs_init_fpfsin.ipynb index 7137e3bb..bfc83e84 100644 --- a/notebooks/show_babs_init_fpfsin.ipynb +++ b/notebooks/show_babs_init_fpfsin.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -40,35 +40,103 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml\n" + ] + } + ], "source": [ "# This notebook only accepts fmriprep with freesurfer ingressed\n", "# ++++++++++++++++++++++++++++++++++\n", - "flag_instance = \"fmriprep_ingressed_fs\"\n", - "type_session = \"multi-ses\"\n", + "bidsapp = \"fmriprep\"\n", + "bidsapp_version_dash = \"23-1-3\"\n", + "# fmriprep: '20-2-3'; '23-1-3'\n", + "task_name = \"ingressed-fs-sloppy\"\n", + "\n", + "input_ds_name_fs = \"fmriprep_anat\"\n", + "# e.g., \"fmriprep_anat\" for zip files from anat workflow\n", + "\n", + "type_session = \"single-ses\"\n", + "which_dataset = \"CCNP\" # \"toy_fake\", \"CCNP\"\n", + "input_ds_fs = \"/home/faird/zhaoc/data/outputs_single-ses_CCNP_fmriprep_anatonly\"\n", + "# ^^ path to the fmriprep `--anat-only` cloned output ria \n", + "\n", + "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", + "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", "# ++++++++++++++++++++++++++++++++++\n", - "where_project = \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data\"\n", - "where_notebooks = \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/notebooks\"\n", "\n", - "if flag_instance == \"fmriprep_ingressed_fs\":\n", - " project_name = \"test_babs_\" + type_session + \"_fpfsin\"\n", - " bidsapp = \"fmriprep\"\n", + "# sanity checks:\n", + "if flag_where == \"cubic\":\n", + " assert type_system == \"sge\"\n", + "elif flag_where == \"msi\":\n", + " assert type_system == \"slurm\"\n", + "\n", + "# where:\n", + "if flag_where == \"cubic\":\n", + " where_root = \"/cbica/projects/BABS\"\n", + " where_project = op.join(where_root, \"data\")\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "elif flag_where == \"local\":\n", + " where_root = \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper\"\n", + " where_project = op.join(where_root, \"data\")\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "elif flag_where == \"msi\":\n", + " where_root = \"/home/faird/zhaoc\"\n", + " where_project = \"/home/faird/zhaoc/data\"\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "else:\n", + " raise Exception(\"not valid `flag_where`!\")\n", + "\n", + "# Input dataset:\n", + "if which_dataset == \"CCNP\":\n", + " assert type_session == \"single-ses\"\n", + " input_ds_bids = \"/home/faird/zhaoc/data/CCNP_BIDS\" # cloned from RBC github org\n", + "elif which_dataset == \"toy_fake\":\n", " if type_session == \"multi-ses\":\n", " input_ds_bids = op.join(where_project, \"w2nu3\") # bids, multi-ses\n", " input_ds_fs = op.join(where_project, \"k9zw2\") # fmriprep done, multi-ses\n", " elif type_session == \"single-ses\":\n", " input_ds_bids = op.join(where_project, \"t8urc\") # bids, single-ses\n", " input_ds_fs = \"osf://2jvub/\" # fmriprep done, single-ses\n", - "else:\n", - " raise Exception(\"`flag_instance` is not 'fmriprep_ingressed_fs'!\")\n", "\n", - "container_ds = op.join(where_project, \"toybidsapp-container-docker\")\n", - "container_name = bidsapp + \"-0-0-0\" # \"toybidsapp-0-0-3\"\n", - "container_config_yaml_file = op.join(where_notebooks, \"example_container_\" + flag_instance + \".yaml\")\n", + "assert \"ingressed-fs\" in task_name\n", + "\n", + "bidsapp = \"fmriprep\"\n", + "container_name = \"fmriprep\" + \"-\" + bidsapp_version_dash\n", "\n", - "list_sub_file = op.join(where_notebooks, \"initial_sub_list_\" + type_session + \".csv\")" + "project_name = \"test_babs_\" + type_session\n", + "# Based on which dataset:\n", + "if which_dataset in [\"HBN\", \"PNC\", \"CCNP\", \"customize\"]: # specific real dataset\n", + " project_name += \"_\" + which_dataset\n", + "project_name += \"_\" + bidsapp + \"_\" + task_name\n", + "\n", + "# Container:\n", + "container_ds = op.join(where_project, bidsapp + \"-container\") \n", + "if flag_where == \"local\":\n", + " # container_ds += \"-docker\" # add \"docker\" at the end\n", + " container_ds = op.join(where_project, \"toybidsapp-container-docker\")\n", + "\n", + "container_config_yaml_file = op.join(where_notebooks, \"eg_\" + container_name\n", + " + \"_\" + task_name + \"_\" + type_system)\n", + "if flag_where in [\"cubic\", \"msi\"]:\n", + " container_config_yaml_file += \"_\" + flag_where\n", + "else:\n", + " if type_system == \"sge\":\n", + " container_config_yaml_file += \"_\" + \"cubic\"\n", + " elif type_system == \"slurm\":\n", + " container_config_yaml_file += \"_\" + \"msi\"\n", + "container_config_yaml_file += \".yaml\"\n", + "print(container_config_yaml_file)\n", + "assert op.exists(container_config_yaml_file)\n", + "\n", + "# list_sub_file = op.join(where_notebooks, \"initial_sub_list_\" + type_session + \".csv\")\n", + "list_sub_file = None" ] }, { @@ -80,99 +148,51 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "DataLad version: 0.17.2\n", - "nothing to save, working tree clean\n", - "nothing to save, working tree clean\n", - "\n", - "project_root of this BABS project: /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data/test_babs_multi-ses_fpfsin\n", - "type of data of this BABS project: multi-ses\n", - "job scheduling system of this BABS project: sge\n", - "\n", - "\n", - "Creating `analysis` folder (also a datalad dataset)...\n", - "\u001b[1;31muntracked\u001b[0m: .gitignore (\u001b[1;35mfile\u001b[0m)\n", - "Folder 'analysis' exists in the `project_root` and is a datalad dataset; not to re-create it.\n", - "\n", - "Creating output and input RIA...\n", - "\n", - "Registering the input dataset(s)...\n", - "The input dataset #1 'BIDS' has been copied into `analysis` folder; not to copy again.\n", - "The input dataset #2 'freesurfer' has been copied into `analysis` folder; not to copy again.\n", - "\n", - "Checking whether each input dataset is a zipped or unzipped dataset...\n", - "input dataset 'BIDS' is considered as an unzipped dataset.\n", - "input dataset 'freesurfer' is considered as a zipped dataset.\n", - "Performing sanity check for any zipped input dataset... Getting example zip file(s) to check...\n", - "\u001b[1;1mget\u001b[0m(\u001b[1;32mok\u001b[0m): sub-01_ses-A_freesurfer-20.2.3.zip (\u001b[1;35mfile\u001b[0m) [from osf-storage...]\n", - "\u001b[1;1mdrop\u001b[0m(\u001b[1;32mok\u001b[0m): sub-01_ses-A_freesurfer-20.2.3.zip (\u001b[1;35mfile\u001b[0m)\n", - "Performing sanity check for any unzipped input dataset...\n", - "\n", - "Adding the container as a sub-dataset of `analysis` dataset...\n", - "The container has been added as a sub-dataset; not to do it again.\n", - "\n", - "Generating a bash script for running container and zipping the outputs...\n", - "This bash script will be named as `fmriprep-0-0-0_zip.sh`\n", - "\n", - "/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/babs/utils.py:316: UserWarning: Usually BIDS App depends on TemplateFlow, but environment variable `TEMPLATEFLOW_HOME` was not set up. Therefore, BABS will not export it or bind its directory when running the container. This may cause errors.\n", - " warnings.warn(\"Usually BIDS App depends on TemplateFlow,\"\n", - "Below is the generated `singularity run` command:\n", - "singularity run --cleanenv -B ${PWD} \\\n", - "\tcontainers/.datalad/environments/fmriprep-0-0-0/image \\\n", - "\tinputs/data/BIDS \\\n", - "\toutputs \\\n", - "\tparticipant \\\n", - "\t-w ${PWD}/.git/tmp/wkdir \\\n", - "\t--n_cpus 1 \\\n", - "\t--stop-on-first-crash \\\n", - "\t--fs-license-file code/license.txt \\\n", - "\t--skip-bids-validation \\\n", - "\t--output-spaces MNI152NLin6Asym:res-2 \\\n", - "\t--force-bbr \\\n", - "\t--cifti-output 91k \\\n", - "\t-v -v \\\n", - "\t--fs-subjects-dir inputs/data/freesurfer/freesurfer \\\n", - "\t--bids-filter-file \"${filterfile}\" \\\n", - "\t--participant-label \"${subid}\"\n", - "Traceback (most recent call last):\n", - " File \"/Users/chenyzh/opt/miniconda3/envs/mydatalad/bin/babs-init\", line 33, in \n", - " sys.exit(load_entry_point('BABS', 'console_scripts', 'babs-init')())\n", - " File \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/babs/cli.py\", line 80, in babs_init_cli\n", - " babs_init(args.where_project, args.project_name,\n", - " File \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/babs/core_functions.py\", line 84, in babs_init\n", - " babs_proj.babs_bootstrap(input_ds, container_ds, container_name, container_config_yaml_file,\n", - " File \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/babs/babs.py\", line 335, in babs_bootstrap\n", - " container.generate_bash_run_bidsapp(bash_path, input_ds, self.type_session)\n", - " File \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/babs/babs.py\", line 881, in generate_bash_run_bidsapp\n", - " raise Exception(\n", - "Exception: FreeSurfer's license will be used but `$FREESURFER_HOME` was not set. Therefore, BABS cannot copy and paste FreeSurfer's license...\n" + "The command to execute:\n", + "babs-init \\\n", + "\t--where_project /home/faird/zhaoc/data \\\n", + "\t--project_name test_babs_single-ses_CCNP_fmriprep_ingressed-fs-sloppy \\\n", + "\t--input BIDS /home/faird/zhaoc/data/CCNP_BIDS \\\n", + "\t--input fmriprep_anat /home/faird/zhaoc/data/outputs_single-ses_CCNP_fmriprep_anatonly \\\n", + "\t--container_ds /home/faird/zhaoc/data/fmriprep-container \\\n", + "\t--container_name fmriprep-23-1-3 \\\n", + "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml \\\n", + "\t--type_session single-ses \\\n", + "\t--type_system slurm\n", + "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] } ], "source": [ - "!(babs-init \\\n", - " --where_project $where_project \\\n", - " --project_name $project_name \\\n", - " --input \"BIDS\" $input_ds_bids \\\n", - " --input \"freesurfer\" $input_ds_fs \\\n", - " --list_sub_file $list_sub_file \\\n", - " --container_ds $container_ds \\\n", - " --container_name $container_name \\\n", - " --container_config_yaml_file $container_config_yaml_file \\\n", - " --type_session $type_session \\\n", - " --type_system sge)" + "cmd = \"babs-init \\\\\\n\"\n", + "cmd += \"\\t\" + \"--where_project \" + where_project + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--project_name \" + project_name + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--input \" + \"BIDS\" + \" \" + input_ds_bids + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--input \" + input_ds_name_fs + \" \" + input_ds_fs + \" \\\\\\n\"\n", + "if list_sub_file is not None:\n", + " cmd += \"\\t\" + \"--list_sub_file \" + list_sub_file + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_ds \" + container_ds + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_name \" + container_name + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_config_yaml_file \" + container_config_yaml_file + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--type_session \" + type_session + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--type_system \" + type_system\n", + "\n", + "print(\"# The command to execute:\")\n", + "print(cmd)\n", + "print(\"WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\")" ] } ], "metadata": { "kernelspec": { - "display_name": "mydatalad", + "display_name": "babs", "language": "python", "name": "python3" }, @@ -186,12 +206,12 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13 | packaged by conda-forge | (main, May 27 2022, 16:58:50) \n[GCC 10.3.0]" + "version": "3.9.16" }, "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "abcc7813313a81f6f916a4574498d1c2de65ad7fdfeb04d04cdf237cdcbdda8b" + "hash": "2538d15ebb217aff7ed13fa29cc6f5f706af190e6008d76f30d7ce8c1383d79a" } } }, From 1499027354662cd1a9e512acdec2d00145acafd4 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Tue, 18 Jul 2023 17:46:55 -0400 Subject: [PATCH 12/23] fix typo --- notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml index df249154..441520cb 100644 --- a/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml +++ b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml @@ -33,7 +33,7 @@ singularity_run: --cifti-output: 91k -v: "-v" --fs-subjects-dir: inputs/data/fmriprep_anat/fmriprep_anat/sourcedata/freesurfer - --sloppy: '' # ADD THIS WHEN TEST RUN! TOOD: remove this in a full run! + --sloppy: '' # ADD THIS WHEN TEST RUN! TODO: remove this in a full run! # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): # As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep' to wrap all derivatives: From fd989d09916a3c7fe22796f74ef0e405f2cf865b Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Wed, 19 Jul 2023 11:16:32 -0400 Subject: [PATCH 13/23] ipynb: run locally --- notebooks/show_babs_init_InputBIDS.ipynb | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index 32c117f2..5a9d547a 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -41,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml\n" + "/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml\n" ] } ], @@ -69,12 +69,12 @@ "input_ds_name = None\n", "# `None` if task_name is not 'zipped'; \"fmriprep_anat\" for zip files from anat workflow\n", "\n", - "type_session = \"single-ses\"\n", - "which_dataset = \"CCNP\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"CCNP\", \"customize\"\n", + "type_session = \"multi-ses\"\n", + "which_dataset = \"toy_fake\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"CCNP\", \"customize\"\n", "input_ds = None # None\n", "# ^^ `None`` if `which_dataset` not 'customize'; please provide the path if `which_dataset` is 'customize'\n", "\n", - "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", + "flag_where = \"local\" # \"cubic\" or \"local\" or \"msi\"\n", "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", "# ++++++++++++++++++++++++++++++++++\n", "\n", @@ -193,7 +193,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -202,13 +202,13 @@ "text": [ "The command to execute:\n", "babs-init \\\n", - "\t--where_project /home/faird/zhaoc/data \\\n", - "\t--project_name test_babs_single-ses_CCNP_fmriprep_anatonly \\\n", - "\t--input BIDS /home/faird/zhaoc/data/CCNP_BIDS \\\n", - "\t--container_ds /home/faird/zhaoc/data/fmriprep-container \\\n", + "\t--where_project /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data \\\n", + "\t--project_name test_babs_multi-ses_fmriprep_anatonly \\\n", + "\t--input BIDS https://osf.io/w2nu3/ \\\n", + "\t--container_ds /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data/toybidsapp-container-docker \\\n", "\t--container_name fmriprep-23-1-3 \\\n", - "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml \\\n", - "\t--type_session single-ses \\\n", + "\t--container_config_yaml_file /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml \\\n", + "\t--type_session multi-ses \\\n", "\t--type_system slurm\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] @@ -244,7 +244,7 @@ ], "metadata": { "kernelspec": { - "display_name": "babs", + "display_name": "mydatalad", "language": "python", "name": "python3" }, @@ -263,7 +263,7 @@ "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "2538d15ebb217aff7ed13fa29cc6f5f706af190e6008d76f30d7ce8c1383d79a" + "hash": "3607342bbedf184dff2663f4815ec87dae3a61156c015bdcd6148f0802eb1c38" } } }, From 41e7fb76cddc1d3961271da92e49b80cc46cd8c9 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Wed, 19 Jul 2023 21:30:36 -0400 Subject: [PATCH 14/23] eg yaml file for fmriprep 23.1.3 --anat-only on sge cubic --- ...eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml | 67 +++++++++++++++++++ notebooks/show_babs_init_InputBIDS.ipynb | 26 +++---- 2 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml diff --git a/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml b/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml new file mode 100644 index 00000000..454a695a --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml @@ -0,0 +1,67 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: `--anat-only` mode +# Which system: SGE +# Tested on which cluster: PennMed CUBIC cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +singularity_run: + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. + --n_cpus: "1" + --stop-on-first-crash: "" + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 # TODO: needed? Only generated figures, not real images... + --force-bbr: "" # TODO: needed? + -v: '-v' + --anat-only: "" # only runs the anatomical workflows + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep_anat' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep_anat: "23-1-3" # folder 'fmriprep_anat' will be zipped into 'sub-xx_(ses-yy_)fmriprep_anat-23-1-3.zip' +# Note: The generated data can also be used to provide FreeSurfer derivatives as input dataset when running fMRIPrep on fMRI data, +# i.e., for use case: fMRIPrep with FreeSurfer results ingressed. +# For that case, when using `babs-init`, for `--input`, please call this FreeSurfer derivatives dataset 'fmriprep_anat'. + +cluster_resources: + interpreting_shell: /bin/bash + hard_memory_limit: 25G + temporary_disk_space: 200G + hard_runtime_limit: "48:00:00" + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +# Because of `--anat-only`, func bold data is not needed. +required_files: + $INPUT_DATASET_#1: + - "anat/*_T1w.nii*" + +# Alert messages that might be found in log files of failed jobs: +# These messages may be helpful for debugging errors in failed jobs. +alert_log_messages: + stdout: + - "Excessive topologic defect encountered" + - "Cannot allocate memory" + - "mris_curvature_stats: Could not open file" + - "Numerical result out of range" + - "fMRIPrep failed" diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index 5a9d547a..5ac3ee0b 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -41,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml\n" + "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml\n" ] } ], @@ -70,12 +70,12 @@ "# `None` if task_name is not 'zipped'; \"fmriprep_anat\" for zip files from anat workflow\n", "\n", "type_session = \"multi-ses\"\n", - "which_dataset = \"toy_fake\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"CCNP\", \"customize\"\n", + "which_dataset = \"toy_real\" # \"toy_fake\", \"toy_real\", \"HBN\", \"PNC\", \"CCNP\", \"customize\"\n", "input_ds = None # None\n", "# ^^ `None`` if `which_dataset` not 'customize'; please provide the path if `which_dataset` is 'customize'\n", "\n", - "flag_where = \"local\" # \"cubic\" or \"local\" or \"msi\"\n", - "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", + "flag_where = \"cubic\" # \"cubic\" or \"local\" or \"msi\"\n", + "type_system = \"sge\" # \"sge\" or \"slurm\"\n", "# ++++++++++++++++++++++++++++++++++\n", "\n", "# sanity checks:\n", @@ -193,7 +193,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -202,14 +202,14 @@ "text": [ "The command to execute:\n", "babs-init \\\n", - "\t--where_project /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data \\\n", + "\t--where_project /cbica/projects/BABS/data \\\n", "\t--project_name test_babs_multi-ses_fmriprep_anatonly \\\n", - "\t--input BIDS https://osf.io/w2nu3/ \\\n", - "\t--container_ds /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/data/toybidsapp-container-docker \\\n", + "\t--input BIDS /cbica/projects/BABS/data/testdata_NKI/data_hashedID_bids \\\n", + "\t--container_ds /cbica/projects/BABS/data/fmriprep-container \\\n", "\t--container_name fmriprep-23-1-3 \\\n", - "\t--container_config_yaml_file /Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper/babs/notebooks/eg_fmriprep-23-1-3_anatonly_slurm_msi.yaml \\\n", + "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml \\\n", "\t--type_session multi-ses \\\n", - "\t--type_system slurm\n", + "\t--type_system sge\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] } @@ -263,7 +263,7 @@ "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "3607342bbedf184dff2663f4815ec87dae3a61156c015bdcd6148f0802eb1c38" + "hash": "abcc7813313a81f6f916a4574498d1c2de65ad7fdfeb04d04cdf237cdcbdda8b" } } }, From 22507d41126d52a815eb6d47e9e9408349d102ea Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 20 Jul 2023 12:16:20 -0400 Subject: [PATCH 15/23] yaml files for fmriprep ingressed fs --sloppy on cubic, for both fmriprep versions --- ...20-2-3_ingressed-fs-sloppy_sge_cubic.yaml} | 29 +++++--- ...-23-1-3_ingressed-fs-sloppy_sge_cubic.yaml | 69 +++++++++++++++++++ notebooks/show_babs_init_fpfsin.ipynb | 58 +++++++++------- 3 files changed, 122 insertions(+), 34 deletions(-) rename notebooks/{eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml => eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml} (57%) create mode 100644 notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_sge_cubic.yaml diff --git a/notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml similarity index 57% rename from notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml rename to notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml index 8ce8491f..944da65e 100644 --- a/notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml @@ -1,12 +1,19 @@ # Below is example config yaml file for fMRIPrep ingressed freesurfer: +# Arguments in `singularity run`: +# In this example, we assume: +# 1. You used BABS to run `fMRIPrep --anat-only` w/ fMRIPrep version 20.2.3, which used legacy output layout +# 2. From 1, you have got output folder called `freesurfer` (i.e., `zip_foldernames`: `freesurfer`) +# 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: +# --input BIDS # 1st input dataset \ +# --input freesurfer # 2nd input dataset \ singularity_run: $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` --n_cpus: '1' --stop-on-first-crash: "" - --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # path to FS license file + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file --skip-bids-validation: "" --output-spaces: MNI152NLin6Asym:res-2 --force-bbr: "" @@ -17,30 +24,30 @@ singularity_run: # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): zip_foldernames: - fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-20-2-3.zip' + fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_(ses-yy_)fmriprep-20-2-3.zip' cluster_resources: - interpreting_shell: /bin/bash # "-S /bin/bash" on cubic - hard_memory_limit: 24G # "-l h_vmem=24G" on cubic - number_of_cpus: '2' # "-pe threaded 2" on cubic - temporary_disk_space: 200G # "-l tmpfree=200G" on cubic + interpreting_shell: /bin/bash + hard_memory_limit: 24G + number_of_cpus: '2' + temporary_disk_space: 200G customized_text: | #$ -R y #$ -l hostname=!compute-fed* # Notes: Above `customized_text` is Penn Med CUBIC cluster specific. # So it's probably not relevant for other clusters -# Users need to add their customized bash command below, -# they will be used as preambles in `participant_job.sh` -# the commands should not be quoted! +# Necessary commands to be run first: script_preamble: | source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name - echo "I am running BABS." # this is an example command to show how to add another line; not necessary to include. # Where to run the jobs: job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space +# Below is to filter out subjects (or sessions). Only those with required files will be kept. required_files: $INPUT_DATASET_#1: - "func/*_bold.nii*" - - "anat/*_T1w.nii*" \ No newline at end of file + - "anat/*_T1w.nii*" + +# `alert_log_messages`: Here we did not provide examples for section `alert_log_messages`. However feel free to add it! diff --git a/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_sge_cubic.yaml b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_sge_cubic.yaml new file mode 100644 index 00000000..7e43b82a --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_sge_cubic.yaml @@ -0,0 +1,69 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: Preprocessing fMRI data with FreeSurfer results ingressed, however in a sloppy mode! +# Which system: SGE +# Tested on which cluster: PennMed CUBIC cluster + +# WARNING!!! +# This is in `--sloppy` mode, which is for testing ONLY, NOT for generating productions used for research! + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +# In this example, we assume: +# 1. You used BABS to run `fMRIPrep --anat-only` w/ fMRIPrep version 23.1.3, and used current BIDS output layout (default); +# 2. From 1, you have got output folder called `fmriprep_anat` (i.e., `zip_foldernames`: `fmriprep_anat`) +# 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: +# --input BIDS # 1st input dataset \ +# --input fmriprep_anat # 2nd input dataset \ +singularity_run: + $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 + --force-bbr: "" + --cifti-output: 91k + -v: "-v" + --fs-subjects-dir: inputs/data/fmriprep_anat/fmriprep_anat/sourcedata/freesurfer + --sloppy: '' # ADD THIS WHEN TEST RUN! TODO: remove this in a full run! + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep: "23-1-3" # folder 'fmriprep' will be zipped into 'sub-xx_(ses-yy_)fmriprep-23-1-3.zip' + +cluster_resources: + interpreting_shell: /bin/bash + hard_memory_limit: 24G + number_of_cpus: '2' + temporary_disk_space: 200G + hard_runtime_limit: "96:00:00" # note: max on MSI cluster # TODO: what's preferred? + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# `alert_log_messages`: Here we did not provide examples for section `alert_log_messages`. However feel free to add it! diff --git a/notebooks/show_babs_init_fpfsin.ipynb b/notebooks/show_babs_init_fpfsin.ipynb index bfc83e84..007a1de3 100644 --- a/notebooks/show_babs_init_fpfsin.ipynb +++ b/notebooks/show_babs_init_fpfsin.ipynb @@ -9,7 +9,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -40,14 +40,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml\n" + "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml\n" ] } ], @@ -55,20 +55,21 @@ "# This notebook only accepts fmriprep with freesurfer ingressed\n", "# ++++++++++++++++++++++++++++++++++\n", "bidsapp = \"fmriprep\"\n", - "bidsapp_version_dash = \"23-1-3\"\n", + "bidsapp_version_dash = \"20-2-3\"\n", "# fmriprep: '20-2-3'; '23-1-3'\n", "task_name = \"ingressed-fs-sloppy\"\n", "\n", - "input_ds_name_fs = \"fmriprep_anat\"\n", - "# e.g., \"fmriprep_anat\" for zip files from anat workflow\n", + "input_ds_name_fs = \"freesurfer\"\n", + "# zip files from anat workflow:\n", + "# e.g., \"fmriprep_anat\" for fmriprep 23.1.3; \"freesurfer\" for fmriprep 20.2.3\n", "\n", "type_session = \"single-ses\"\n", - "which_dataset = \"CCNP\" # \"toy_fake\", \"CCNP\"\n", - "input_ds_fs = \"/home/faird/zhaoc/data/outputs_single-ses_CCNP_fmriprep_anatonly\"\n", + "which_dataset = \"HBN\" # \"toy_fake\", \"toy_real\", \"CCNP\", \"HBN\"\n", + "input_ds_fs = \"/cbica/projects/BABS/data/HBN_fmriprep_anat\"\n", "# ^^ path to the fmriprep `--anat-only` cloned output ria \n", "\n", - "flag_where = \"msi\" # \"cubic\" or \"local\" or \"msi\"\n", - "type_system = \"slurm\" # \"sge\" or \"slurm\"\n", + "flag_where = \"cubic\" # \"cubic\" or \"local\" or \"msi\"\n", + "type_system = \"sge\" # \"sge\" or \"slurm\"\n", "# ++++++++++++++++++++++++++++++++++\n", "\n", "# sanity checks:\n", @@ -97,6 +98,9 @@ "if which_dataset == \"CCNP\":\n", " assert type_session == \"single-ses\"\n", " input_ds_bids = \"/home/faird/zhaoc/data/CCNP_BIDS\" # cloned from RBC github org\n", + "elif which_dataset == \"HBN\":\n", + " assert type_session == \"single-ses\"\n", + " input_ds_bids = \"/cbica/projects/BABS/data/HBN_BIDS\"\n", "elif which_dataset == \"toy_fake\":\n", " if type_session == \"multi-ses\":\n", " input_ds_bids = op.join(where_project, \"w2nu3\") # bids, multi-ses\n", @@ -104,6 +108,14 @@ " elif type_session == \"single-ses\":\n", " input_ds_bids = op.join(where_project, \"t8urc\") # bids, single-ses\n", " input_ds_fs = \"osf://2jvub/\" # fmriprep done, single-ses\n", + "elif which_dataset == \"toy_real\":\n", + " if type_session == \"multi-ses\":\n", + " # input_ds_bids = \"/cbica/projects/RBC/chenying_practice/data_for_babs/NKI/data_hashedID_bids\"\n", + " input_ds_bids = \"/cbica/projects/BABS/data/testdata_NKI/data_hashedID_bids\"\n", + " elif type_session == \"single-ses\":\n", + " raise Exception(\"not supported yet!\")\n", + "else:\n", + " raise Exception(\"not valid `which_dataset`!\")\n", "\n", "assert \"ingressed-fs\" in task_name\n", "\n", @@ -114,7 +126,7 @@ "# Based on which dataset:\n", "if which_dataset in [\"HBN\", \"PNC\", \"CCNP\", \"customize\"]: # specific real dataset\n", " project_name += \"_\" + which_dataset\n", - "project_name += \"_\" + bidsapp + \"_\" + task_name\n", + "project_name += \"_\" + bidsapp + \"-\" + bidsapp_version_dash + \"_\" + task_name\n", "\n", "# Container:\n", "container_ds = op.join(where_project, bidsapp + \"-container\") \n", @@ -148,24 +160,24 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The command to execute:\n", + "# The command to execute:\n", "babs-init \\\n", - "\t--where_project /home/faird/zhaoc/data \\\n", - "\t--project_name test_babs_single-ses_CCNP_fmriprep_ingressed-fs-sloppy \\\n", - "\t--input BIDS /home/faird/zhaoc/data/CCNP_BIDS \\\n", - "\t--input fmriprep_anat /home/faird/zhaoc/data/outputs_single-ses_CCNP_fmriprep_anatonly \\\n", - "\t--container_ds /home/faird/zhaoc/data/fmriprep-container \\\n", - "\t--container_name fmriprep-23-1-3 \\\n", - "\t--container_config_yaml_file /home/faird/zhaoc/babs/notebooks/eg_fmriprep-23-1-3_ingressed-fs-sloppy_slurm_msi.yaml \\\n", + "\t--where_project /cbica/projects/BABS/data \\\n", + "\t--project_name test_babs_single-ses_HBN_fmriprep-20-2-3_ingressed-fs-sloppy \\\n", + "\t--input BIDS /cbica/projects/BABS/data/HBN_BIDS \\\n", + "\t--input freesurfer /cbica/projects/BABS/data/HBN_fmriprep_anat \\\n", + "\t--container_ds /cbica/projects/BABS/data/fmriprep-container \\\n", + "\t--container_name fmriprep-20-2-3 \\\n", + "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml \\\n", "\t--type_session single-ses \\\n", - "\t--type_system slurm\n", + "\t--type_system sge\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" ] } @@ -192,7 +204,7 @@ ], "metadata": { "kernelspec": { - "display_name": "babs", + "display_name": "mydatalad", "language": "python", "name": "python3" }, @@ -211,7 +223,7 @@ "orig_nbformat": 4, "vscode": { "interpreter": { - "hash": "2538d15ebb217aff7ed13fa29cc6f5f706af190e6008d76f30d7ce8c1383d79a" + "hash": "abcc7813313a81f6f916a4574498d1c2de65ad7fdfeb04d04cdf237cdcbdda8b" } } }, From 8891ed3214562acd728208e2f4b68625544164a5 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 20 Jul 2023 12:39:25 -0400 Subject: [PATCH 16/23] prepare yaml file for fmriprep 20.2.3 --sloppy on sge --- ...eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml | 1 + ...-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml | 19 ++++- ...mriprep-20-2-3_sloppy-no-fs_sge_cubic.yaml | 80 +++++++++++++++++++ .../eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml | 28 +++---- 4 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 notebooks/eg_fmriprep-20-2-3_sloppy-no-fs_sge_cubic.yaml diff --git a/notebooks/eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml index 9942ce12..9a7d6b3a 100644 --- a/notebooks/eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-20-2-3_anatonly_sge_cubic.yaml @@ -45,6 +45,7 @@ singularity_run: # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): # We use fMRIPrep's version string when zipping 'freesurfer' folder. +# WARNING: we will only save `freesurfer` folder, and won't save `fmriprep` folder (though it will be generated) zip_foldernames: freesurfer: "20-2-3" # folder 'freesurfer' will be zipped into 'sub-xx_ses-yy_freesurfer-20-2-3.zip' diff --git a/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml index 944da65e..5f031d82 100644 --- a/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-20-2-3_ingressed-fs-sloppy_sge_cubic.yaml @@ -1,4 +1,18 @@ -# Below is example config yaml file for fMRIPrep ingressed freesurfer: +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 20.2.3 +# Task: Preprocessing fMRI data with FreeSurfer results ingressed, however in a sloppy mode! +# Which system: SGE +# Tested on which cluster: PennMed CUBIC cluster + +# WARNING!!! +# This is in `--sloppy` mode, which is for testing ONLY, NOT for generating productions used for research! + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! # Arguments in `singularity run`: # In this example, we assume: @@ -7,7 +21,6 @@ # 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: # --input BIDS # 1st input dataset \ # --input freesurfer # 2nd input dataset \ - singularity_run: $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` @@ -39,7 +52,7 @@ cluster_resources: # Necessary commands to be run first: script_preamble: | - source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + source ${CONDA_PREFIX}/bin/activate mydatalad # [FIX ME] Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name # Where to run the jobs: job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space diff --git a/notebooks/eg_fmriprep-20-2-3_sloppy-no-fs_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_sloppy-no-fs_sge_cubic.yaml new file mode 100644 index 00000000..5b784e98 --- /dev/null +++ b/notebooks/eg_fmriprep-20-2-3_sloppy-no-fs_sge_cubic.yaml @@ -0,0 +1,80 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 20.2.3 +# Task: `--sloppy` mode + without FreeSurfer reconstruction +# Which system: SGE +# Tested on which cluster: Penn Med CUBIC cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! +# WARNING!!! +# We'll use `--sloppy` testing mode of fMRIPrep. +# Therefore this YAML file should only be used for testing purpose. +# You should NOT use this YAML file to generate formal results! + +# Arguments when executing the BIDS App using `singularity run`: +singularity_run: + -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: "MNI152NLin6Asym:res-2" # for two output spaces: e.g., "MNI152NLin6Asym:res-2 MNI152NLin2009cAsym" + --force-bbr: "" + # --cifti-output: 91k # probably not needed, as there is no FS recon + -v: '-v' # this is for double "-v" + --sloppy: '' # WARNING: use this only when testing + --fs-no-reconall: '' # WARNING: use this only when testing + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# per `--fs-no-reconall`, there won't be an output folder called `freesurfer` +zip_foldernames: + fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-20-2-3.zip' + +cluster_resources: + interpreting_shell: /bin/bash # --> "#!/bin/bash" + hard_memory_limit: 25G # --> "#$ -l h_vmem=25G" + temporary_disk_space: 200G # --> "#$ -l tmpfree=200G" # this is highly-recommended on CUBIC cluster + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Users need to add their customized bash command below, +# they will be used as preambles in `participant_job.sh` +# the commands should not be quoted! +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # [FIX ME] Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + echo "I am running BABS." # [FIX ME] this is an example command to show how to add another line; not necessary to include. + +# ^^ conda env above: where the scripts generated by BABS will run +# not necessary the same one for running `babs-init` +# ^^ based on what you need on your cluster; some people even don't use `conda`... +# for MSI, might need to add command e.g., "module_load" + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # [FIX ME] Penn Med CUBIC cluster tmp space + +# Below is to filter out subjects (or sessions) +# right now we only filter based on unzipped dataset +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# Alert messages that might be found in log files of failed jobs: +# These messages may be helpful for debugging errors in failed jobs. +alert_log_messages: + stdout: + - "Exception: No T1w images found for" # probably not needed, after setting `required_files` + - "Excessive topologic defect encountered" + - "Cannot allocate memory" + - "mris_curvature_stats: Could not open file" + - "Numerical result out of range" + - "fMRIPrep failed" + # stderr: + # - "xxxxx" diff --git a/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml index 81c5919f..573cecb9 100644 --- a/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml @@ -1,10 +1,9 @@ # This is an example config yaml file for: # BIDS App: fMRIPrep ("fmriprep") # BIDS App version: 20.2.3 -# Task: `--sloppy` mode + without FreeSurfer reconstruction +# Task: `--sloppy` mode # Which system: SGE # Tested on which cluster: Penn Med CUBIC cluster -# fMRIPrep's Docker image is publicly available at: https://hub.docker.com/r/nipreps/fmriprep/ # WARNING!!! # This is only an example, which may not necessarily fit your purpose, @@ -22,22 +21,24 @@ singularity_run: --n_cpus: '1' --stop-on-first-crash: "" --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file - --skip-bids-validation: Null # Null or NULL is also a placeholder + --skip-bids-validation: "" --output-spaces: "MNI152NLin6Asym:res-2" # for two output spaces: e.g., "MNI152NLin6Asym:res-2 MNI152NLin2009cAsym" --force-bbr: "" + --cifti-output: 91k -v: '-v' # this is for double "-v" --sloppy: '' # WARNING: use this only when testing - --fs-no-reconall: '' # WARNING: use this only when testing # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): -# per `--fs-no-reconall`, there won't be an output folder called `freesurfer` zip_foldernames: - fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_ses-yy_fmriprep-20-2-3.zip' + fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_(ses-yy_)fmriprep-20-2-3.zip' + freesurfer: "20-2-3" # folder 'freesurfer' will be zipped into 'sub-xx_(ses-yy_)freesurfer-20-2-3.zip' cluster_resources: - interpreting_shell: /bin/bash # --> "#!/bin/bash" - hard_memory_limit: 25G # --> "#$ -l h_vmem=25G" - temporary_disk_space: 200G # --> "#$ -l tmpfree=200G" # this is highly-recommended on CUBIC cluster + interpreting_shell: /bin/bash + hard_memory_limit: 25G + number_of_cpus: '2' # needed??????? + temporary_disk_space: 200G + hard_runtime_limit: "96:00:00" customized_text: | #$ -R y #$ -l hostname=!compute-fed* @@ -49,12 +50,6 @@ cluster_resources: # the commands should not be quoted! script_preamble: | source ${CONDA_PREFIX}/bin/activate mydatalad # [FIX ME] Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name - echo "I am running BABS." # [FIX ME] this is an example command to show how to add another line; not necessary to include. - -# ^^ conda env above: where the scripts generated by BABS will run -# not necessary the same one for running `babs-init` -# ^^ based on what you need on your cluster; some people even don't use `conda`... -# for MSI, might need to add command e.g., "module_load" # Where to run the jobs: job_compute_space: "${CBICA_TMPDIR}" # [FIX ME] Penn Med CUBIC cluster tmp space @@ -70,11 +65,8 @@ required_files: # These messages may be helpful for debugging errors in failed jobs. alert_log_messages: stdout: - - "Exception: No T1w images found for" # probably not needed, after setting `required_files` - "Excessive topologic defect encountered" - "Cannot allocate memory" - "mris_curvature_stats: Could not open file" - "Numerical result out of range" - "fMRIPrep failed" - # stderr: - # - "xxxxx" From 1ba9dbe1a69f3960084dfe885babefb82793ed3c Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 20 Jul 2023 12:52:23 -0400 Subject: [PATCH 17/23] add yaml file back: for ingressed fs without --sloppy; however not tested yet! --- ...mriprep-20-2-3_ingressed-fs_sge_cubic.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml diff --git a/notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml new file mode 100644 index 00000000..869e7225 --- /dev/null +++ b/notebooks/eg_fmriprep-20-2-3_ingressed-fs_sge_cubic.yaml @@ -0,0 +1,62 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 20.2.3 +# Task: Preprocessing fMRI data with FreeSurfer results ingressed +# Which system: SGE +# Tested on which cluster: PennMed CUBIC cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +# In this example, we assume: +# 1. You used BABS to run `fMRIPrep --anat-only` w/ fMRIPrep version 20.2.3, which used legacy output layout +# 2. From 1, you have got output folder called `freesurfer` (i.e., `zip_foldernames`: `freesurfer`) +# 3. When running `babs-init` for current use case, argument `--input` for `babs-init` is as below: +# --input BIDS # 1st input dataset \ +# --input freesurfer # 2nd input dataset \ +singularity_run: + $INPUT_PATH: inputs/data/BIDS # the key `$INPUT_PATH` is a placeholder, which must be included first as there are two input datasets + -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: MNI152NLin6Asym:res-2 + --force-bbr: "" + --cifti-output: 91k + -v: "-v" + --fs-subjects-dir: inputs/data/freesurfer/freesurfer + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +zip_foldernames: + fmriprep: "20-2-3" # folder 'fmriprep' will be zipped into 'sub-xx_(ses-yy_)fmriprep-20-2-3.zip' + +cluster_resources: + interpreting_shell: /bin/bash + hard_memory_limit: 24G + number_of_cpus: '2' + temporary_disk_space: 200G + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # [FIX ME] Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# `alert_log_messages`: Here we did not provide examples for section `alert_log_messages`. However feel free to add it! From 0d35a55d7bc2c56d41c1edf7046a86b42ba47f25 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Thu, 20 Jul 2023 21:34:21 -0400 Subject: [PATCH 18/23] remove request for more than 1 cpus for fmriprep --sloppy for 20.2.3 --- .../eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml | 3 +-- notebooks/show_babs_init_InputBIDS.ipynb | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml b/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml index 573cecb9..b105efb9 100644 --- a/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml @@ -18,7 +18,7 @@ # Arguments when executing the BIDS App using `singularity run`: singularity_run: -w: "$BABS_TMPDIR" # this is a placeholder. To be changed to `${PWD}/.git/tmp/wkdir` - --n_cpus: '1' + --n_cpus: '1' # seems like fMRIPrep 20.2.X that includes freesurfer recon, cannot go more than 1 cpus... --stop-on-first-crash: "" --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file --skip-bids-validation: "" @@ -36,7 +36,6 @@ zip_foldernames: cluster_resources: interpreting_shell: /bin/bash hard_memory_limit: 25G - number_of_cpus: '2' # needed??????? temporary_disk_space: 200G hard_runtime_limit: "96:00:00" customized_text: | diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index 5ac3ee0b..e521fc6d 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -41,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml\n" + "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml\n" ] } ], @@ -57,12 +57,12 @@ "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", "bidsapp = \"fmriprep\"\n", - "bidsapp_version_dash = \"23-1-3\"\n", + "bidsapp_version_dash = \"20-2-3\"\n", "# fmriprep: '20-2-3'; '23-1-3'\n", "# qsiprep: '0-16-0RC3'\n", "# toybidsapp: '0-0-7'\n", "# fmirprep-fake: '0-1-2'\n", - "task_name = \"anatonly\"\n", + "task_name = \"sloppy\"\n", "# for fmriprep: 'anatonly', 'sloppy';\n", "# for toybidsapp: 'rawBIDS', 'zipped'\n", "# for fmriprep-fake: 'full' or 'legacy-layout' or 'anatonly'\n", @@ -157,7 +157,10 @@ "if input_ds_name is None:\n", " input_ds_name = \"BIDS\"\n", "\n", - "project_name += \"_\" + bidsapp + \"_\" + task_name\n", + "if \"fmriprep\" in bidsapp:\n", + " project_name += \"_\" + bidsapp + \"-\" + bidsapp_version_dash + \"_\" + task_name\n", + "else:\n", + " project_name += \"_\" + bidsapp + \"_\" + task_name\n", "\n", "\n", "# Container:\n", @@ -193,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -203,11 +206,11 @@ "The command to execute:\n", "babs-init \\\n", "\t--where_project /cbica/projects/BABS/data \\\n", - "\t--project_name test_babs_multi-ses_fmriprep_anatonly \\\n", + "\t--project_name test_babs_multi-ses_fmriprep-20-2-3_sloppy \\\n", "\t--input BIDS /cbica/projects/BABS/data/testdata_NKI/data_hashedID_bids \\\n", "\t--container_ds /cbica/projects/BABS/data/fmriprep-container \\\n", - "\t--container_name fmriprep-23-1-3 \\\n", - "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml \\\n", + "\t--container_name fmriprep-20-2-3 \\\n", + "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml \\\n", "\t--type_session multi-ses \\\n", "\t--type_system sge\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" @@ -258,7 +261,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.16 (main, Mar 8 2023, 14:00:05) \n[GCC 11.2.0]" }, "orig_nbformat": 4, "vscode": { From 5d11baae85f62f27027762b701d9cb540a8d8794 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Sun, 23 Jul 2023 18:50:47 -0400 Subject: [PATCH 19/23] prep yaml file for fmriprep 23.1.3 --sloppy for CUBIC SGE cluster; tested it --- ...eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml | 2 +- .../eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml | 69 +++++++++++++++++++ notebooks/show_babs_init_InputBIDS.ipynb | 16 ++--- 3 files changed, 78 insertions(+), 9 deletions(-) create mode 100644 notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml diff --git a/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml b/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml index 454a695a..50c029a4 100644 --- a/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml +++ b/notebooks/eg_fmriprep-23-1-3_anatonly_sge_cubic.yaml @@ -24,7 +24,7 @@ singularity_run: --anat-only: "" # only runs the anatomical workflows # Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): -# As we are using BIDS output layout, we need to ask BABS to create a folder 'fmriprep_anat' to wrap all derivatives: +# As fMRIPrep will use BIDS output layout, we need to ask BABS to create a folder 'fmriprep_anat' to wrap all derivatives: zip_foldernames: $TO_CREATE_FOLDER: "true" fmriprep_anat: "23-1-3" # folder 'fmriprep_anat' will be zipped into 'sub-xx_(ses-yy_)fmriprep_anat-23-1-3.zip' diff --git a/notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml b/notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml new file mode 100644 index 00000000..3f0099da --- /dev/null +++ b/notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml @@ -0,0 +1,69 @@ +# This is an example config yaml file for: +# BIDS App: fMRIPrep ("fmriprep") +# BIDS App version: 23.1.3 +# Task: `--sloppy` mode +# Which system: SGE +# Tested on which cluster: Penn Med CUBIC cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! +# WARNING!!! +# We'll use `--sloppy` testing mode of fMRIPrep. +# Therefore this YAML file should only be used for testing purpose. +# You should NOT use this YAML file to generate formal results! + +# Arguments in `singularity run`: +singularity_run: + -w: "$BABS_TMPDIR" # this is a placeholder recognized by BABS. + --n_cpus: '1' + --stop-on-first-crash: "" + --fs-license-file: "/cbica/projects/BABS/software/FreeSurfer/license.txt" # [FIX ME] path to FS license file + --skip-bids-validation: "" + --output-spaces: "MNI152NLin6Asym:res-2" + --force-bbr: "" + --cifti-output: 91k + -v: '-v' + --sloppy: '' # WARNING: use this only when testing + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# As fMRIPrep will use BIDS output layout, we need to ask BABS to create a folder 'fmriprep' to wrap all derivatives: +zip_foldernames: + $TO_CREATE_FOLDER: "true" + fmriprep: "23-1-3" # folder 'fmriprep' will be zipped into 'sub-xx_(ses-yy_)fmriprep-23-1-3.zip' + +cluster_resources: + interpreting_shell: /bin/bash + hard_memory_limit: 25G + temporary_disk_space: 200G + hard_runtime_limit: "96:00:00" + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # [FIX ME] Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # [FIX ME] Penn Med CUBIC cluster tmp space + +# Below is to filter out subjects (or sessions). Only those with required files will be kept. +required_files: + $INPUT_DATASET_#1: + - "func/*_bold.nii*" + - "anat/*_T1w.nii*" + +# Alert messages that might be found in log files of failed jobs: +# These messages may be helpful for debugging errors in failed jobs. +alert_log_messages: + stdout: + - "Excessive topologic defect encountered" + - "Cannot allocate memory" + - "mris_curvature_stats: Could not open file" + - "Numerical result out of range" + - "fMRIPrep failed" diff --git a/notebooks/show_babs_init_InputBIDS.ipynb b/notebooks/show_babs_init_InputBIDS.ipynb index e521fc6d..0a8c5ba7 100644 --- a/notebooks/show_babs_init_InputBIDS.ipynb +++ b/notebooks/show_babs_init_InputBIDS.ipynb @@ -41,14 +41,14 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml\n" + "/cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml\n" ] } ], @@ -57,7 +57,7 @@ "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", "# ++++++++++++++++++++++++++++++++++\n", "bidsapp = \"fmriprep\"\n", - "bidsapp_version_dash = \"20-2-3\"\n", + "bidsapp_version_dash = \"23-1-3\"\n", "# fmriprep: '20-2-3'; '23-1-3'\n", "# qsiprep: '0-16-0RC3'\n", "# toybidsapp: '0-0-7'\n", @@ -196,7 +196,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -206,11 +206,11 @@ "The command to execute:\n", "babs-init \\\n", "\t--where_project /cbica/projects/BABS/data \\\n", - "\t--project_name test_babs_multi-ses_fmriprep-20-2-3_sloppy \\\n", + "\t--project_name test_babs_multi-ses_fmriprep-23-1-3_sloppy \\\n", "\t--input BIDS /cbica/projects/BABS/data/testdata_NKI/data_hashedID_bids \\\n", "\t--container_ds /cbica/projects/BABS/data/fmriprep-container \\\n", - "\t--container_name fmriprep-20-2-3 \\\n", - "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-20-2-3_sloppy_sge_cubic.yaml \\\n", + "\t--container_name fmriprep-23-1-3 \\\n", + "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_fmriprep-23-1-3_sloppy_sge_cubic.yaml \\\n", "\t--type_session multi-ses \\\n", "\t--type_system sge\n", "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" @@ -261,7 +261,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16 (main, Mar 8 2023, 14:00:05) \n[GCC 11.2.0]" + "version": "3.9.16" }, "orig_nbformat": 4, "vscode": { From ecf11e114f4799545fed8333e1109d7dab765ca8 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Mon, 24 Jul 2023 15:14:38 -0400 Subject: [PATCH 20/23] add eg yaml file for xcp-d 0.4.0 --- notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml | 47 ++++ notebooks/show_babs_init_xcpd.ipynb | 229 +++++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml create mode 100644 notebooks/show_babs_init_xcpd.ipynb diff --git a/notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml b/notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml new file mode 100644 index 00000000..b510cca8 --- /dev/null +++ b/notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml @@ -0,0 +1,47 @@ +# This is an example config yaml file for: +# BIDS App: XCP-D ("xcpd") +# BIDS App version: 0.4.0 +# Task: Running the entire workflow, for NIfTI images (i.e., without `--cifti`) +# Which system: SGE +# Tested on which cluster: PennMed CUBIC cluster + +# WARNING!!! +# This is only an example, which may not necessarily fit your purpose, +# or be an optimized solution for your case, +# or be compatible to the BIDS App version you're using. +# Therefore, please change and tailor it for your case before use it!!! + +# Arguments in `singularity run`: +singularity_run: + -w: "$BABS_TMPDIR" # this is a placeholder recognized BABS. + --despike: "" + --lower-bpf: "0.01" + --upper-bpf: "0.08" + -p: "36P" + --fd-thresh: "0.3" + -vvv: "" + +# Output foldername(s) to be zipped, and the BIDS App version to be included in the zip filename(s): +# XCP-D will automatically generate a folder called 'xcp_d' that wrap all the output files. +zip_foldernames: + xcp_d: "0-4-0" # folder 'xcp_d' will be zipped into 'sub-xx_(ses-yy_)xcp_d-0-4-0.zip' + +cluster_resources: + interpreting_shell: /bin/bash + hard_memory_limit: 32G + temporary_disk_space: 100G + hard_runtime_limit: "24:00:00" + customized_text: | + #$ -R y + #$ -l hostname=!compute-fed* +# Notes: Above `customized_text` is Penn Med CUBIC cluster specific. +# So it's probably not relevant for other clusters + +# Necessary commands to be run first: +script_preamble: | + source ${CONDA_PREFIX}/bin/activate mydatalad # Penn Med CUBIC cluster; replace 'mydatalad' with your conda env name + +# Where to run the jobs: +job_compute_space: "${CBICA_TMPDIR}" # Penn Med CUBIC cluster tmp space + +# `required_files` and `alert_log_messages` sections are not provided in this example. diff --git a/notebooks/show_babs_init_xcpd.ipynb b/notebooks/show_babs_init_xcpd.ipynb new file mode 100644 index 00000000..faf98d30 --- /dev/null +++ b/notebooks/show_babs_init_xcpd.ipynb @@ -0,0 +1,229 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This jupyter notebook is to show function `babs-init`." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "# See `README_howtorun_show_babs_init_ipynb.md` for how to run this file!\n", + "\n", + "# Clone out:\n", + "# datalad clone ria+file:///path/to//output_ria#~data singleORmulti-ses__outputs\n", + "# If you want to change `project_root`'s foldername, also change `output_ria/alias/data` symlink:\n", + " # cd output_ria/alias\n", + " # ln -sf /new/full/path/to/output_ria/xxx/xxx-xxx-xxx-xxx data\n", + "\n", + "# flake8: noqa\n", + "\n", + "# set up how Jupyter notebook behaves:\n", + "from IPython.core.interactiveshell import InteractiveShell\n", + "InteractiveShell.ast_node_interactivity = 'all' # print all outputs\n", + "\n", + "import os\n", + "import os.path as op\n", + "import warnings" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There are several arguments when calling `babs-init`:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "/cbica/projects/BABS/babs/notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml\n" + ] + } + ], + "source": [ + "# This notebook only accepts toybidsapp_rawBIDS, qsiprep or fmriprep\n", + "# or fmriprep_anatonly or 'fmriprep_sloppyFlag' or fmriprepfake (input ds: BIDS)\n", + "# ++++++++++++++++++++++++++++++++++\n", + "bidsapp = \"xcpd\"\n", + "bidsapp_version_dash = \"0-4-0\"\n", + "# xcp-d: '0-3-0'; '0-4-0'\n", + "\n", + "# fmriprep_version_dash = \"22-0-2\"\n", + "# fmriprep output: '22-0-2' for HBN fmriprep func outputs; '20.2.3' for CCNP fmriprep outputs\n", + "\n", + "task_name = \"nifti\" # \"nifti\"\n", + "\n", + "input_ds_name = \"fmriprep\" # \"fmriprep\"\n", + "\n", + "type_session = \"single-ses\"\n", + "which_dataset = \"CCNP\" # \"HBN\"\n", + "input_ds = None # None\n", + "# ^^ `None`` if `which_dataset` not 'customize'; please provide the path if `which_dataset` is 'customize'\n", + "\n", + "flag_where = \"cubic\" # \"cubic\" or \"local\" or \"msi\"\n", + "type_system = \"sge\" # \"sge\" or \"slurm\"\n", + "# ++++++++++++++++++++++++++++++++++\n", + "\n", + "# sanity checks:\n", + "if flag_where == \"cubic\":\n", + " assert type_system == \"sge\"\n", + "elif flag_where == \"msi\":\n", + " assert type_system == \"slurm\"\n", + "\n", + "# where:\n", + "if flag_where == \"cubic\":\n", + " where_root = \"/cbica/projects/BABS\"\n", + " where_project = op.join(where_root, \"data\")\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "elif flag_where == \"local\":\n", + " where_root = \"/Users/chenyzh/Desktop/Research/Satterthwaite_Lab/datalad_wrapper\"\n", + " where_project = op.join(where_root, \"data\")\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "elif flag_where == \"msi\":\n", + " where_root = \"/home/faird/zhaoc\"\n", + " where_project = \"/home/faird/zhaoc/data\"\n", + " where_notebooks = op.join(where_root, \"babs/notebooks\")\n", + "else:\n", + " raise Exception(\"not valid `flag_where`!\")\n", + "\n", + "# Input dataset:\n", + "if which_dataset == \"HBN\": # HBN data:\n", + " assert type_session == \"single-ses\"\n", + " if flag_where == \"cubic\":\n", + " input_ds = \"/cbica/projects/BABS/data/HBN_fmriprep_func\" # datalad sibling in BABS cubic project\n", + "elif which_dataset == \"CCNP\": # CCNP data:\n", + " assert type_session == \"single-ses\"\n", + " if flag_where == \"cubic\":\n", + " input_ds = \"/cbica/projects/BABS/data/CCNP_fmriprep\"\n", + "project_name = \"test_babs_\" + type_session\n", + "# Based on which dataset:\n", + "if which_dataset in [\"HBN\", \"PNC\", \"CCNP\", \"customize\"]: # specific real dataset\n", + " project_name += \"_\" + which_dataset\n", + "# Based on which BIDS App:\n", + "assert bidsapp == \"xcpd\"\n", + "container_name = bidsapp + \"-\" + bidsapp_version_dash\n", + "\n", + "project_name += \"_\" + bidsapp + \"_\" + task_name\n", + "\n", + "# Container:\n", + "container_ds = op.join(where_project, bidsapp + \"-container\") \n", + "if flag_where == \"local\":\n", + " # container_ds += \"-docker\" # add \"docker\" at the end\n", + " container_ds = op.join(where_project, \"toybidsapp-container-docker\")\n", + "\n", + "container_config_yaml_file = op.join(where_notebooks, \"eg_\" + container_name\n", + " + \"_\" + task_name + \"_\" + type_system)\n", + "if flag_where in [\"cubic\", \"msi\"]:\n", + " container_config_yaml_file += \"_\" + flag_where\n", + "else:\n", + " if type_system == \"sge\":\n", + " container_config_yaml_file += \"_\" + \"cubic\"\n", + " elif type_system == \"slurm\":\n", + " container_config_yaml_file += \"_\" + \"msi\"\n", + "container_config_yaml_file += \".yaml\"\n", + "print(container_config_yaml_file)\n", + "assert op.exists(container_config_yaml_file)\n", + "# container_config_yaml_file = op.join(where_notebooks, \"example_container_\" + flag_instance + \".yaml\")\n", + "\n", + "# list_sub_file = op.join(where_notebooks, \"initial_sub_list_\" + type_session + \".csv\")\n", + "list_sub_file = None" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's pass these arguments into `babs-init` CLI:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The command to execute:\n", + "babs-init \\\n", + "\t--where_project /cbica/projects/BABS/data \\\n", + "\t--project_name test_babs_single-ses_CCNP_xcpd_nifti \\\n", + "\t--input fmriprep /cbica/projects/BABS/data/CCNP_fmriprep \\\n", + "\t--container_ds /cbica/projects/BABS/data/xcpd-container \\\n", + "\t--container_name xcpd-0-4-0 \\\n", + "\t--container_config_yaml_file /cbica/projects/BABS/babs/notebooks/eg_xcpd-0-4-0_nifti_sge_cubic.yaml \\\n", + "\t--type_session single-ses \\\n", + "\t--type_system sge\n", + "WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\n" + ] + } + ], + "source": [ + "cmd = \"babs-init \\\\\\n\"\n", + "cmd += \"\\t\" + \"--where_project \" + where_project + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--project_name \" + project_name + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--input \" + input_ds_name + \" \" + input_ds + \" \\\\\\n\"\n", + "if list_sub_file is not None:\n", + " cmd += \"\\t\" + \"--list_sub_file \" + list_sub_file + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_ds \" + container_ds + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_name \" + container_name + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--container_config_yaml_file \" + container_config_yaml_file + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--type_session \" + type_session + \" \\\\\\n\"\n", + "cmd += \"\\t\" + \"--type_system \" + type_system\n", + "\n", + "print(\"The command to execute:\")\n", + "print(cmd)\n", + "print(\"WARNING: make sure you've changed `--fs-license-file` value in YAML file if you use it!!!\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "!($cmd)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "mydatalad", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.16 (main, Mar 8 2023, 14:00:05) \n[GCC 11.2.0]" + }, + "orig_nbformat": 4, + "vscode": { + "interpreter": { + "hash": "abcc7813313a81f6f916a4574498d1c2de65ad7fdfeb04d04cdf237cdcbdda8b" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 707a3990266fd6de5e54fbb15673b9b691295943 Mon Sep 17 00:00:00 2001 From: Chenying Zhao Date: Mon, 24 Jul 2023 21:44:29 -0400 Subject: [PATCH 21/23] update docs zip_foldernames section: how to ask BABS to create a wrapper output folder --- docs/source/preparation_config_yaml_file.rst | 98 +++++++++++++++++++- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/docs/source/preparation_config_yaml_file.rst b/docs/source/preparation_config_yaml_file.rst index 3f0f811c..5d63c043 100644 --- a/docs/source/preparation_config_yaml_file.rst +++ b/docs/source/preparation_config_yaml_file.rst @@ -368,15 +368,50 @@ Section ``zip_foldernames`` This section defines the name(s) of the expected output folder(s). BABS will zip those folder(s) into separate zip file(s). -Example section **zip_foldernames** for ``fMRIPrep``:: +Here we provide two examples. :ref:`Example #1 ` +is for regular use cases, +where the BIDS App will generate one or several folders that wrap all derivative files. +Example use cases are ``fMRIPrep`` with legacy output layout, as well as ``QSIPrep`` and ``XCP-D``. + +If the BIDS App won't generate one or several folders that wrap all derivative files, +users should ask BABS to create a folder as an extra layer by specifying ``$TO_CREATE_FOLDER: "true"``. +We explain how to do so in :ref:`Exmample #2 `. +An example use case is ``fMRIPrep`` with BIDS output layout. + + +.. _example_zip_foldernames_for_fmriprep_legacy_output_layout: + +Example #1: for ``fMRIPrep`` *legacy* output layout +------------------------------------------------------ + +Here we use ``fMRIPrep`` (*legacy* output layout) as an example to show you +how to write this ``zip_foldernames`` section. For this case, all derivative files +are wrapped in folders generated by fMRIPrep. Similar use cases are ``QSIPrep`` +(e.g., generating a folder called ``qsiprep``), and ``XCP-D`` (generating a folder called ``xcp_d``). + +Older versions of ``fMRIPrep`` (version < 21.0) generate +`legacy output layout `_ +which looks like below:: + + / + fmriprep/ + freesurfer/ + +In this case, ``fMRIPrep`` generates two folders, ``fmriprep`` and ``freesurfer``, +which include all derivatives. Therefore, we can directly tell BABS the expected foldernames, +without asking BABS to create them. + +Example section **zip_foldernames** for ``fMRIPrep`` *legacy* output layout: + +.. code-block:: yaml + :linenos: zip_foldernames: fmriprep: "20-2-3" freesurfer: "20-2-3" -As you can see in this example, we expect that fMRIPrep will generate two folders, -one is called ``fmriprep``, the other is called ``freesurfer``. -If there is only one expected output folder, simply provide only one. +Here, we write the expected folders in line #2 and #3. +For other BIDS Apps, if there is only one expected output folder, simply provide only one. In addition to the folder name(s), please also add the version of the BIDS App as the value. @@ -389,7 +424,60 @@ Here, ``${sub-id}`` is the subject ID (e.g., ``sub-01``), and ``${ses-id}`` is the session ID (e.g., ``ses-A``). In other words, each subject (or session) will have their specific zip file(s). -Other detailed instructions: + +.. _example_zip_foldernames_for_fmriprep_BIDS_output_layout: + +Example #2: for ``fMRIPrep`` *BIDS* output layout: asking BABS to create additional output folder +--------------------------------------------------------------------------------------------------- + +Recent ``fMRIPrep`` (version >= 21.0) uses +`BIDS output layout `_ +which looks like below:: + + / + logs/ + sub-