aces / cbrain-plugins-neuro

5 stars 19 forks source link

FSL melodic: make task relocatable. #23

Open glatard opened 8 years ago

glatard commented 8 years ago

As noticed by @prioux:

I had a quick look at the work directory of that task, and in the .qsub file all the data files are always substitued with complete full path to the task's work directory. Is that really necessary? The entire point of writing a task is to encapsulate the processing locally in the work directory, to make things relocatable even accross clusters. Full paths defeat this completely. Couldn't all operations be performed with relative paths instead? e.g. instead of

# Extracts dimensions of file /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz
${FSLINFO} /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz | awk '$1=="dim1" || $1=="dim2" || $1=="dim3" || $1=="dim4" {print}'> /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz.fslinfo
# Extracts TR of file /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz
${FSLHD} /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz | awk '$1=="pixdim4" {print $2}' > /gs/project/eim-670-aa/cbrain/data/gridshare/31/01/02/nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz.trvalue

why not :

# Extracts dimensions of file nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz
${FSLINFO} nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz | awk '$1=="dim1" || $1=="dim2" || $1=="dim3" || $1=="dim4" {print}' > nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz.fslinfo
# Extracts TR of file nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz
${FSLHD} nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz | awk '$1=="pixdim4" {print $2}' > nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz.trvalue

Also, the bash commands could be split on multiple lines to make things prettier. And no need to repeat the file name in the comment

# Extracts dimensions
${FSLINFO} \
    nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz | \
    awk '$1=="dim1" || $1=="dim2" || $1=="dim3" || $1=="dim4" {print}' \
    > nmahani-FslMelodic-T310102/Spin002^^^^_resting_post1_SENSE_FSL_14_1.nii.gz.fslinfo
glatard commented 8 years ago

While here, review the generated bash scripts, fix (minor) identation issues and add missing comments, e.g. for XDIM, YDIM, ZDIM, TDIM checks.