-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reconstruct ecpac call for re-running; Refactoring
- Loading branch information
Showing
4 changed files
with
221 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pathlib as pl | ||
from typing import Optional | ||
|
||
import click | ||
|
||
|
||
def check_exist_file(path: pl.Path, label: str = "") -> bool: | ||
"""Check if a file exists. Or print a message if it doesn't.""" | ||
if path.exists() and path.is_file(): | ||
return True | ||
click.secho(f'Error: {label} file does not exist! "{path}"', fg="red") | ||
return False | ||
|
||
|
||
def check_exist_dir(path: pl.Path, label: str = "") -> bool: | ||
"""Check if a directory exists. Or print a message if it doesn't.""" | ||
if path.exists() and path.is_dir(): | ||
return True | ||
click.secho(f'Error: {label} directory does not exist! "{path}"', fg="red") | ||
return False | ||
|
||
|
||
def option_or_prompt(opt: Optional[str], prompt: str, default: Optional[str] = None) -> str: | ||
"""Prompt the user for input if the option is not provided.""" | ||
if opt is not None: | ||
return opt | ||
return click.prompt(prompt, default=default, type=str) | ||
|
||
|
||
def option_or_confirm(opt: Optional[bool], prompt: str, default: Optional[bool] = False) -> bool: | ||
"""Prompt the user for input (confirmation boolean) if the option is not provided.""" | ||
if opt is not None: | ||
return opt | ||
return click.confirm(prompt, default=default) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
import pathlib as pl | ||
|
||
ID_PIPELINE_DEFAULT = "default" | ||
FILENAME_JOB = "job.sh" | ||
FOLDERNAME_OUTPUT = "output" | ||
|
||
# Grab from $PROJECT, which is "/ocean/projects/{med000000p}/{username}" | ||
ENV_PROJECT = os.environ.get("PROJECT", "") | ||
PSC_PROJECT_USER = pl.Path(ENV_PROJECT) | ||
PSC_OUTPUT_DEFAULT = PSC_PROJECT_USER / "ecpac_runs" | ||
PSC_IMAGE_DEFAULT = PSC_PROJECT_USER / "images/cpac.sif" | ||
|
||
CPAC_ANALYSIS_LEVELS = ("participant", "group", "test_config") | ||
ANALYSIS_LEVEL_DEFAULT = "participant" | ||
CPAC_PRECONFIGS = [ | ||
"abcd-options", | ||
"abcd-prep", | ||
"anat-only", | ||
"benchmark-FNIRT", | ||
"blank", | ||
"ccs-options", | ||
"default", | ||
"default-deprecated", | ||
"fmriprep-options", | ||
"fx-options", | ||
"monkey", | ||
"ndmg", | ||
"nhp-macaque", | ||
"preproc", | ||
"rbc-options", | ||
"rodent", | ||
] | ||
|
||
|
||
BASH_TEMPLATE_JOB = """\ | ||
#!/usr/bin/bash | ||
#SBATCH --job-name {job_name} | ||
#SBATCH --output {stdout_file} | ||
#SBATCH --nodes 1 | ||
#SBATCH --partition RM-shared | ||
#SBATCH --time {duration_str} | ||
#SBATCH --ntasks-per-node {threads} | ||
#SBATCH --mem {memory_mb} | ||
set -x | ||
cd {wd} | ||
singularity run \ | ||
--cleanenv \ | ||
{cpac_bin_opt} \ | ||
-B {path_input}:{path_input}:ro \ | ||
-B {path_output}:{path_output} \ | ||
{image} {path_input} {path_output} {analysis_level} \ | ||
--skip_bids_validator \ | ||
--n_cpus {cpac_threads} \ | ||
--mem_gb {cpac_memory_gb} \ | ||
--participant_label {subject} \ | ||
{pipeline} \ | ||
{extra_cpac_args} | ||
""" | ||
|
||
BASH_TEMPLATE_PIPELINE_PRECONFIG = "--preconfig {pipeline}" | ||
BASH_TEMPLATE_PIPELINE_CONFIG_FILE = "--pipeline-file {pipeline}" | ||
|
||
|
||
BASH_TEMPLATE_JOB_CPAC_BIN = """\ | ||
-B {cpac_bin}/CPAC:/code/CPAC \ | ||
-B {cpac_bin}/dev/docker_data/run.py:/code/run.py \ | ||
-B {cpac_bin}/dev/docker_data:/cpac_resources \ | ||
""" |
Oops, something went wrong.