Commit 9c4b74a6 authored by Fidel Alfaro Almagro's avatar Fidel Alfaro Almagro
Browse files

Simplifying the executing options

parent fd7803c2
......@@ -27,14 +27,9 @@ def bb_pipeline_diff_joint(subject, jobHold, fileConfiguration, queue, coeff,
# Run bedpostX with CPU or GPU
if ((exec_block == 20) or (exec_block == 123)):
eddy_cpu = True
run_cpu = True
else:
eddy_cpu = False
if (exec_block == 40):
bedpostx_cpu = True
else:
bedpostx_cpu = False
run_cpu = False
# Run block 2 --> eddy
if ((exec_block == 0) or (exec_block == 123) or (exec_block == 2) or (exec_block == 20)):
......@@ -48,32 +43,35 @@ def bb_pipeline_diff_joint(subject, jobHold, fileConfiguration, queue, coeff,
else:
run_block_3 = False
# Run block 4 --> bedpostx + probtrack
if ((exec_block == 0) or (exec_block == 4) or (exec_block == 40)):
run_block_4 = True
else:
run_block_4 = False
# This should never happen
if ((exec_block == 1) or (exec_block == 5)):
if (exec_block == 1):
return 1
jobPOSTEDDY="1"
jobDTIFIT="1"
jobTBSS="1"
finalJob="1"
jobAUTOPTX = "1"
jobDTIFIT = "1"
jobTBSS = "1"
finalJob = "1"
if run_block_2:
jobPREPARE = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_pre_eddy_' + subject + '" -j ' + str(jobHold) + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_eddy/bb_pre_eddy ' + subject )
if eddy_cpu:
if run_cpu:
jobEDDY = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_eddy_cpu_' + subject + '" -j ' + jobPREPARE + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_eddy/bb_eddy_wrap_cpu ' + baseDir)
jobPOSTEDDY = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_post_eddy_' + subject + '" -j ' + jobEDDY + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_eddy/bb_post_eddy ' + baseDir + ' ' + coeff + ' ' + str(b_value_shell))
jobPREBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_pre_bedpostx_' + subject + '" -j ' + jobPOSTEDDY + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_pre_bedpostx ' + baseDir + '/dMRI/dMRI')
jobBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_bedpostx_cpu_' + subject + '" -j ' + jobPREBEDPOSTX + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_bedpostx_cpu ' + baseDir + '/dMRI/dMRI')
jobAUTOPTX = LT.runCommand(logger, '${BB_BIN_DIR}/bb_diffusion_pipeline/bb_autoPtx/bb_autoPtx_queue_cpu_joint ' + subject + ' ' + jobBEDPOSTX + ',' + jobTBSS + ' ' + long_queues)
else:
jobEDDY = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_eddy_gpu_' + subject + '" -j ' + jobPREPARE + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_eddy/bb_eddy_wrap_gpu ' + baseDir)
jobPOSTEDDY = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_post_eddy_' + subject + '" -j ' + jobEDDY + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_eddy/bb_post_eddy ' + baseDir + ' ' + coeff + ' ' + str(b_value_shell))
finalJob = finalJob + "," + str(jobPOSTEDDY)
jobPREBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_pre_bedpostx_' + subject + '" -j ' + jobPOSTEDDY + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_pre_bedpostx ' + baseDir + '/dMRI/dMRI')
jobBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_bedpostx_gpu_' + subject + '" -j ' + jobPREBEDPOSTX + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_bedpostx_gpu ' + baseDir + '/dMRI/dMRI')
jobAUTOPTX = LT.runCommand(logger, '${BB_BIN_DIR}/bb_diffusion_pipeline/bb_autoPtx/bb_autoPtx_queue_gpu_joint ' + subject + ' ' + jobBEDPOSTX + ',' + jobTBSS + ' ' + long_queues)
finalJob = finalJob + "," + str(jobAUTOPTX)
if run_block_3:
jobDTIFIT = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_dtifit_' + subject + '" -j ' + jobPOSTEDDY + ' -l ' + logDir + ' ${FSLDIR}/bin/dtifit -k ' + baseDir + '/dMRI/dMRI/data_ud_1_shell -m ' + baseDir + '/dMRI/dMRI/nodif_brain_mask_ud -r ' + baseDir + '/dMRI/dMRI/data_ud_1_shell.bvec -b ' + baseDir + '/dMRI/dMRI/data_ud_1_shell.bval -o ' + baseDir + '/dMRI/dMRI/dti')
jobDTIFIT = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_dtifit_' + subject + '" -j ' + jobAUTOPTX + ' -l ' + logDir + ' ${FSLDIR}/bin/dtifit -k ' + baseDir + '/dMRI/dMRI/data_ud_1_shell -m ' + baseDir + '/dMRI/dMRI/nodif_brain_mask_ud -r ' + baseDir + '/dMRI/dMRI/data_ud_1_shell.bvec -b ' + baseDir + '/dMRI/dMRI/data_ud_1_shell.bval -o ' + baseDir + '/dMRI/dMRI/dti')
jobTBSS = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_tbss_' + subject + '" -j ' + jobDTIFIT + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_tbss/bb_tbss_general ' + subject )
if num_shells > 1:
jobNODDI = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_NODDI_' + subject + '" -j ' + jobTBSS + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_NODDI ' + subject )
......@@ -81,17 +79,4 @@ def bb_pipeline_diff_joint(subject, jobHold, fileConfiguration, queue, coeff,
else:
finalJob = finalJob + "," + str(jobTBSS)
if run_block_4:
jobPREBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + short_queues + ' -N "bb_pre_bedpostx_' + subject + '" -j ' + jobDTIFIT + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_pre_bedpostx ' + baseDir + '/dMRI/dMRI')
if bedpostx_cpu:
jobBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_bedpostx_cpu_' + subject + '" -j ' + jobPREBEDPOSTX + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_bedpostx_cpu ' + baseDir + '/dMRI/dMRI')
jobAUTOPTX = LT.runCommand(logger, '${BB_BIN_DIR}/bb_diffusion_pipeline/bb_autoPtx/bb_autoPtx_queue_cpu_joint ' + subject + ' ' + jobBEDPOSTX + ',' + jobTBSS + ' ' + long_queues)
else:
jobBEDPOSTX = LT.runCommand(logger, '${FSLDIR}/bin/fsl_sub -q ' + long_queues + ' -N "bb_bedpostx_gpu_' + subject + '" -j ' + jobPREBEDPOSTX + ' -l ' + logDir + ' $BB_BIN_DIR/bb_diffusion_pipeline/bb_bedpostx/bb_bedpostx_gpu ' + baseDir + '/dMRI/dMRI')
jobAUTOPTX = LT.runCommand(logger, '${BB_BIN_DIR}/bb_diffusion_pipeline/bb_autoPtx/bb_autoPtx_queue_gpu_joint ' + subject + ' ' + jobBEDPOSTX + ',' + jobTBSS + ' ' + long_queues)
finalJob = finalJob + "," + str(jobAUTOPTX)
return finalJob
......@@ -35,7 +35,7 @@ class Usage(Exception):
def choose_block(subject, runTopup, fileConfig, queue, coeff, num_shells,
b_value_shell, exec_block):
if exec_block == 0:
if ((exec_block == 0) or (exec_block == 123)):
# Default value for job id. SGE does not wait for a job with this id.
jobSTEP2 = "1"
jobSTEP3 = "1"
......@@ -62,44 +62,36 @@ def choose_block(subject, runTopup, fileConfig, queue, coeff, num_shells,
jobSTEP1 = bb_pipeline_struct(subject, runTopup, fileConfig, queue, coeff)
if runTopup:
jobSTEP2 = bb_pipeline_func(subject, jobSTEP1, fileConfig, queue, coeff)
return jobSTEP2
else:
return jobSTEP1
elif exec_block == 123:
jobSTEP1 = bb_pipeline_struct(subject, runTopup, fileConfig, queue, coeff)
if runTopup:
jobSTEP2 = bb_pipeline_func(subject, jobSTEP1, fileConfig, queue, coeff)
jobSTEP3 = bb_pipeline_diff_joint(subject, jobSTEP1, fileConfig, queue,
coeff, num_shells, b_value_shell,
exec_block)
jobSTEP3 = bb_pipeline_asl(subject, jobSTEP1, fileConfig)
return jobSTEP3
else:
return jobSTEP1
elif ((exec_block == 2) or (exec_block == 20) or (exec_block == 3) or
(exec_block == 4) or (exec_block == 40)):
elif ((exec_block == 2) or (exec_block == 20)):
if runTopup:
jobSTEP3 = bb_pipeline_diff_joint(subject, 1, fileConfig, queue,
jobSTEP2 = bb_pipeline_diff_joint(subject, 1, fileConfig, queue,
coeff, num_shells, b_value_shell,
exec_block)
return jobSTEP3
return jobSTEP2
else:
return 1
if exec_block == 5:
elif (exec_block == 3)):
jobSTEP1 = "1"
jobSTEP3 = "1"
jobSTEP4 = "1"
if runTopup:
jobSTEP4 = bb_pipeline_asl(subject, 1, fileConfig)
jobSTEP3 = bb_pipeline_diff_joint(subject, jobSTEP1, fileConfig, queue,
coeff, num_shells, b_value_shell,
exec_block)
jobSTEP5 = bb_pipeline_FS(subject, 1, fileConfig, queue)
jobSTEP6 = bb_IDP(subject, str(jobSTEP4), fileConfig, queue)
jobSTEP5 = bb_pipeline_FS(subject, jobSTEP1, fileConfig, queue)
jobSTEP6 = bb_IDP(subject, str(jobSTEP1) + "," + str(jobSTEP2) + "," + str(jobSTEP3) + "," + str(jobSTEP4),
fileConfig, queue)
jobSTEP7 = bb_post_pipeline(subject, str(jobSTEP4) + "," + str(jobSTEP5) + "," + str(jobSTEP6),
fileConfig, queue)
return jobSTEP7
else:
return 1
......@@ -161,15 +153,12 @@ def main():
dest="num_shells")
parser.add_argument("-X", "--exec_block", action="store", nargs="?", default=0,
help='Pipeline block(s) to execute: Option (default 0): \n' +
' - 0: Run the whole pipeline with default parameters \n' +
' - 1: Run (CPU) 1st block (up until eddy) \n' +
' - 2: Run (GPU) 2nd block (eddy) \n' +
' - 3: Run (CPU) 3rd block (after eddy, before bedpostX + probtrackX) \n' +
' - 4: Run (GPU) 4th block (bedpostX + probtrackX) \n' +
' - 5: Run (CPU) 5th block (everything after bedpostX + probtrackX) \n' +
' - 20: Run (CPU) 2nd block (eddy) \n '+
' - 40: Run (CPU) 4th block (bedpostX + probtrackX) \n ' +
' - 123: Run (CPU) 1st, 2nd, & 3rd block (up until bedpostX) \n ',
' - 0 Run the whole pipeline with default parameters \n' +
' - 1 Run (CPU) 1st block (up until eddy) \n' +
' - 2 Run (GPU) 2nd block (eddy + bedpostX + probtrackX) \n' +
' - 3 Run (CPU) 3rd block (after eddy + bedpostX + probtrackX) \n' +
' - 20 Run (CPU) 2nd block (eddy + bedpostX + probtrackX) \n '+
' - 123 Run (CPU) 1st, 2nd, & 3rd block \n ',
dest="exec_block")
#########################
......@@ -323,7 +312,7 @@ def main():
else:
try:
exec_block = int(argsa.exec_block)
allowed_values = [0, 1, 2, 3, 4, 5, 20, 40, 123]
allowed_values = [0, 1, 2, 3, 20, 123]
if not exec_block in allowed_values:
logger.warning("ERROR in the eXecute block: " + exec_block +
......
......@@ -34,6 +34,6 @@ cd /ukbdata/;
mkdir $SUBJID/logs/
$BB_BIN_DIR/bb_autodownload/bb_convert_no_ram_disk $SUBJID $VISIT &> $SUBJID/logs/conv.txt
$BB_BIN_DIR//bb_pipeline_tools/bb_pipeline_queue.py $SUBJID -X 123
$BB_BIN_DIR//bb_pipeline_tools/bb_pipeline_queue.py $SUBJID -X 1
. $BB_BIN_DIR/bb_pipeline_tools/bb_set_footer
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment